Skip to content

Commit

Permalink
OpenAPI Spec fix nullable alongside $ref (#32887)
Browse files Browse the repository at this point in the history
* OpenAPI Spec fix nullable alongside $ref

* Fix CI

* Update following code review

* Add deprecation warning for 'none' state.
  • Loading branch information
pierrejeambrun committed Aug 2, 2023
1 parent fea8c90 commit 3141d4b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
2 changes: 1 addition & 1 deletion airflow/api_connexion/endpoints/task_instance_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def get_mapped_task_instances(
def _convert_ti_states(states: Iterable[str] | None) -> list[TaskInstanceState | None] | None:
if not states:
return None
return [None if s == "none" else TaskInstanceState(s) for s in states]
return [None if s in ("none", None) else TaskInstanceState(s) for s in states]


def _apply_array_filter(query: Select, key: ClauseElement, values: Iterable[Any] | None) -> Select:
Expand Down
17 changes: 9 additions & 8 deletions airflow/api_connexion/openapi/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3228,7 +3228,6 @@ components:
items:
$ref: '#/components/schemas/Provider'


SLAMiss:
type: object
properties:
Expand Down Expand Up @@ -3256,6 +3255,7 @@ components:

Trigger:
type: object
nullable: true
properties:
id:
type: integer
Expand All @@ -3272,6 +3272,7 @@ components:

Job:
type: object
nullable: true
properties:
id:
type: integer
Expand Down Expand Up @@ -3335,7 +3336,6 @@ components:
nullable: true
state:
$ref: '#/components/schemas/TaskState'
nullable: true
try_number:
type: integer
map_index:
Expand Down Expand Up @@ -3371,7 +3371,6 @@ components:
type: string
sla_miss:
$ref: '#/components/schemas/SLAMiss'
nullable: true
rendered_fields:
description: |
JSON object describing rendered fields.
Expand All @@ -3380,10 +3379,8 @@ components:
type: object
trigger:
$ref: '#/components/schemas/Trigger'
nullable: true
triggerer_job:
$ref: '#/components/schemas/Job'
nullable: true
note:
type: string
description: |
Expand Down Expand Up @@ -3561,7 +3558,6 @@ components:
*Changed in version 2.0.1*: Field becomes nullable.
dag_run_timeout:
nullable: true
$ref: '#/components/schemas/TimeDelta'
doc_md:
type: string
Expand Down Expand Up @@ -3699,10 +3695,8 @@ components:
readOnly: true
execution_timeout:
$ref: '#/components/schemas/TimeDelta'
nullable: true
retry_delay:
$ref: '#/components/schemas/TimeDelta'
nullable: true
retry_exponential_backoff:
type: boolean
readOnly: true
Expand Down Expand Up @@ -4506,6 +4500,7 @@ components:
TimeDelta:
description: Time delta
type: object
nullable: true
required:
- __type
- days
Expand Down Expand Up @@ -4646,8 +4641,14 @@ components:
*Changed in version 2.4.0*: 'sensing' state has been removed.
*Changed in version 2.4.2*: 'restarting' is added as a possible value
*Changed in version 2.7.0*: Field becomes nullable and null primitive is added as a possible value.
*Changed in version 2.7.0*: 'none' state is deprecated in favor of null.
type: string
nullable: true
enum:
- null
- success
- running
- failed
Expand Down
2 changes: 1 addition & 1 deletion airflow/api_connexion/schemas/task_instance_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TaskInstanceBatchFormSchema(Schema):
end_date_lte = fields.DateTime(load_default=None, validate=validate_istimezone)
duration_gte = fields.Int(load_default=None)
duration_lte = fields.Int(load_default=None)
state = fields.List(fields.Str(), load_default=None)
state = fields.List(fields.Str(allow_none=True), load_default=None)
pool = fields.List(fields.Str(), load_default=None)
queue = fields.List(fields.Str(), load_default=None)

Expand Down
55 changes: 31 additions & 24 deletions airflow/www/static/js/types/api-generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ export interface components {
/** Format: datetime */
created_date?: string;
triggerer_id?: number | null;
};
} | null;
Job: {
id?: number;
dag_id?: string | null;
Expand All @@ -1320,7 +1320,7 @@ export interface components {
executor_class?: string | null;
hostname?: string | null;
unixname?: string | null;
};
} | null;
TaskInstance: {
task_id?: string;
dag_id?: string;
Expand All @@ -1337,7 +1337,7 @@ export interface components {
/** Format: datetime */
end_date?: string | null;
duration?: number | null;
state?: components["schemas"]["TaskState"] | null;
state?: components["schemas"]["TaskState"];
try_number?: number;
map_index?: number;
max_tries?: number;
Expand All @@ -1352,15 +1352,15 @@ export interface components {
queued_when?: string | null;
pid?: number | null;
executor_config?: string;
sla_miss?: components["schemas"]["SLAMiss"] | null;
sla_miss?: components["schemas"]["SLAMiss"];
/**
* @description JSON object describing rendered fields.
*
* *New in version 2.3.0*
*/
rendered_fields?: { [key: string]: unknown };
trigger?: components["schemas"]["Trigger"] | null;
triggerer_job?: components["schemas"]["Job"] | null;
trigger?: components["schemas"]["Trigger"];
triggerer_job?: components["schemas"]["Job"];
/**
* @description Contains manually entered notes by the user about the TaskInstance.
*
Expand Down Expand Up @@ -1460,7 +1460,7 @@ export interface components {
* *Changed in version 2.0.1*: Field becomes nullable.
*/
start_date?: string | null;
dag_run_timeout?: components["schemas"]["TimeDelta"] | null;
dag_run_timeout?: components["schemas"]["TimeDelta"];
doc_md?: string | null;
default_view?: string;
/**
Expand Down Expand Up @@ -1535,8 +1535,8 @@ export interface components {
queue?: string | null;
pool?: string;
pool_slots?: number;
execution_timeout?: components["schemas"]["TimeDelta"] | null;
retry_delay?: components["schemas"]["TimeDelta"] | null;
execution_timeout?: components["schemas"]["TimeDelta"];
retry_delay?: components["schemas"]["TimeDelta"];
retry_exponential_backoff?: boolean;
priority_weight?: number;
weight_rule?: components["schemas"]["WeightRule"];
Expand Down Expand Up @@ -2059,7 +2059,7 @@ export interface components {
days: number;
seconds: number;
microseconds: number;
};
} | null;
/** @description Relative delta */
RelativeDelta: {
__type: string;
Expand Down Expand Up @@ -2134,22 +2134,29 @@ export interface components {
* *Changed in version 2.4.0*: 'sensing' state has been removed.
* *Changed in version 2.4.2*: 'restarting' is added as a possible value
*
* @enum {string}
* *Changed in version 2.7.0*: Field becomes nullable and null primitive is added as a possible value.
* *Changed in version 2.7.0*: 'none' state is deprecated in favor of null.
*
* @enum {string|null}
*/
TaskState:
| "success"
| "running"
| "failed"
| "upstream_failed"
| "skipped"
| "up_for_retry"
| "up_for_reschedule"
| "queued"
| "none"
| "scheduled"
| "deferred"
| "removed"
| "restarting";
| (
| null
| "success"
| "running"
| "failed"
| "upstream_failed"
| "skipped"
| "up_for_retry"
| "up_for_reschedule"
| "queued"
| "none"
| "scheduled"
| "deferred"
| "removed"
| "restarting"
)
| null;
/**
* @description DAG State.
*
Expand Down

0 comments on commit 3141d4b

Please sign in to comment.