question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@task_group returns int, but it appears in @task as TaskGroup

See original GitHub issue

Apache Airflow version

13faa6912f7cd927737a1dc15630d3bbaf2f5d4d

Environment

  • Configuration: Local Executor
  • OS (e.g. from /etc/os-release): Mac OS 11.3
  • Kernel: Darwin Kernel Version 20.4.0
  • Install tools: pip install -e .

The DAG

@task
def one():
    return 1

@task_group
def trivial_group(inval):

    @task
    def add_one(i):
        return i + 1

    outval = add_one(inval)
    return outval

@task
def print_it(inval):
    print(inval)

@dag(schedule_interval=None, start_date=days_ago(1), default_args={"owner": "airflow"})
def wrap():

    x = one()
    y = trivial_group(x)
    z = print_it(y)

wrap_dag = wrap()

What happened: print_it had no predecessors and receives <airflow.utils.task_group.TaskGroup object at 0x128921940>

What you expected to happen: print_it comes after trivial_group.add_one and receives 2

The caller ends up with the task group itself, equivalent in the traditional api to tg_ref in:

with TaskGroup("trivial_group") tg_ref:
    pass

This interrupts the ability to continue using the Task Flow api because passing it into a function annotated with @task fails to register the dependency with whatever magic gets it out of xcom and adds edges to the dag.

To Replicate

 $ airflow dags test wrap $(date "+%Y-%m-%d")

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ashbcommented, May 7, 2021

Yeah, not released yet. (Sorry, I checked before adding the high priority label but forgot to comment)

We’ll change this before 2.1 is cut

0reactions
MatrixManAtYrServicecommented, May 7, 2021

@ashb the @task_group decorator was merged here: https://github.com/apache/airflow/pull/15034 (Apr 1).

I think that means that it’s not in any released packages. DAG’s using it would have opted in to the bleeding edge by cloning master instead of waiting for a release. Seems reasonable to fix it directly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why `TaskGroup.addTask(priority:operation:)` doesn't return ...
It seems to me that the method intentionally doesn't return the added task but I'm not sure what's the motivation for this? It...
Read more >
How to create a task group and add tasks to it
Swift's task groups are collections of tasks that work together to produce a single result. Each task inside the group must return the...
Read more >
next() | Apple Developer Documentation
If there aren't any pending tasks in the task group, this method returns nil , which lets you write the following to wait...
Read more >
Use TaskGroup and PythonBranchOperator in the same DAG
BranchPythonOperator is expected to return task_ids. You need to change the get_tasks function to: def get_tasks(**kwargs): task ...
Read more >
Dynamic Tasks inside of TaskGroup do not have group_id ...
The tasks below are named plus_one and plus_two : ... 2, 3]) with TaskGroup(group_id='ggg'): @task def plus_two(x: int): return x + 2 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found