Skip to content
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

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

Closed
MatrixManAtYrService opened this issue May 6, 2021 · 5 comments · Fixed by #15779
Closed

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

MatrixManAtYrService opened this issue May 6, 2021 · 5 comments · Fixed by #15779
Labels
kind:bug This is a clearly a bug priority:high High priority bug that should be patched quickly but does not require immediate new release
Milestone

Comments

@MatrixManAtYrService
Copy link
Contributor

MatrixManAtYrService commented May 6, 2021

Apache Airflow version

13faa69

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")
@MatrixManAtYrService MatrixManAtYrService added the kind:bug This is a clearly a bug label May 6, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented May 6, 2021

Thanks for opening your first issue here! Be sure to follow the issue template!

@MatrixManAtYrService
Copy link
Contributor Author

FYI @ashb, @dimberman

@ashb
Copy link
Member

ashb commented May 7, 2021

Hmmm I wonder if we can do this without breaking existing DAGs? (It's possible someone is using the fact that the decorated fn returns the TG object?

(Or have we not released this yet and can change it. It's to early and I can't remember.)

@ashb ashb added this to the Airflow 2.1 milestone May 7, 2021
@ashb ashb added the priority:high High priority bug that should be patched quickly but does not require immediate new release label May 7, 2021
@MatrixManAtYrService
Copy link
Contributor Author

MatrixManAtYrService commented May 7, 2021

@ashb the @task_group decorator was merged here: #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.

@ashb
Copy link
Member

ashb commented 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug This is a clearly a bug priority:high High priority bug that should be patched quickly but does not require immediate new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants