From 79ea68da81e1605a009f9241c43657bcc39fcc18 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Thu, 3 Oct 2024 02:15:11 +0530 Subject: [PATCH] Use lambda for aliases, re-run breeze static checks --- airflow/api_fastapi/openapi/v1-generated.yaml | 30 +++++--------- airflow/api_fastapi/serializers/dags.py | 14 +++---- .../ui/openapi-gen/requests/schemas.gen.ts | 40 ++++++------------- airflow/ui/openapi-gen/requests/types.gen.ts | 14 +++---- 4 files changed, 33 insertions(+), 65 deletions(-) diff --git a/airflow/api_fastapi/openapi/v1-generated.yaml b/airflow/api_fastapi/openapi/v1-generated.yaml index 2777a55f6844..59471149edc3 100644 --- a/airflow/api_fastapi/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/openapi/v1-generated.yaml @@ -594,12 +594,12 @@ components: catchup: type: boolean title: Catchup - dagrun_timeout: + dag_run_timeout: anyOf: - type: string format: duration - type: 'null' - title: Dagrun Timeout + title: Dag Run Timeout dataset_expression: anyOf: - type: object @@ -632,31 +632,30 @@ components: title: Orientation params: anyOf: - - {} + - type: object - type: 'null' title: Params render_template_as_native_obj: type: boolean title: Render Template As Native Obj - template_searchpath: + template_search_path: anyOf: - - type: string - items: type: string type: array - type: 'null' - title: Template Searchpath + title: Template Search Path timezone: anyOf: - type: string - type: 'null' title: Timezone - last_loaded: + last_parsed: anyOf: - type: string format: date-time - type: 'null' - title: Last Loaded + title: Last Parsed file_token: type: string title: File Token @@ -667,14 +666,6 @@ components: title: Concurrency description: Return max_active_tasks as concurrency. readOnly: true - last_parsed: - anyOf: - - type: string - format: date-time - - type: 'null' - title: Last Parsed - description: Return last_loaded as last_parsed. - readOnly: true type: object required: - dag_id @@ -703,7 +694,7 @@ components: - next_dagrun_create_after - owners - catchup - - dagrun_timeout + - dag_run_timeout - dataset_expression - doc_md - start_date @@ -712,12 +703,11 @@ components: - orientation - params - render_template_as_native_obj - - template_searchpath + - template_search_path - timezone - - last_loaded + - last_parsed - file_token - concurrency - - last_parsed title: DAGDetailsResponse description: Specific serializer for DAG Details responses. DAGPatchBody: diff --git a/airflow/api_fastapi/serializers/dags.py b/airflow/api_fastapi/serializers/dags.py index 7275455022f1..964e526d31d2 100644 --- a/airflow/api_fastapi/serializers/dags.py +++ b/airflow/api_fastapi/serializers/dags.py @@ -116,17 +116,13 @@ class DAGDetailsResponse(DAGResponse): timezone: str | None last_parsed: datetime | None - def _validation_alias_fn(field_name: str): - val_dict = { - "dag_run_timeout": "dagrun_timeout", - "last_parsed": "last_loaded", - "template_search_path": "template_searchpath", - } - return val_dict.get(field_name, field_name) - model_config = ConfigDict( alias_generator=AliasGenerator( - validation_alias=_validation_alias_fn, + validation_alias=lambda field_name: { + "dag_run_timeout": "dagrun_timeout", + "last_parsed": "last_loaded", + "template_search_path": "template_searchpath", + }.get(field_name, field_name), ) ) diff --git a/airflow/ui/openapi-gen/requests/schemas.gen.ts b/airflow/ui/openapi-gen/requests/schemas.gen.ts index 56f2412e879c..e8aae616be06 100644 --- a/airflow/ui/openapi-gen/requests/schemas.gen.ts +++ b/airflow/ui/openapi-gen/requests/schemas.gen.ts @@ -239,7 +239,7 @@ export const $DAGDetailsResponse = { type: "boolean", title: "Catchup", }, - dagrun_timeout: { + dag_run_timeout: { anyOf: [ { type: "string", @@ -249,7 +249,7 @@ export const $DAGDetailsResponse = { type: "null", }, ], - title: "Dagrun Timeout", + title: "Dag Run Timeout", }, dataset_expression: { anyOf: [ @@ -314,7 +314,9 @@ export const $DAGDetailsResponse = { }, params: { anyOf: [ - {}, + { + type: "object", + }, { type: "null", }, @@ -325,11 +327,8 @@ export const $DAGDetailsResponse = { type: "boolean", title: "Render Template As Native Obj", }, - template_searchpath: { + template_search_path: { anyOf: [ - { - type: "string", - }, { items: { type: "string", @@ -340,7 +339,7 @@ export const $DAGDetailsResponse = { type: "null", }, ], - title: "Template Searchpath", + title: "Template Search Path", }, timezone: { anyOf: [ @@ -353,7 +352,7 @@ export const $DAGDetailsResponse = { ], title: "Timezone", }, - last_loaded: { + last_parsed: { anyOf: [ { type: "string", @@ -363,7 +362,7 @@ export const $DAGDetailsResponse = { type: "null", }, ], - title: "Last Loaded", + title: "Last Parsed", }, file_token: { type: "string", @@ -377,20 +376,6 @@ export const $DAGDetailsResponse = { description: "Return max_active_tasks as concurrency.", readOnly: true, }, - last_parsed: { - anyOf: [ - { - type: "string", - format: "date-time", - }, - { - type: "null", - }, - ], - title: "Last Parsed", - description: "Return last_loaded as last_parsed.", - readOnly: true, - }, }, type: "object", required: [ @@ -420,7 +405,7 @@ export const $DAGDetailsResponse = { "next_dagrun_create_after", "owners", "catchup", - "dagrun_timeout", + "dag_run_timeout", "dataset_expression", "doc_md", "start_date", @@ -429,12 +414,11 @@ export const $DAGDetailsResponse = { "orientation", "params", "render_template_as_native_obj", - "template_searchpath", + "template_search_path", "timezone", - "last_loaded", + "last_parsed", "file_token", "concurrency", - "last_parsed", ], title: "DAGDetailsResponse", description: "Specific serializer for DAG Details responses.", diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index 1a5637bd067c..c37106abc8fc 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -38,7 +38,7 @@ export type DAGDetailsResponse = { next_dagrun_create_after: string | null; owners: Array; catchup: boolean; - dagrun_timeout: string | null; + dag_run_timeout: string | null; dataset_expression: { [key: string]: unknown; } | null; @@ -47,11 +47,13 @@ export type DAGDetailsResponse = { end_date: string | null; is_paused_upon_creation: boolean | null; orientation: string; - params: unknown | null; + params: { + [key: string]: unknown; + } | null; render_template_as_native_obj: boolean; - template_searchpath: string | Array | null; + template_search_path: Array | null; timezone: string | null; - last_loaded: string | null; + last_parsed: string | null; /** * Return file token. */ @@ -60,10 +62,6 @@ export type DAGDetailsResponse = { * Return max_active_tasks as concurrency. */ readonly concurrency: number; - /** - * Return last_loaded as last_parsed. - */ - readonly last_parsed: string | null; }; /**