kaxil commented on code in PR #75751:
URL: https://github.com/apache/airflow/pull/75751#discussion_r4696645219
##########
task-sdk/tests/task_sdk/execution_time/test_task_runner.py:
##########
@@ -7500,6 +7542,35 @@ def side_effect(msg):
SetAssetStateStoreByName(name="resolved_asset", key="watermark",
value="2026-05-01")
)
+ def test_asset_state_store_alias_resolved_before_execute(self,
create_runtime_ti, mock_supervisor_comms):
+ alias = AssetAlias(name="my_alias")
+ resolved = Asset(name="resolved_asset", uri="s3://bucket/resolved")
+ captured = {}
+
+ def sent_messages():
Review Comment:
`sent_messages` reads like an attribute. `get_sent_messages`, to match
`get_asset_by_name_calls` in `test_mappedoperator.py`?
##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -1707,15 +1774,27 @@ def context_update_for_unmapped(context: Context, task:
BaseOperator) -> None:
contains information about the mapped task. We need to do some in-place
updates to ensure the template context reflects the unmapped task instead.
+ This includes the asset accessors, since the operator's ``__init__`` (which
+ only runs on unmapping) may add inlets and outlets. Creating them makes no
+ supervisor calls; they are built later.
+
:meta private:
"""
from airflow.sdk.definitions.param import process_params
- context["task"] = context["ti"].task = task
+ context["task"] = (ti := context["ti"]).task = task
context["params"] = process_params(
context["dag"], task, context["dag_run"].conf, suppress_exception=False
)
+ context["inlets"] = task.inlets
+ context["outlets"] = task.outlets
+ context["inlet_events"] = InletEventsAccessors(task.inlets)
+ if (asset_state_store := create_asset_state_store(ti)) is None:
+ context.pop("asset_state_store", None)
Review Comment:
No test reaches this `pop`; replacing it with `pass` leaves the suite green.
The new mapped tests either start with no assets or keep the `partial()` ones.
A case with `partial(inlets=[Asset("a")])` and an `__init__` that clears
`self.inlets` would cover it, since that's the path where the accessor built
from the `MappedOperator` would otherwise stay in the context.
##########
task-sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -1520,6 +1514,12 @@ def _prepare(ti: RuntimeTaskInstance, log: Logger,
context: Context) -> ToSuperv
jinja_env = ti.task.dag.get_template_env()
ti.render_templates(context=context, jinja_env=jinja_env)
+ # Build the asset lookups now. This makes sync supervisor calls, which may
+ # deadlock if they are first made from async task code instead.
+ context["inlet_events"].build_lookups()
Review Comment:
Nothing pins this call. I swapped it for `pass` and the asset and mapped
tests still pass, because the new tests call `build_lookups()` directly or use
concrete `Asset` inlets. Could you add a case that goes through `run()` with
`inlets=[Asset.ref(name="a")]` and checks `GetAssetByName` was sent before
`execute()`, like `test_asset_state_store_alias_resolved_before_execute` does
for aliases?
--
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]