-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AIRFLOW-2843] Add flag in ExternalTaskSensor to check if external DAG/task exists #4547
Conversation
…G/task exists In ExternalTaskSensor, it may be good to provide an option to cease waiting immediately if the external DAG/task specified doesn't exist. To provide an argument "check_existence". Set to True to check if the external DAG/task exists, and immediately cease waiting if the external DAG/task does not exist. The default value is set to False (no check or ceasing will happen) so it will not affect any existing DAGs or current user expectation.
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed a typo.
|
||
if self.external_task_id: | ||
refreshed_dag_info = DagBag(dag_to_wait.fileloc).get_dag(self.external_dag_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Purposely leave
include_examples
forDagBag
to be default valueTrue
, since theexternal_dag_id
may be example DAG. -
The exact file path is given to
DagBag
, so that it will only scan a single DAG file. This helps ensure no heavy overhead.
|
||
if self.external_task_id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Codecov Report
@@ Coverage Diff @@
## master #4547 +/- ##
==========================================
+ Coverage 74.07% 74.08% +<.01%
==========================================
Files 421 421
Lines 27649 27663 +14
==========================================
+ Hits 20481 20494 +13
- Misses 7168 7169 +1
Continue to review full report at Codecov.
|
LGTM overall for the logic, will take a closer look once in the office. |
LGTM, thanks @XD-DENG |
Thanks @feng-tao |
…G/task exists (#4547) In ExternalTaskSensor, it may be good to provide an option to cease waiting immediately if the external DAG/task specified doesn't exist. To provide an argument "check_existence". Set to True to check if the external DAG/task exists, and immediately cease waiting if the external DAG/task does not exist. The default value is set to False (no check or ceasing will happen) so it will not affect any existing DAGs or current user expectation.
…G/task exists (#4547) In ExternalTaskSensor, it may be good to provide an option to cease waiting immediately if the external DAG/task specified doesn't exist. To provide an argument "check_existence". Set to True to check if the external DAG/task exists, and immediately cease waiting if the external DAG/task does not exist. The default value is set to False (no check or ceasing will happen) so it will not affect any existing DAGs or current user expectation.
…G/task exists (apache#4547) In ExternalTaskSensor, it may be good to provide an option to cease waiting immediately if the external DAG/task specified doesn't exist. To provide an argument "check_existence". Set to True to check if the external DAG/task exists, and immediately cease waiting if the external DAG/task does not exist. The default value is set to False (no check or ceasing will happen) so it will not affect any existing DAGs or current user expectation.
Jira
Description
Background
ExternalTaskSensor
will keep waiting even if the external DAG/task specified doesn't exist at all (this is making sense in some scenarios).But it may be good to provide an option to cease waiting immediately if the external task specified doesn't exist.
Proposal
Provide a flag
check_existence
. Set toTrue
to check if the external DAG/task exists, and immediately cease waiting if the external DAG/task does not exist.The default value is set to
False
(no check or ceasing will happen), so it will not affect any existing DAGs or user expectation.This is a follow-up on #3688