hussein-awala commented on code in PR #32990:
URL: https://github.com/apache/airflow/pull/32990#discussion_r1285271196
##########
airflow/models/taskinstance.py:
##########
@@ -166,6 +166,16 @@ class TaskReturnCode(Enum):
"""When task exits with deferral to trigger."""
+def get_current_context() -> Context:
+ """Retrieve the execution context dictionary without altering user
method's signature."""
+ if not _CURRENT_CONTEXT:
+ raise AirflowException(
+ "Current context was requested but no context was found! "
+ "Are you running within an airflow task?"
+ )
+ return _CURRENT_CONTEXT[-1]
Review Comment:
Currently I duplicated it, but I think we should move it to TI (or base
operator class), since it is useful in all the operators and not just in Python
operators. WDYT?
--
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]