ashb commented on a change in pull request #17719:
URL: https://github.com/apache/airflow/pull/17719#discussion_r692765812
##########
File path: airflow/models/taskinstance.py
##########
@@ -1723,30 +1736,22 @@ def is_eligible_to_retry(self):
return self.task.retries and self.try_number <= self.max_tries
- @provide_session
- def get_template_context(self, session=None) -> Context:
+ def get_template_context(self, session: Session = None) -> Context:
"""Return TI Context"""
+ # Do not use provide_session here -- it expunges everything on exit!
+ if not session:
+ session = settings.Session()
task = self.task
from airflow import macros
integrate_macros_plugins()
- dag_run = self.get_dagrun()
-
- # FIXME: Many tests don't create a DagRun. We should fix the tests.
- if dag_run is None:
- FakeDagRun = namedtuple(
- "FakeDagRun",
- # A minimal set of attributes to keep things working.
- "conf data_interval_start data_interval_end external_trigger
run_id",
- )
- dag_run = FakeDagRun(
- conf=None,
- data_interval_start=None,
- data_interval_end=None,
- external_trigger=False,
- run_id="",
- )
+ params = {} # type: Dict[str, Any]
+ # Ensure that the dag_run is loaded -- otherwise `self.execution_date`
may not work
+ dag_run = self.get_dagrun(session)
+ if hasattr(task, 'dag'):
+ if task.dag.params:
+ params.update(task.dag.params)
params = {} # type: Dict[str, Any]
Review comment:
Yes, _very_.
--
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]