Skip to content

Commit

Permalink
Use lambda for aliases, re-run breeze static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
omkar-foss committed Oct 2, 2024
1 parent 89b83ce commit 5250a48
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 65 deletions.
30 changes: 10 additions & 20 deletions airflow/api_fastapi/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,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
Expand Down Expand Up @@ -547,31 +547,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
Expand All @@ -582,14 +581,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
Expand Down Expand Up @@ -618,7 +609,7 @@ components:
- next_dagrun_create_after
- owners
- catchup
- dagrun_timeout
- dag_run_timeout
- dataset_expression
- doc_md
- start_date
Expand All @@ -627,12 +618,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:
Expand Down
14 changes: 5 additions & 9 deletions airflow/api_fastapi/serializers/dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
)

Expand Down
40 changes: 12 additions & 28 deletions airflow/ui/openapi-gen/requests/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export const $DAGDetailsResponse = {
type: "boolean",
title: "Catchup",
},
dagrun_timeout: {
dag_run_timeout: {
anyOf: [
{
type: "string",
Expand All @@ -249,7 +249,7 @@ export const $DAGDetailsResponse = {
type: "null",
},
],
title: "Dagrun Timeout",
title: "Dag Run Timeout",
},
dataset_expression: {
anyOf: [
Expand Down Expand Up @@ -314,7 +314,9 @@ export const $DAGDetailsResponse = {
},
params: {
anyOf: [
{},
{
type: "object",
},
{
type: "null",
},
Expand All @@ -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",
Expand All @@ -340,7 +339,7 @@ export const $DAGDetailsResponse = {
type: "null",
},
],
title: "Template Searchpath",
title: "Template Search Path",
},
timezone: {
anyOf: [
Expand All @@ -353,7 +352,7 @@ export const $DAGDetailsResponse = {
],
title: "Timezone",
},
last_loaded: {
last_parsed: {
anyOf: [
{
type: "string",
Expand All @@ -363,7 +362,7 @@ export const $DAGDetailsResponse = {
type: "null",
},
],
title: "Last Loaded",
title: "Last Parsed",
},
file_token: {
type: "string",
Expand All @@ -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: [
Expand Down Expand Up @@ -420,7 +405,7 @@ export const $DAGDetailsResponse = {
"next_dagrun_create_after",
"owners",
"catchup",
"dagrun_timeout",
"dag_run_timeout",
"dataset_expression",
"doc_md",
"start_date",
Expand All @@ -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.",
Expand Down
14 changes: 6 additions & 8 deletions airflow/ui/openapi-gen/requests/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type DAGDetailsResponse = {
next_dagrun_create_after: string | null;
owners: Array<string>;
catchup: boolean;
dagrun_timeout: string | null;
dag_run_timeout: string | null;
dataset_expression: {
[key: string]: unknown;
} | null;
Expand All @@ -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<string> | null;
template_search_path: Array<string> | null;
timezone: string | null;
last_loaded: string | null;
last_parsed: string | null;
/**
* Return file token.
*/
Expand All @@ -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;
};

/**
Expand Down

0 comments on commit 5250a48

Please sign in to comment.