[GitHub] XD-DENG commented on a change in pull request #4547: [AIRFLOW-2843] Add flag in ExternalTaskSensor to check if external DAG/task exists

2019-01-17 Thread GitBox
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_r248673451
 
 

 ##
 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:
+refreshed_dag_info = 
DagBag(dag_to_wait.fileloc).get_dag(self.external_dag_id)
 
 Review comment:
   1. Purposely leave `include_examples` for `DagBag` to be default value 
`True`, since the `external_dag_id` may be example DAG.
   
   2. The exact file path is given to `DagBag`, so that it will only scan a 
single DAG file. This helps ensure no heavy overhead.
   


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


[GitHub] XD-DENG commented on a change in pull request #4547: [AIRFLOW-2843] Add flag in ExternalTaskSensor to check if external DAG/task exists

2019-01-17 Thread GitBox
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


[GitHub] XD-DENG commented on a change in pull request #4547: [AIRFLOW-2843] Add flag in ExternalTaskSensor to check if external DAG/task exists

2019-01-17 Thread GitBox
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_r248673451
 
 

 ##
 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:
+refreshed_dag_info = 
DagBag(dag_to_wait.fileloc).get_dag(self.external_dag_id)
 
 Review comment:
   1. Purposely leave `include_examples` for `DagBag` to be default value 
`True`, as user may wait for the example DAG.
   
   2. The exact file path is given to `DagBag`, so that it will only scan a 
single 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


[GitHub] XD-DENG commented on a change in pull request #4547: [AIRFLOW-2843] Add flag in ExternalTaskSensor to check if external DAG/task exists

2019-01-17 Thread GitBox
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_r248672681
 
 

 ##
 File path: airflow/sensors/external_task_sensor.py
 ##
 @@ -26,7 +29,8 @@
 
 class ExternalTaskSensor(BaseSensorOperator):
 """
-Waits for a different DAG or a task in in a different DAG to complete
+Waits for a different DAG or a task in a different DAG to complete for a
 
 Review comment:
   Fix a typo.


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


[GitHub] XD-DENG commented on a change in pull request #4547: [AIRFLOW-2843] Add flag in ExternalTaskSensor to check if external DAG/task exists

2019-01-17 Thread GitBox
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_r248672681
 
 

 ##
 File path: airflow/sensors/external_task_sensor.py
 ##
 @@ -26,7 +29,8 @@
 
 class ExternalTaskSensor(BaseSensorOperator):
 """
-Waits for a different DAG or a task in in a different DAG to complete
+Waits for a different DAG or a task in a different DAG to complete for a
 
 Review comment:
   Fixed a typo.


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