Skip to content

Commit 405bb72

Browse files
ashbnailo2c
authored andcommitted
Remove default_view property from DAG class and model (apache#47616)
This doesn't make sense to be controlled from the DAG code in the new UI in Airflow 3 anymore. Part of apache#43519
1 parent 0206214 commit 405bb72

File tree

25 files changed

+1706
-1774
lines changed

25 files changed

+1706
-1774
lines changed

airflow/api_fastapi/core_api/datamodels/dags.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class DAGResponse(BaseModel):
6161
is_active: bool
6262
last_parsed_time: datetime | None
6363
last_expired: datetime | None
64-
default_view: str | None
6564
fileloc: str
6665
description: str | None
6766
timetable_summary: str | None

airflow/api_fastapi/core_api/openapi/v1-generated.yaml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8243,11 +8243,6 @@ components:
82438243
format: date-time
82448244
- type: 'null'
82458245
title: Last Expired
8246-
default_view:
8247-
anyOf:
8248-
- type: string
8249-
- type: 'null'
8250-
title: Default View
82518246
fileloc:
82528247
type: string
82538248
title: Fileloc
@@ -8403,7 +8398,6 @@ components:
84038398
- is_active
84048399
- last_parsed_time
84058400
- last_expired
8406-
- default_view
84078401
- fileloc
84088402
- description
84098403
- timetable_summary
@@ -8473,11 +8467,6 @@ components:
84738467
format: date-time
84748468
- type: 'null'
84758469
title: Last Expired
8476-
default_view:
8477-
anyOf:
8478-
- type: string
8479-
- type: 'null'
8480-
title: Default View
84818470
fileloc:
84828471
type: string
84838472
title: Fileloc
@@ -8560,7 +8549,6 @@ components:
85608549
- is_active
85618550
- last_parsed_time
85628551
- last_expired
8563-
- default_view
85648552
- fileloc
85658553
- description
85668554
- timetable_summary
@@ -8989,11 +8977,6 @@ components:
89898977
format: date-time
89908978
- type: 'null'
89918979
title: Last Expired
8992-
default_view:
8993-
anyOf:
8994-
- type: string
8995-
- type: 'null'
8996-
title: Default View
89978980
fileloc:
89988981
type: string
89998982
title: Fileloc
@@ -9081,7 +9064,6 @@ components:
90819064
- is_active
90829065
- last_parsed_time
90839066
- last_expired
9084-
- default_view
90859067
- fileloc
90869068
- description
90879069
- timetable_summary

airflow/cli/commands/remote_commands/dag_command.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class Meta:
9090
is_active = auto_field(dump_only=True)
9191
last_parsed_time = auto_field(dump_only=True)
9292
last_expired = auto_field(dump_only=True)
93-
default_view = auto_field(dump_only=True)
9493
fileloc = auto_field(dump_only=True)
9594
file_token = fields.Method("get_token", dump_only=True)
9695
owners = fields.Method("get_owners", dump_only=True)
@@ -295,7 +294,6 @@ def _get_dagbag_dag_details(dag: DAG) -> dict:
295294
"is_active": dag.get_is_active(),
296295
"last_parsed_time": None,
297296
"last_expired": None,
298-
"default_view": dag.default_view,
299297
"fileloc": dag.fileloc,
300298
"file_token": None,
301299
"owners": dag.owner,

airflow/config_templates/config.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,13 +1687,6 @@ webserver:
16871687
type: string
16881688
example: ~
16891689
default: "False"
1690-
dag_default_view:
1691-
description: |
1692-
Default DAG view. Valid values are: ``grid``, ``graph``, ``duration``, ``gantt``, ``landing_times``
1693-
version_added: ~
1694-
type: string
1695-
example: ~
1696-
default: "grid"
16971690
dag_orientation:
16981691
description: |
16991692
Default DAG orientation. Valid values are:

airflow/configuration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ def inversed_deprecated_sections(self):
358358
},
359359
"webserver": {
360360
"navbar_color": (re.compile(r"(?i)^#007A87$"), "#fff", "2.1"),
361-
"dag_default_view": (re.compile(r"^tree$"), "grid", "3.0"),
362361
},
363362
"email": {
364363
"email_backend": (

airflow/dag_processing/collection.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ def update_dags(
426426
dm.is_active = True
427427
dm.has_import_errors = False
428428
dm.last_parsed_time = utcnow()
429-
dm.default_view = dag.default_view or conf.get("webserver", "dag_default_view").lower()
430429
if hasattr(dag, "_dag_display_property_value"):
431430
dm._dag_display_property_value = dag._dag_display_property_value
432431
elif dag.dag_display_name != dag.dag_id:
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
"""
20+
Remove dag.default_view column.
21+
22+
Revision ID: 16f7f5ee874e
23+
Revises: cf87489a35df
24+
Create Date: 2025-03-11 10:39:25.449265
25+
26+
"""
27+
28+
from __future__ import annotations
29+
30+
import sqlalchemy as sa
31+
from alembic import op
32+
33+
# revision identifiers, used by Alembic.
34+
revision = "16f7f5ee874e"
35+
down_revision = "cf87489a35df"
36+
branch_labels = None
37+
depends_on = None
38+
airflow_version = "3.0.0"
39+
40+
41+
def upgrade():
42+
with op.batch_alter_table("dag", schema=None) as batch_op:
43+
batch_op.drop_column("default_view")
44+
45+
46+
def downgrade():
47+
with op.batch_alter_table("dag", schema=None) as batch_op:
48+
batch_op.add_column(sa.Column("default_view", sa.VARCHAR(length=25), nullable=True))

airflow/models/dag.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124

125125
log = logging.getLogger(__name__)
126126

127-
DEFAULT_VIEW_PRESETS = ["grid", "graph", "duration", "gantt", "landing_times"]
128127
ORIENTATION_PRESETS = ["LR", "TB", "RL", "BT"]
129128

130129
AssetT = TypeVar("AssetT", bound=BaseAsset)
@@ -380,8 +379,6 @@ class DAG(TaskSDKDag, LoggingMixin):
380379
:param dagrun_timeout: Specify the duration a DagRun should be allowed to run before it times out or
381380
fails. Task instances that are running when a DagRun is timed out will be marked as skipped.
382381
:param sla_miss_callback: DEPRECATED - The SLA feature is removed in Airflow 3.0, to be replaced with a new implementation in 3.1
383-
:param default_view: Specify DAG default view (grid, graph, duration,
384-
gantt, landing_times), default grid
385382
:param orientation: Specify DAG orientation in graph view (LR, TB, RL, BT), default LR
386383
:param catchup: Perform scheduler catchup (or only run latest)? Defaults to True
387384
:param on_failure_callback: A function or list of functions to be called when a DagRun of this dag fails.
@@ -428,7 +425,6 @@ class DAG(TaskSDKDag, LoggingMixin):
428425
partial: bool = False
429426
last_loaded: datetime | None = attrs.field(factory=timezone.utcnow)
430427

431-
default_view: str = airflow_conf.get_mandatory_value("webserver", "dag_default_view").lower()
432428
orientation: str = airflow_conf.get_mandatory_value("webserver", "dag_orientation")
433429

434430
# this will only be set at serialization time
@@ -1901,13 +1897,6 @@ def sync_to_db(self, session=NEW_SESSION):
19011897
bundle_version = self.get_bundle_version(session=session)
19021898
self.bulk_write_to_db(bundle_name, bundle_version, [self], session=session)
19031899

1904-
def get_default_view(self):
1905-
"""Allow backward compatible jinja2 templates."""
1906-
if self.default_view is None:
1907-
return airflow_conf.get("webserver", "dag_default_view").lower()
1908-
else:
1909-
return self.default_view
1910-
19111900
@staticmethod
19121901
@provide_session
19131902
def deactivate_unknown_dags(active_dag_ids, session=NEW_SESSION):
@@ -2084,8 +2073,6 @@ class DagModel(Base):
20842073
_dag_display_property_value = Column("dag_display_name", String(2000), nullable=True)
20852074
# Description of the dag
20862075
description = Column(Text)
2087-
# Default view of the DAG inside the webserver
2088-
default_view = Column(String(25))
20892076
# Timetable summary
20902077
timetable_summary = Column(Text, nullable=True)
20912078
# Timetable description
@@ -2235,11 +2222,6 @@ def get_paused_dag_ids(dag_ids: list[str], session: Session = NEW_SESSION) -> se
22352222
paused_dag_ids = {paused_dag_id for (paused_dag_id,) in paused_dag_ids}
22362223
return paused_dag_ids
22372224

2238-
def get_default_view(self) -> str:
2239-
"""Get the Default DAG View, returns the default config value if DagModel does not have a value."""
2240-
# This is for backwards-compatibility with old dags that don't have None as default_view
2241-
return self.default_view or airflow_conf.get_mandatory_value("webserver", "dag_default_view").lower()
2242-
22432225
@property
22442226
def safe_dag_id(self):
22452227
return self.dag_id.replace(".", "__dot__")

airflow/serialization/serialized_objects.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,6 @@ class SerializedDAG(DAG, BaseSerialization):
16371637
def __get_constructor_defaults():
16381638
param_to_attr = {
16391639
"description": "_description",
1640-
"default_view": "_default_view",
16411640
}
16421641
return {
16431642
param_to_attr.get(k, k): v.default
@@ -1917,7 +1916,6 @@ class LazyDeserializedDAG(pydantic.BaseModel):
19171916
"max_consecutive_failed_dag_runs",
19181917
"owner_links",
19191918
"access_control",
1920-
"default_view",
19211919
}
19221920

19231921
@property

airflow/ui/openapi-gen/requests/schemas.gen.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,17 +1589,6 @@ export const $DAGDetailsResponse = {
15891589
],
15901590
title: "Last Expired",
15911591
},
1592-
default_view: {
1593-
anyOf: [
1594-
{
1595-
type: "string",
1596-
},
1597-
{
1598-
type: "null",
1599-
},
1600-
],
1601-
title: "Default View",
1602-
},
16031592
fileloc: {
16041593
type: "string",
16051594
title: "Fileloc",
@@ -1884,7 +1873,6 @@ export const $DAGDetailsResponse = {
18841873
"is_active",
18851874
"last_parsed_time",
18861875
"last_expired",
1887-
"default_view",
18881876
"fileloc",
18891877
"description",
18901878
"timetable_summary",
@@ -1976,17 +1964,6 @@ export const $DAGResponse = {
19761964
],
19771965
title: "Last Expired",
19781966
},
1979-
default_view: {
1980-
anyOf: [
1981-
{
1982-
type: "string",
1983-
},
1984-
{
1985-
type: "null",
1986-
},
1987-
],
1988-
title: "Default View",
1989-
},
19901967
fileloc: {
19911968
type: "string",
19921969
title: "Fileloc",
@@ -2128,7 +2105,6 @@ export const $DAGResponse = {
21282105
"is_active",
21292106
"last_parsed_time",
21302107
"last_expired",
2131-
"default_view",
21322108
"fileloc",
21332109
"description",
21342110
"timetable_summary",
@@ -2776,17 +2752,6 @@ export const $DAGWithLatestDagRunsResponse = {
27762752
],
27772753
title: "Last Expired",
27782754
},
2779-
default_view: {
2780-
anyOf: [
2781-
{
2782-
type: "string",
2783-
},
2784-
{
2785-
type: "null",
2786-
},
2787-
],
2788-
title: "Default View",
2789-
},
27902755
fileloc: {
27912756
type: "string",
27922757
title: "Fileloc",
@@ -2935,7 +2900,6 @@ export const $DAGWithLatestDagRunsResponse = {
29352900
"is_active",
29362901
"last_parsed_time",
29372902
"last_expired",
2938-
"default_view",
29392903
"fileloc",
29402904
"description",
29412905
"timetable_summary",

0 commit comments

Comments
 (0)