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

airflow dags show Exception: "The node ... should be TaskGroup and is not" #23315

Closed
1 of 2 tasks
MatrixManAtYrService opened this issue Apr 28, 2022 · 3 comments · Fixed by #23339
Closed
1 of 2 tasks
Assignees
Labels
area:core kind:bug This is a clearly a bug

Comments

@MatrixManAtYrService
Copy link
Contributor

MatrixManAtYrService commented Apr 28, 2022

Apache Airflow version

main (development)

What happened

This happens for any dag with a task expansion. For instance:

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator

with DAG(
    dag_id="simple_mapped",
    start_date=datetime(1970, 1, 1),
    schedule_interval=None,
) as dag:

    BashOperator.partial(task_id="hello_world").expand(
        bash_command=["echo hello", "echo world"]
    )

I ran airflow dags show simple_mapped and instead of graphviz DOT notation, I saw this:

{dagbag.py:507} INFO - Filling up the DagBag from /Users/matt/2022/04/27/dags
Traceback (most recent call last):
  File .../bin/airflow", line 8, in <module>
    sys.exit(main())
  File ... lib/python3.9/site-packages/airflow/__main__.py", line 38, in main
    args.func(args)
  File ... lib/python3.9/site-packages/airflow/cli/cli_parser.py", line 51, in command
    return func(*args, **kwargs)
  File ... lib/python3.9/site-packages/airflow/cli/commands/dag_command.py", line 205, in dag_show
    dot = render_dag(dag)
  File ... lib/python3.9/site-packages/airflow/utils/dot_renderer.py", line 188, in render_dag
    _draw_nodes(dag.task_group, dot, states_by_task_id)
  File ... lib/python3.9/site-packages/airflow/utils/dot_renderer.py", line 125, in _draw_nodes
    _draw_task_group(node, parent_graph, states_by_task_id)
  File ... lib/python3.9/site-packages/airflow/utils/dot_renderer.py", line 110, in _draw_task_group
    _draw_nodes(child, parent_graph, states_by_task_id)
  File ... lib/python3.9/site-packages/airflow/utils/dot_renderer.py", line 121, in _draw_nodes
    raise AirflowException(f"The node {node} should be TaskGroup and is not")
airflow.exceptions.AirflowException: The node <Mapped(BashOperator): hello_world> should be TaskGroup and is not

What you think should happen instead

I should see something about the dag structure.

How to reproduce

run airflow dags show for any dag with a task expansion

Operating System

MacOS, venv

Versions of Apache Airflow Providers

n/a

Deployment

Virtualenv installation

Deployment details

❯ airflow version                
2.3.0.dev0

cloned at 4f6fe72

Anything else

There's a related card on this board https://github.com/apache/airflow/projects/12

Support Mapped task groups in the DAG "dot renderer" (i.e. backfill job with --show-dagrun)

But I don't think that functionality is making it into 2.3.0, so maybe we need to add a fix here in the meantime?

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@MatrixManAtYrService MatrixManAtYrService added area:core kind:bug This is a clearly a bug labels Apr 28, 2022
@MatrixManAtYrService MatrixManAtYrService changed the title airflow dags show gives AirflowException: The node <...> should be TaskGroup and is not airflow dags show Exception: "The node ... should be TaskGroup and is not" Apr 28, 2022
@RNHTTR
Copy link
Contributor

RNHTTR commented Apr 28, 2022

I'm able to reproduce in breeze. I'd be happy to take this one.

@potiuk
Copy link
Member

potiuk commented Apr 28, 2022

Assigned to you @RNHTTR :)

@RNHTTR
Copy link
Contributor

RNHTTR commented Apr 28, 2022

I've found the issue. Task expansion creates a MappedOperator, which interestingly inherits from AbstractOperator and not BaseOperator.

airflow dags show ultimately users [dot_renderer.py](https://github.com/apache/airflow/blob/main/airflow/utils/dot_renderer.py#L117-L118) to draw the DAG, and it checks that each node is either a TaskGroup or a BaseOperator, thus the error. I'll put together a fix, a test, and submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants