This is an automated email from the ASF dual-hosted git repository.
jasonliu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 610b5c0458a Alias task_display_name for XComModel (#54879)
610b5c0458a is described below
commit 610b5c0458a835d0e9db0aac4aab8e0caf625002
Author: Guan Ming(Wesley) Chiu <[email protected]>
AuthorDate: Mon Aug 25 15:23:31 2025 +0800
Alias task_display_name for XComModel (#54879)
---
.../airflow/api_fastapi/core_api/datamodels/xcom.py | 1 +
.../core_api/openapi/v2-rest-api-generated.yaml | 12 ++++++++++++
airflow-core/src/airflow/models/xcom.py | 6 ++++++
.../src/airflow/ui/openapi-gen/requests/schemas.gen.ts | 18 +++++++++++++++---
.../src/airflow/ui/openapi-gen/requests/types.gen.ts | 3 +++
.../api_fastapi/core_api/routes/public/test_xcom.py | 13 +++++++++++++
airflow-ctl/src/airflowctl/api/datamodels/generated.py | 3 +++
7 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/xcom.py
b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/xcom.py
index ec65436955b..0f22cd72262 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/xcom.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/xcom.py
@@ -35,6 +35,7 @@ class XComResponse(BaseModel):
dag_id: str
run_id: str
dag_display_name: str = Field(validation_alias=AliasPath("dag_run",
"dag_model", "dag_display_name"))
+ task_display_name: str = Field(validation_alias=AliasPath("task",
"task_display_name"))
class XComResponseNative(XComResponse):
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
b/airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
index 9b6600f2412..8c5a758eebf 100644
---
a/airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
+++
b/airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
@@ -12579,6 +12579,9 @@ components:
dag_display_name:
type: string
title: Dag Display Name
+ task_display_name:
+ type: string
+ title: Task Display Name
type: object
required:
- key
@@ -12589,6 +12592,7 @@ components:
- dag_id
- run_id
- dag_display_name
+ - task_display_name
title: XComResponse
description: Serializer for a xcom item.
XComResponseNative:
@@ -12621,6 +12625,9 @@ components:
dag_display_name:
type: string
title: Dag Display Name
+ task_display_name:
+ type: string
+ title: Task Display Name
value:
title: Value
type: object
@@ -12633,6 +12640,7 @@ components:
- dag_id
- run_id
- dag_display_name
+ - task_display_name
- value
title: XComResponseNative
description: XCom response serializer with native return type.
@@ -12666,6 +12674,9 @@ components:
dag_display_name:
type: string
title: Dag Display Name
+ task_display_name:
+ type: string
+ title: Task Display Name
value:
anyOf:
- type: string
@@ -12681,6 +12692,7 @@ components:
- dag_id
- run_id
- dag_display_name
+ - task_display_name
- value
title: XComResponseString
description: XCom response serializer with string return type.
diff --git a/airflow-core/src/airflow/models/xcom.py
b/airflow-core/src/airflow/models/xcom.py
index a7301578ed2..e9fc2ac2bfc 100644
--- a/airflow-core/src/airflow/models/xcom.py
+++ b/airflow-core/src/airflow/models/xcom.py
@@ -104,6 +104,12 @@ class XComModel(TaskInstanceDependencies):
)
logical_date = association_proxy("dag_run", "logical_date")
+ task = relationship(
+ "TaskInstance",
+ viewonly=True,
+ lazy="selectin",
+ )
+
@classmethod
@provide_session
def clear(
diff --git a/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
b/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
index 6e44b2acad6..4b626ea4999 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
@@ -6348,10 +6348,14 @@ export const $XComResponse = {
dag_display_name: {
type: 'string',
title: 'Dag Display Name'
+ },
+ task_display_name: {
+ type: 'string',
+ title: 'Task Display Name'
}
},
type: 'object',
- required: ['key', 'timestamp', 'logical_date', 'map_index', 'task_id',
'dag_id', 'run_id', 'dag_display_name'],
+ required: ['key', 'timestamp', 'logical_date', 'map_index', 'task_id',
'dag_id', 'run_id', 'dag_display_name', 'task_display_name'],
title: 'XComResponse',
description: 'Serializer for a xcom item.'
} as const;
@@ -6399,12 +6403,16 @@ export const $XComResponseNative = {
type: 'string',
title: 'Dag Display Name'
},
+ task_display_name: {
+ type: 'string',
+ title: 'Task Display Name'
+ },
value: {
title: 'Value'
}
},
type: 'object',
- required: ['key', 'timestamp', 'logical_date', 'map_index', 'task_id',
'dag_id', 'run_id', 'dag_display_name', 'value'],
+ required: ['key', 'timestamp', 'logical_date', 'map_index', 'task_id',
'dag_id', 'run_id', 'dag_display_name', 'task_display_name', 'value'],
title: 'XComResponseNative',
description: 'XCom response serializer with native return type.'
} as const;
@@ -6452,6 +6460,10 @@ export const $XComResponseString = {
type: 'string',
title: 'Dag Display Name'
},
+ task_display_name: {
+ type: 'string',
+ title: 'Task Display Name'
+ },
value: {
anyOf: [
{
@@ -6465,7 +6477,7 @@ export const $XComResponseString = {
}
},
type: 'object',
- required: ['key', 'timestamp', 'logical_date', 'map_index', 'task_id',
'dag_id', 'run_id', 'dag_display_name', 'value'],
+ required: ['key', 'timestamp', 'logical_date', 'map_index', 'task_id',
'dag_id', 'run_id', 'dag_display_name', 'task_display_name', 'value'],
title: 'XComResponseString',
description: 'XCom response serializer with string return type.'
} as const;
diff --git a/airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts
b/airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts
index aad9efc4019..159351d6c61 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts
@@ -1571,6 +1571,7 @@ export type XComResponse = {
dag_id: string;
run_id: string;
dag_display_name: string;
+ task_display_name: string;
};
/**
@@ -1585,6 +1586,7 @@ export type XComResponseNative = {
dag_id: string;
run_id: string;
dag_display_name: string;
+ task_display_name: string;
value: unknown;
};
@@ -1600,6 +1602,7 @@ export type XComResponseString = {
dag_id: string;
run_id: string;
dag_display_name: string;
+ task_display_name: string;
value: string | null;
};
diff --git
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_xcom.py
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_xcom.py
index 5df0ae6a61b..e4817ec7ea7 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_xcom.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_xcom.py
@@ -50,11 +50,13 @@ TEST_XCOM_KEY_2 = "test_xcom_key_non_existing"
TEST_DAG_ID = "test-dag-id"
TEST_DAG_DISPLAY_NAME = "test-dag-id"
TEST_TASK_ID = "test-task-id"
+TEST_TASK_DISPLAY_NAME = "test-task-id"
TEST_EXECUTION_DATE = "2005-04-02T00:00:00+00:00"
TEST_DAG_ID_2 = "test-dag-id-2"
TEST_DAG_DISPLAY_NAME_2 = "test-dag-id-2"
TEST_TASK_ID_2 = "test-task-id-2"
+TEST_TASK_DISPLAY_NAME_2 = "test-task-id-2"
logical_date_parsed = timezone.parse(TEST_EXECUTION_DATE)
logical_date_formatted = logical_date_parsed.strftime("%Y-%m-%dT%H:%M:%SZ")
@@ -133,6 +135,7 @@ class TestGetXComEntry(TestXComEndpoint):
"run_id": run_id,
"key": TEST_XCOM_KEY,
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"map_index": -1,
"timestamp": current_data["timestamp"],
"value": json.dumps(TEST_XCOM_VALUE),
@@ -216,6 +219,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": f"{TEST_XCOM_KEY}-0",
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"timestamp": "TIMESTAMP",
"map_index": -1,
},
@@ -226,6 +230,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": f"{TEST_XCOM_KEY}-1",
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"timestamp": "TIMESTAMP",
"map_index": -1,
},
@@ -253,6 +258,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": f"{TEST_XCOM_KEY}-0",
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"timestamp": "TIMESTAMP",
"map_index": -1,
},
@@ -263,6 +269,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": f"{TEST_XCOM_KEY}-1",
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"timestamp": "TIMESTAMP",
"map_index": -1,
},
@@ -273,6 +280,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": f"{TEST_XCOM_KEY}-0",
"task_id": TEST_TASK_ID_2,
+ "task_display_name": TEST_TASK_DISPLAY_NAME_2,
"timestamp": "TIMESTAMP",
"map_index": -1,
},
@@ -283,6 +291,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": f"{TEST_XCOM_KEY}-1",
"task_id": TEST_TASK_ID_2,
+ "task_display_name": TEST_TASK_DISPLAY_NAME_2,
"timestamp": "TIMESTAMP",
"map_index": -1,
},
@@ -311,6 +320,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": TEST_XCOM_KEY,
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"timestamp": "TIMESTAMP",
"map_index": idx,
}
@@ -325,6 +335,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": TEST_XCOM_KEY,
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"timestamp": "TIMESTAMP",
"map_index": map_index,
}
@@ -349,6 +360,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": TEST_XCOM_KEY,
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"timestamp": "TIMESTAMP",
"map_index": 0,
},
@@ -359,6 +371,7 @@ class TestGetXComEntries(TestXComEndpoint):
"run_id": run_id,
"key": TEST_XCOM_KEY,
"task_id": TEST_TASK_ID,
+ "task_display_name": TEST_TASK_DISPLAY_NAME,
"timestamp": "TIMESTAMP",
"map_index": 1,
},
diff --git a/airflow-ctl/src/airflowctl/api/datamodels/generated.py
b/airflow-ctl/src/airflowctl/api/datamodels/generated.py
index 8666613f105..b564755e551 100644
--- a/airflow-ctl/src/airflowctl/api/datamodels/generated.py
+++ b/airflow-ctl/src/airflowctl/api/datamodels/generated.py
@@ -955,6 +955,7 @@ class XComResponse(BaseModel):
dag_id: Annotated[str, Field(title="Dag Id")]
run_id: Annotated[str, Field(title="Run Id")]
dag_display_name: Annotated[str, Field(title="Dag Display Name")]
+ task_display_name: Annotated[str, Field(title="Task Display Name")]
class XComResponseNative(BaseModel):
@@ -970,6 +971,7 @@ class XComResponseNative(BaseModel):
dag_id: Annotated[str, Field(title="Dag Id")]
run_id: Annotated[str, Field(title="Run Id")]
dag_display_name: Annotated[str, Field(title="Dag Display Name")]
+ task_display_name: Annotated[str, Field(title="Task Display Name")]
value: Annotated[Any, Field(title="Value")]
@@ -986,6 +988,7 @@ class XComResponseString(BaseModel):
dag_id: Annotated[str, Field(title="Dag Id")]
run_id: Annotated[str, Field(title="Run Id")]
dag_display_name: Annotated[str, Field(title="Dag Display Name")]
+ task_display_name: Annotated[str, Field(title="Task Display Name")]
value: Annotated[str | None, Field(title="Value")] = None