kaxil commented on code in PR #77009:
URL: https://github.com/apache/airflow/pull/77009#discussion_r4701980753


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_tasks.py:
##########
@@ -120,6 +120,7 @@ def test_should_respond_200(self, test_client):
             "wait_for_downstream": False,
             "weight_rule": "downstream",
             "is_mapped": False,
+            "is_durable": False,

Review Comment:
   Every expectation in this file is `False`, since `create_dags` only builds 
`EmptyOperator`s, so hardcoding `is_durable=False` in `TaskResponse` would 
still pass. Could one test add a durable task, ideally a mapped one, that 
expects `True`?



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/tasks.py:
##########
@@ -81,6 +81,7 @@ class TaskResponse(BaseModel):
     params: abc.MutableMapping | None
     class_ref: dict | None
     is_mapped: bool | None
+    is_durable: bool

Review Comment:
   #76833 landed with its own 
`/ui/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/durable` route, 
which returns `{"tries": []}` instead of a 404 and only runs for try 2 and 
later, and `DurableBanner` doesn't read `is_durable`. Is there still a consumer 
for this field? Without one I'd rather not add a public API field and a 
serialized key whose value for mapped tasks is a guess (see 
`_is_durable_operator`).



##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -173,6 +177,15 @@ def __str__(self) -> str:
         )
 
 
+def _is_durable_operator(op: SdkOperator) -> bool:
+    if isinstance(op, MappedOperator):
+        # partial() leaves non-BaseOperator default_args like ``durable`` to 
unmapping, so resolve them here.
+        default_args, _ = get_merged_defaults(op.dag, op.task_group, None, 
None)
+        default = default_args.get("durable", issubclass(op.operator_class, 
ResumableJobMixin))

Review Comment:
   The class-membership guess goes wrong in more cases than the mapped KPO one 
in the description. `default_args={"durable": True}` on the Dag makes every 
mapped `BashOperator` or `@task` report durable, because `apply_defaults` only 
copies a default into a class whose signature takes `durable`, and 
`GlueJobOperator.partial(resume_glue_job_on_retry=False)` reports durable but 
runs with `durable=False` (same for Spark's `reconnect_on_retry=False`). The 
mapped Hugging Face dataset operators (`durable: bool = True`, no mixin) report 
false. Could the operator class resolve its own value from the partial kwargs 
and merged defaults, so core doesn't have to mirror each `__init__`?



##########
go-sdk/internal/genspec/authoring.go:
##########
@@ -146,6 +146,7 @@ var taskShape = authoringShape{
                "_needs_expansion":              "derived from whether the task 
is mapped",
                "_is_mapped":                    "derived from whether the task 
is mapped",
                "_is_sensor":                    "derived from the task's own 
kind",
+               "_is_durable":                   "set by Python's 
ResumableJobMixin, which a Go task has no equivalent of",

Review Comment:
   The serializer also sets this for `KubernetesPodOperator`, which has no 
`ResumableJobMixin`. Maybe "set when a Python task's `durable` is on, which a 
Go task has no equivalent of"?



-- 
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]

Reply via email to