-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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-4453] Make behavior of none_failed
consistent with documentation
#7464
Conversation
@TV4Fun as discussed, this is the new PR. Please close the old one. Thank you! |
f5fadcd
to
754ce48
Compare
airflow/operators/python.py
Outdated
with create_session() as session: | ||
branch_ti = session.query(TaskInstance).filter( | ||
TaskInstance.dag_id == ti.dag_id, | ||
TaskInstance.task_id == branch_operator.task_id, | ||
TaskInstance.execution_date == ti.execution_date | ||
).one_or_none() | ||
|
||
if not branch_ti: | ||
return | ||
|
||
if branch_ti.state == State.SKIPPED: | ||
raise AirflowSkipException(f"Skipping because parent task {branch_operator.task_id} " | ||
"is skipped.") |
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.
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.
Thanks @kaxil. This is raising AirflowSkipException
to cause the join task itself to be skipped. Please let me know if there are better ways to do this.
For other reviewers who haven't seen the previous discussion on the ancestor PR. What this create_branch_join
does here is to make a join task like join_2
in the following DAG. It makes sure the workflow can still work as we intuitively expect after the behaviour or none_failed
is fixed by this PR. Logically, join_2
should be skipped because its parent BranchPythonOperator
branch_2
has been skipped. Without create_branch_join
, the none_failed
task would actually become success
.
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.
Hi, @kaxil I've done the renaming you suggested to create_branch_join_task()
.
Any suggestion about how to make join_2
skipped other than raising AirflowSkipException
?
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.
What do you think of having 2 trigger rules?
- Fixed "none_failed"
- none_failed_or_skipped
(2) can be used to get current "non_failed" like feature, isn't it?
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.
WDYT?
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.
Hi @kaxil sorry for the late reply. Yes I think your suggestion sounds good. I'll think a bit more and work on fixing none_failed, and adding none_failed_or_skipped.
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.
@kaxil I have done the following. Could you take a second look? There are some elastic search related tests failing in Travis. Does not look related to my change.
- Fixed "none_failed"
- none_failed_or_skipped
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.
Sure I will take a look today, can you rebase on the latest master please to fix the Elasticsearch issue
Any progress here? |
754ce48
to
4d27e42
Compare
e028a29
to
4284078
Compare
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.
Lot better, I like this change
Can you rebase to latest master to fix the CI |
4284078
to
50aa121
Compare
…tation The documentation for the `none_failed` trigger rule (https://airflow.apache.org/docs/stable/concepts.html#trigger-rules) describes its behavior as "all parents have not failed (`failed` or `upstream_failed`) i.e. all parents have succeeded or been skipped." With that definition in mind, there is no reason that the check for `none_failed` should ever have to check for skipped upstream tasks or set the current task to `skipped`. The current behavior causes the rule to skip if all upstream tasks have skipped, which is more than a little confusing. This fixes the behavior to be consistent with the documentation.
50aa121
to
74f565d
Compare
Codecov Report
@@ Coverage Diff @@
## master #7464 +/- ##
===========================================
+ Coverage 65.44% 86.88% +21.44%
===========================================
Files 927 928 +1
Lines 44963 44988 +25
===========================================
+ Hits 29425 39087 +9662
+ Misses 15538 5901 -9637
Continue to review full report at Codecov.
|
…tation (#7464) The documentation for the `none_failed` trigger rule (https://airflow.apache.org/docs/stable/concepts.html#trigger-rules) describes its behavior as "all parents have not failed (`failed` or `upstream_failed`) i.e. all parents have succeeded or been skipped." With that definition in mind, there is no reason that the check for `none_failed` should ever have to check for skipped upstream tasks or set the current task to `skipped`. The current behavior causes the rule to skip if all upstream tasks have skipped, which is more than a little confusing. This fixes the behavior to be consistent with the documentation. Co-authored-by: root <[email protected]> (cherry picked from commit f0c65e3)
…tation (#7464) The documentation for the `none_failed` trigger rule (https://airflow.apache.org/docs/stable/concepts.html#trigger-rules) describes its behavior as "all parents have not failed (`failed` or `upstream_failed`) i.e. all parents have succeeded or been skipped." With that definition in mind, there is no reason that the check for `none_failed` should ever have to check for skipped upstream tasks or set the current task to `skipped`. The current behavior causes the rule to skip if all upstream tasks have skipped, which is more than a little confusing. This fixes the behavior to be consistent with the documentation. Co-authored-by: root <[email protected]> (cherry picked from commit f0c65e3)
…tation (apache#7464) The documentation for the `none_failed` trigger rule (https://airflow.apache.org/docs/stable/concepts.html#trigger-rules) describes its behavior as "all parents have not failed (`failed` or `upstream_failed`) i.e. all parents have succeeded or been skipped." With that definition in mind, there is no reason that the check for `none_failed` should ever have to check for skipped upstream tasks or set the current task to `skipped`. The current behavior causes the rule to skip if all upstream tasks have skipped, which is more than a little confusing. This fixes the behavior to be consistent with the documentation. Co-authored-by: root <[email protected]> (cherry picked from commit f0c65e3)
…tation (#7464) The documentation for the `none_failed` trigger rule (https://airflow.apache.org/docs/stable/concepts.html#trigger-rules) describes its behavior as "all parents have not failed (`failed` or `upstream_failed`) i.e. all parents have succeeded or been skipped." With that definition in mind, there is no reason that the check for `none_failed` should ever have to check for skipped upstream tasks or set the current task to `skipped`. The current behavior causes the rule to skip if all upstream tasks have skipped, which is more than a little confusing. This fixes the behavior to be consistent with the documentation. Co-authored-by: root <[email protected]> (cherry picked from commit f0c65e3)
…tation (apache#7464) The documentation for the `none_failed` trigger rule (https://airflow.apache.org/docs/stable/concepts.html#trigger-rules) describes its behavior as "all parents have not failed (`failed` or `upstream_failed`) i.e. all parents have succeeded or been skipped." With that definition in mind, there is no reason that the check for `none_failed` should ever have to check for skipped upstream tasks or set the current task to `skipped`. The current behavior causes the rule to skip if all upstream tasks have skipped, which is more than a little confusing. This fixes the behavior to be consistent with the documentation. Co-authored-by: root <[email protected]>
…tation (apache#7464) (#235) * [AIRFLOW-4453] Make behavior of `none_failed` consistent with documentation (apache#7464) The documentation for the `none_failed` trigger rule (https://airflow.apache.org/docs/stable/concepts.html#trigger-rules) describes its behavior as "all parents have not failed (`failed` or `upstream_failed`) i.e. all parents have succeeded or been skipped." With that definition in mind, there is no reason that the check for `none_failed` should ever have to check for skipped upstream tasks or set the current task to `skipped`. The current behavior causes the rule to skip if all upstream tasks have skipped, which is more than a little confusing. This fixes the behavior to be consistent with the documentation. Co-authored-by: root <[email protected]> * Fix tests Co-authored-by: yuqian90 <[email protected]> Co-authored-by: root <[email protected]>
This is to pick up the work started in #7098. I discussed with @TV4Fun and opened this new PR to continue the work.
none_failed
consistent with documentation. Do not skip itself when all parents are skipped.none_failed_or_skipped
which behaves like the oldnone_failed
trigger rule (i.e. all parents are success or skipped and at least one parent is success). One use case ofnone_failed_or_skipped
is the join task in a workflow with nestedBranchPythonOperator
Issue link: AIRFLOW-4453
Make sure to mark the boxes below before creating PR: [x]
[AIRFLOW-NNNN]
. AIRFLOW-NNNN = JIRA ID** For document-only changes commit message can start with
[AIRFLOW-XXXX]
.In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.