jscheffl commented on code in PR #59876:
URL: https://github.com/apache/airflow/pull/59876#discussion_r2679448497


##########
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:
   Very good catch! Thenaks! Have reworked the logic now.



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