Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion airflow/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ def string_lower_type(val):
)

# list_tasks
ARG_TREE = Arg(("-t", "--tree"), help="Tree view", action="store_true")
ARG_TREE = Arg(
("-t", "--tree"),
help="Deprecated - use `dags show` instead. Display tasks in a tree. Note that generating the tree can be slow and the output very large for some DAGs.",
action="store_true",
)

# tasks_run
# This is a hidden option -- not meant for users to set or know about
Expand Down
12 changes: 12 additions & 0 deletions airflow/models/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,12 @@ def pickle(self, session=NEW_SESSION) -> DagPickle:

def tree_view(self) -> None:
"""Print an ASCII tree representation of the DAG."""
warnings.warn(
"`tree_view` is deprecated and will be removed in Airflow 3.0.",
category=RemovedInAirflow3Warning,
stacklevel=2,
)

for tmp in self._generate_tree_view():
print(tmp)

Expand All @@ -2787,6 +2793,12 @@ def get_downstream(task, level=0) -> Generator[str, None, None]:

def get_tree_view(self) -> str:
"""Return an ASCII tree representation of the DAG."""
warnings.warn(
"`get_tree_view` is deprecated and will be removed in Airflow 3.0.",
category=RemovedInAirflow3Warning,
stacklevel=2,
)

rst = ""
for tmp in self._generate_tree_view():
rst += tmp + "\n"
Expand Down
14 changes: 12 additions & 2 deletions tests/models/test_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,15 +1653,25 @@ def test_tree_view(self):
op1_a >> op2 >> op3

with redirect_stdout(StringIO()) as stdout:
dag.tree_view()
with pytest.warns(
RemovedInAirflow3Warning,
match="`tree_view` is deprecated and will be removed in Airflow 3.0",
):
dag.tree_view()
stdout = stdout.getvalue()

stdout_lines = stdout.splitlines()
assert "t1_a" in stdout_lines[0]
assert "t2" in stdout_lines[1]
assert "t3" in stdout_lines[2]
assert "t1_b" in stdout_lines[3]
assert dag.get_tree_view() == (

with pytest.warns(
RemovedInAirflow3Warning,
match="`get_tree_view` is deprecated and will be removed in Airflow 3.0",
):
get_tree_view = dag.get_tree_view()
assert get_tree_view == (
"<Task(EmptyOperator): t1_a>\n"
" <Task(EmptyOperator): t2>\n"
" <Task(EmptyOperator): t3>\n"
Expand Down