This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-7-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit b868b32bf8d78fd7994809b5e940c54a0b08305d Author: Pierre Jeambrun <[email protected]> AuthorDate: Wed Aug 2 19:53:06 2023 +0200 OpenAPI Spec fix nullable alongside $ref (#32887) * OpenAPI Spec fix nullable alongside $ref * Fix CI * Update following code review * Add deprecation warning for 'none' state. (cherry picked from commit 3141d4bff5fb80267b3f38955838eac89c9098fd) --- .../endpoints/task_instance_endpoint.py | 2 +- airflow/api_connexion/openapi/v1.yaml | 17 +++---- .../api_connexion/schemas/task_instance_schema.py | 2 +- airflow/www/static/js/types/api-generated.ts | 55 ++++++++++++---------- 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/airflow/api_connexion/endpoints/task_instance_endpoint.py b/airflow/api_connexion/endpoints/task_instance_endpoint.py index c0f1f7079e..ab4b24f8f2 100644 --- a/airflow/api_connexion/endpoints/task_instance_endpoint.py +++ b/airflow/api_connexion/endpoints/task_instance_endpoint.py @@ -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: diff --git a/airflow/api_connexion/openapi/v1.yaml b/airflow/api_connexion/openapi/v1.yaml index d69bbf0b9c..b3b4a0f5f0 100644 --- a/airflow/api_connexion/openapi/v1.yaml +++ b/airflow/api_connexion/openapi/v1.yaml @@ -3228,7 +3228,6 @@ components: items: $ref: '#/components/schemas/Provider' - SLAMiss: type: object properties: @@ -3256,6 +3255,7 @@ components: Trigger: type: object + nullable: true properties: id: type: integer @@ -3272,6 +3272,7 @@ components: Job: type: object + nullable: true properties: id: type: integer @@ -3335,7 +3336,6 @@ components: nullable: true state: $ref: '#/components/schemas/TaskState' - nullable: true try_number: type: integer map_index: @@ -3371,7 +3371,6 @@ components: type: string sla_miss: $ref: '#/components/schemas/SLAMiss' - nullable: true rendered_fields: description: | JSON object describing rendered fields. @@ -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: | @@ -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 @@ -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 @@ -4506,6 +4500,7 @@ components: TimeDelta: description: Time delta type: object + nullable: true required: - __type - days @@ -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 diff --git a/airflow/api_connexion/schemas/task_instance_schema.py b/airflow/api_connexion/schemas/task_instance_schema.py index 359294f5d4..c929da3099 100644 --- a/airflow/api_connexion/schemas/task_instance_schema.py +++ b/airflow/api_connexion/schemas/task_instance_schema.py @@ -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) diff --git a/airflow/www/static/js/types/api-generated.ts b/airflow/www/static/js/types/api-generated.ts index 5387da0cc1..f791db4385 100644 --- a/airflow/www/static/js/types/api-generated.ts +++ b/airflow/www/static/js/types/api-generated.ts @@ -1305,7 +1305,7 @@ export interface components { /** Format: datetime */ created_date?: string; triggerer_id?: number | null; - }; + } | null; Job: { id?: number; dag_id?: string | null; @@ -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; @@ -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; @@ -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. * @@ -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; /** @@ -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"]; @@ -2059,7 +2059,7 @@ export interface components { days: number; seconds: number; microseconds: number; - }; + } | null; /** @description Relative delta */ RelativeDelta: { __type: string; @@ -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. *
