-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
BranchPythonOperator skipping following tasks #10725
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! |
Thanks for bringing this up. Definitely looks related to #7276. Let me clarify the problem first. @CatarinaSilva 's example looks like this. The expected end state should be both I'm sorry that I did not anticipate empty branch cases when working on #7276. That said, if we actually look at the docstr of
In this case, both I understand this sounds counter-intuitive. The problem is To remove this ambiguity, may I suggest changing the
i.e. always include "final_task" in the return because the intention is to always run "final_task" no matter what the branching outcome is. The DAG will then look like this and the behaviour will be as expected: If this solution is not satisfactory, please let me know and I'll think about something better. |
Just want to bring this up because we also encountered this. If what mentioned above is eventually finalized, the example in the doc here: https://airflow.apache.org/docs/stable/concepts.html?highlight=branch#trigger-rules should be updated accordingly to avoid confusion. |
Okay, I thought I'm alone, but then saw #10686 and now this, I start to think that its a regression. |
@yuqian90 Looks like more people rely on this feature, would you be able to make a PR that restores this behavior to allow empty branch please |
@kaxil will do |
Thanks @yuqian90 , however the logic you proposed:
seems good to me, for some reason I didn't think I could have the same task in both sides of the branch 😅 I will use that until the behavior is restored and maybe even after honestly. What version will your PR be included in? |
Hi, @CatarinaSilva , yes the workaround will work
Hi, @CatarinaSilva the workaround should continue to work after the fix is merged. So you can start using it right now and after too. @kaxil I'm hoping the fix #10751 can be merged in the next release of 1.10.* although the PR is for master. |
Thanks for the quick workaround @yuqian90 , I will look at the PR and merge it soon |
Regarding of what @yuqian90 said, the question is should we fix the documentation to match the behavior (and the example) or should we fix the behavior and the examples to match the documentation. TBH the previous behavior seems more logical, where task are only skipped if there is no task running or to be run that points to it. |
closes: #10725 Make sure SkipMixin.skip_all_except() handles empty branches like this properly. When "task1" is followed, "join" must not be skipped even though it is considered to be immediately downstream of "branch".
Thanks, @yuqian90 -- If it is not much work can you create a backport PR for this targeting v1-10-test? |
Will do. |
BranchPythonOperator skips child tasks if they are not returned by python_callable. The ambiguity only happens when there are empty branches. Either way won't be perfect. This PR aims to keep the behaviour the same as before 1.10.12. |
Apache Airflow version:
1.10.12
What happened:
Seems that from 1.10.12 the behavior from BranchPythonOperator was reversed. A task after all branches would be excluded from the skipped tasks before but now it is skipped. This prevents empty branches.
What you expected to happen:
Tasks after all branches should respect the trigger_rule and not be automatically skipped by the branch operator
How to reproduce it:
Run following code in a dag:
Temporary workaround:
Add dummy operators to any branch with no tasks
The text was updated successfully, but these errors were encountered: