Apache Airflow version: None
Ticket was created 17/Nov/16 21:19
Kubernetes version (if you are using kubernetes) (use kubectl version):
Environment:
- Cloud provider or hardware configuration:
- OS (e.g. from /etc/os-release):
- Kernel (e.g.
uname -a):
- Install tools:
- Others:
What happened:
Currently in models.get_template_context we have:
run_id = ''
dag_run = None
if hasattr(task, 'dag'):
if task.dag.params:
params.update(task.dag.params)
dag_run = (
session.query(DagRun)
.filter_by(
dag_id=task.dag.dag_id,
execution_date=self.execution_date)
.first()
)
run_id = dag_run.run_id if dag_run else None
session.expunge_all()
session.commit()
Since subdags do not have associated DagRuns for their dag_id, the context will not contain the dagrun or run_id associated with the subdag, even though it exists associated with the parent dag.
If we change this code to up the DagRun based on the dag_id of the parent dag, we can set these values.
What you expected to happen:
How to reproduce it:
Anything else we need to know:
Moved here from https://issues.apache.org/jira/browse/AIRFLOW-637
Apache Airflow version: None
Ticket was created 17/Nov/16 21:19
Kubernetes version (if you are using kubernetes) (use
kubectl version):Environment:
uname -a):What happened:
Currently in models.get_template_context we have:
run_id = ''
dag_run = None
if hasattr(task, 'dag'):
if task.dag.params:
params.update(task.dag.params)
dag_run = (
session.query(DagRun)
.filter_by(
dag_id=task.dag.dag_id,
execution_date=self.execution_date)
.first()
)
run_id = dag_run.run_id if dag_run else None
session.expunge_all()
session.commit()
Since subdags do not have associated DagRuns for their dag_id, the context will not contain the dagrun or run_id associated with the subdag, even though it exists associated with the parent dag.
If we change this code to up the DagRun based on the dag_id of the parent dag, we can set these values.
What you expected to happen:
How to reproduce it:
Anything else we need to know:
Moved here from https://issues.apache.org/jira/browse/AIRFLOW-637