milton0825 commented on a change in pull request #5498: [AIRFLOW-4509]
SubDagOperator using scheduler instead of backfill
URL: https://github.com/apache/airflow/pull/5498#discussion_r305694624
##########
File path: airflow/operators/subdag_operator.py
##########
@@ -89,14 +88,71 @@ def __init__(
)
)
- self.subdag = subdag
- # Airflow pool is not honored by SubDagOperator.
- # Hence resources could be consumed by SubdagOperators
- # Use other executor with your own risk.
- self.executor = executor
-
- def execute(self, context):
- ed = context['execution_date']
- self.subdag.run(
- start_date=ed, end_date=ed, donot_pickle=True,
- executor=self.executor)
+ def _get_dagrun(self, execution_date):
+ dag_runs = DagRun.find(
+ dag_id=self.subdag.dag_id,
+ execution_date=execution_date,
+ )
+ return dag_runs[0] if dag_runs else None
+
+ @provide_session
+ def _reset_dag_run_and_task_instances(self, dag_run, execution_date,
session=None):
Review comment:
Yeah this is better as it wraps the `try ... finally rollback` logic in the
context manager.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services