XD-DENG commented on a change in pull request #4547: [AIRFLOW-2843] Add flag in ExternalTaskSensor to check if external DAG/task exists URL: https://github.com/apache/airflow/pull/4547#discussion_r248673851
########## File path: airflow/sensors/external_task_sensor.py ########## @@ -103,17 +114,37 @@ def poke(self, context, session=None): '{self.external_task_id} on ' '{} ... '.format(serialized_dttm_filter, **locals())) - if self.external_task_id: - TI = TaskInstance + DM = DagModel + TI = TaskInstance + DR = DagRun + if self.check_existence: + dag_to_wait = session.query(DM).filter( + DM.dag_id == self.external_dag_id + ).first() + + if not dag_to_wait: + raise AirflowException('The external DAG ' + '{} does not exist.'.format(self.external_dag_id)) + else: + if not os.path.exists(dag_to_wait.fileloc): + raise AirflowException('The external DAG ' + '{} was deleted.'.format(self.external_dag_id)) + if self.external_task_id: Review comment: If `ExternalTaskSensor` is waiting for a DAG, we will check database `dag` table + file system. If it's waiting for a task, ADDITIONAL check will be done to check if that task exists in the latest DAG file. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services