You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/10/12 23:05:11 UTC
[GitHub] [airflow] turbaszek commented on a change in pull request #11484: Add reset_dag_run option on dagrun_operator to clear existing dag run
turbaszek commented on a change in pull request #11484:
URL: https://github.com/apache/airflow/pull/11484#discussion_r503577112
##########
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}")
Review comment:
```suggestion
self.log.info("Clearing %s on %s", self.trigger_dag_id, self.execution_date)
```
----------------------------------------------------------------
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:
users@infra.apache.org