ashb commented on code in PR #59876:
URL: https://github.com/apache/airflow/pull/59876#discussion_r2667966072
##########
airflow-core/src/airflow/models/base.py:
##########
@@ -98,3 +99,14 @@ class TaskInstanceDependencies(Base):
dag_id: Mapped[str] = mapped_column(StringID(), nullable=False)
run_id: Mapped[str] = mapped_column(StringID(), nullable=False)
map_index: Mapped[int] = mapped_column(Integer, nullable=False,
server_default=text("-1"))
+
+
+def has_execution_context() -> bool:
+ """Check if we are in an execution context (Task, Dag Parse or Triggerer
perhaps)."""
+ # TODO: This is not the best way of having compat, but it's "better than
erroring" for now. This still
+ # means SQLA etc is loaded, but we can't avoid that unless/until we add
import shims as a big
+ # back-compat layer
+
+ # If this is set it means are in some kind of execution context (Task, Dag
Parse or Triggerer perhaps)
+ # and should use the Task SDK API server path
+ return hasattr(sys.modules.get("airflow.sdk.execution_time.task_runner"),
"_SupervisorCommsHolder.comms")
Review Comment:
Yeah. And this means our unit tests do not exercise this path correctly.
```
In [1]: import airflow.sdk.execution_time.task_runner
2026-01-07T10:53:37.236044Z [warning ] Skipping masking for a secret as
it's too short (<5 chars) [airflow._shared.secrets_masker.secrets_masker]
loc=secrets_masker.py:551
2026-01-07T10:53:37.236167Z [warning ] Skipping masking for a secret as
it's too short (<5 chars) [airflow.sdk._shared.secrets_masker.secrets_masker]
loc=secrets_masker.py:551
In [2]: import sys
In [3]: airflow.sdk.execution_time.task_runner._SupervisorCommsHolder.comms
= 1
In [4]: hasattr(sys.modules.get("airflow.sdk.execution_time.task_runner"),
"_SupervisorCommsHolder.comms")
Out[4]: False
```
--
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]