jason810496 commented on code in PR #75387:
URL: https://github.com/apache/airflow/pull/75387#discussion_r4434758066
##########
airflow-core/src/airflow/api_fastapi/execution_api/services/task_instances.py:
##########
@@ -69,11 +69,11 @@ def get_arg_bindings(task: SerializedOperator | None) ->
list | None:
def get_execution_timeout(task: SerializedOperator | None) -> float | None:
Review Comment:
Nit: We already gate the task is not None at the router level.
```suggestion
def get_execution_timeout(task: SerializedOperator) -> float | None:
```
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -383,36 +383,33 @@ def ti_run(
if first_task_reschedule_start_date is not None:
context.first_task_reschedule_start_date =
first_task_reschedule_start_date
- # Avoid loading the serialized Dag on the normal Python task path:
only a lang-SDK
- # (foreign-runtime) task needs its definition here, and ti.is_stub
carries the row's own copy
- # of the serialized flag.
- serialized_task = get_task(dag_bag, ti, session=session) if ti.is_stub
else None
-
- # Only set for lang-SDK (foreign-runtime) tasks with a captured
TaskFlow arg
- # spec; the route excludes unset fields, keeping regular responses
lean.
- if client_supports_arg_bindings() and (arg_bindings :=
get_arg_bindings(serialized_task)):
- try:
- context.arg_bindings =
get_arg_bindings_adapter().validate_python(arg_bindings)
- except ValidationError:
- log.exception(
- "Serialized arg_bindings spec failed validation",
- dag_id=ti.dag_id,
- task_id=ti.task_id,
- dag_version_id=ti.dag_version_id,
- )
- raise HTTPException(
- status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
- detail={
- "reason": "invalid_arg_bindings",
- "message": "The serialized TaskFlow arg spec for this
stub task is not valid.",
- },
- )
+ # Only a lang-SDK (foreign-runtime) task needs its definition here: a
Python task parses its
+ # Dag file itself. ti.is_stub carries the row's own copy of the
serialized flag, so a Python
+ # task never loads the serialized Dag.
+ if ti.is_stub and (serialized_task := get_task(dag_bag, ti,
session=session)) is not None:
+ # The route excludes unset fields, keeping responses without a
captured TaskFlow arg spec lean.
+ if client_supports_arg_bindings() and (arg_bindings :=
get_arg_bindings(serialized_task)):
Review Comment:
Nit: Sightly change the order to avoid unnecessary load.
```suggestion
if client_supports_arg_bindings() and ti.is_stub and
(serialized_task := get_task(dag_bag, ti, session=session)) is not None:
# The route excludes unset fields, keeping responses without a
captured TaskFlow arg spec lean.
if (arg_bindings := get_arg_bindings(serialized_task)):
```
##########
airflow-core/src/airflow/api_fastapi/execution_api/services/task_instances.py:
##########
Review Comment:
Nit:
```suggestion
def get_arg_bindings(task: SerializedOperator) -> list | None:
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]