MappedTaskGroup without taskflow #50297
Unanswered
raphaelauv
asked this question in
General
Replies: 1 comment 2 replies
-
From documentation it's not recommended to use If you want to avoid decorator syntax in DAG definition, it may be better to wire task inputs/outputs just at task level instead of using a mapped task group. What about giving this adjustment a try? Looks a bit redundant but I think it is logically equivalent to the original one. ...
from airflow.utils.task_group import TaskGroup
...
with DAG(
dag_id="dag_group_DTM",
start_date=today("UTC").add(days=-1),
schedule=timedelta(days=1),
):
first = PythonOperator(
task_id="first",
python_callable=lambda : [1, 10, 20, 30]
)
def sleep(duration):
# It's recommended to place module imports in the task function (subroutine),
# so that all required imports only happens when the task gets run.
import time
time.sleep(duration)
with TaskGroup(group_id="group_1"):
a = PythonOperator.partial(task_id="a", python_callable=sleep).expand(duration=duration.output)
b = PythonOperator.partial(task_id="b", python_callable=sleep).expand(duration=duration.output)
c = PythonOperator.partial(task_id="a", python_callable=sleep).expand(duration=duration.output)
a >> b >> c |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi I'm trying to use dynamic task mapping on a taskgroup without the taskflow syntax
this is working ->
but I would like to not mix traditional syntax with taskflow syntax, and I did not yet found a way using
do you have any idea if it's possible ? thanks all
Beta Was this translation helpful? Give feedback.
All reactions