You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/02/14 12:38:18 UTC
[GitHub] [airflow] AlejandroBaron opened a new issue #21561: Tasks after BranchOperator are getting skipped using TaskFlow API
AlejandroBaron opened a new issue #21561:
URL: https://github.com/apache/airflow/issues/21561
### Apache Airflow version
2.2.3 (latest released)
### What happened
I was trying to use branching in the newest Airflow version but no matter what I try, any task after the branch operator gets skipped
![image](https://user-images.githubusercontent.com/20068161/153865524-b6b08447-3b3a-417e-8223-55cb5159befd.png)
Might be related to https://github.com/apache/airflow/issues/10725, but none of the solutions there seemed to work.
### What you expected to happen
The task following a BranchPythonOperator to be executed
### How to reproduce
```
from airflow.decorators import dag, task
from datetime import timedelta, datetime
from airflow.operators.python import BranchPythonOperator
from airflow.utils.trigger_rule import TriggerRule
import logging
logger = logging.getLogger("airflow.task")
@dag(
schedule_interval="0 0 * * *",
start_date=datetime.today() - timedelta(days=2),
dagrun_timeout=timedelta(minutes=60),
)
def StackOverflowExample():
@task
def task_A():
logging.info("TASK A")
@task
def task_B():
logging.info("TASK B")
@task
def task_C():
logging.info("TASK C")
@task
def task_D():
logging.info("TASK D")
return {"parameter":0.5}
def _choose_task(task_parameters,**kwargs):
logging.info(task_parameters["parameter"])
if task_parameters["parameter"]<0.5:
logging.info("SUCCESSS ")
return ['branch_1', 'task_final']
else:
logging.info("RIP")
return ['branch_2', 'task_final']
@task(task_id="branch_1")
def branch_1():
logging.info("branch_1...")
@task(task_id="branch_2")
def branch_2():
logging.info("branch_2")
@task(task_id="task_final")
def task_final():
logging.info("task_final")
parameter = task_A() >> task_B() >> task_C() >> task_D()
choose_task = BranchPythonOperator(
task_id='choose_best_model',
op_kwargs={"task_parameters":parameter},
python_callable=_choose_task,
trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS
)
choose_task >> [branch_1(), branch_2()] >> task_final()
dag = StackOverflowExample ()
```
### Operating System
Ubuntu 18.04 (WSL2)
### Versions of Apache Airflow Providers
_No response_
### Deployment
Docker-Compose
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] eladkal commented on issue #21561: Tasks after BranchOperator are getting skipped using TaskFlow API
Posted by GitBox <gi...@apache.org>.
eladkal commented on issue #21561:
URL: https://github.com/apache/airflow/issues/21561#issuecomment-1039153945
This is not a bug but an issue with your pipeline. You need to override the trigger rule.
Answered in https://stackoverflow.com/a/71112836/14624409
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on issue #21561: Tasks after BranchOperator are getting skipped using TaskFlow API
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #21561:
URL: https://github.com/apache/airflow/issues/21561#issuecomment-1039038453
Thanks for opening your first issue here! Be sure to follow the issue template!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] eladkal closed issue #21561: Tasks after BranchOperator are getting skipped using TaskFlow API
Posted by GitBox <gi...@apache.org>.
eladkal closed issue #21561:
URL: https://github.com/apache/airflow/issues/21561
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org