kukigai commented on a change in pull request #11484:
URL: https://github.com/apache/airflow/pull/11484#discussion_r503582103
##########
File path: airflow/operators/dagrun_operator.py
##########
@@ -92,11 +97,39 @@ def execute(self, context: Dict):
execution_date = timezone.utcnow()
run_id = DagRun.generate_run_id(DagRunType.MANUAL, execution_date)
- # Ignore MyPy type for self.execution_date because it doesn't pick up
the timezone.parse() for strings
- trigger_dag(
- dag_id=self.trigger_dag_id,
- run_id=run_id,
- conf=self.conf,
- execution_date=self.execution_date,
- replace_microseconds=False,
- )
+ try:
+ # Ignore MyPy type for self.execution_date because it doesn't pick
up the timezone.parse() for strings
+ trigger_dag(
+ dag_id=self.trigger_dag_id,
+ run_id=run_id,
+ conf=self.conf,
+ execution_date=self.execution_date,
+ replace_microseconds=False,
+ )
+
+ except DagRunAlreadyExists as e:
+ if self.reset_dag_run:
+ self.log.info(f"Clearing {self.trigger_dag_id} on
{self.execution_date}")
+
+ # Get target dag object and call clear()
+
+ dag_model = DagModel.get_current(self.trigger_dag_id)
+ if dag_model is None:
+ raise DagNotFound("Dag id {} not found in
DagModel".format(self.trigger_dag_id))
+
+ def read_store_serialized_dags():
+ from airflow.configuration import conf
+ return conf.getboolean('core', 'store_serialized_dags')
+
+ dag_bag = DagBag(
+ dag_folder=dag_model.fileloc,
+ store_serialized_dags=read_store_serialized_dags()
+ )
Review comment:
it does the same thing as
https://github.com/apache/airflow/blob/master/airflow/api/common/experimental/trigger_dag.py#L115-L125
----------------------------------------------------------------
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]