-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to write dag_id and task_id in their national characters,…
… added display name for dag / task (v2) (#38446) * Add display name in DAGs and tasks Co-authored-by: Tzu-ping Chung <[email protected]> Co-authored-by: Aleksandr Shelukheev <[email protected]> * Fix frontend issues * Fix pytests * Add DAG display tool tips * Implement national language char display example oon two DAGs * Review nit from other PR * Fix WWW pytest on HTML code * Review feedback, make task_display_name a property, not a field in mapped operator * Review feedback, rename internal fields * Small nit, optimize sorting on DAG home page with display name * Review feedback * Fix pytests in API plus review feedback on API * Review feedback, extend schema, update apispecs and fix breadcrumb navigation * nit, update page titles as well * Fix pytests for extended API model * Ensure mapped operator also provides a display string * Ensure display field is only serialized if different from task id * fix pytest for API * Review feedback from TP * Move labels down to base and mapped operator * Move labels up to abstract operator * Only one decorator is needed --------- Co-authored-by: Vincent Gao <[email protected]> Co-authored-by: Tzu-ping Chung <[email protected]> Co-authored-by: Aleksandr Shelukheev <[email protected]>
- Loading branch information
1 parent
a033243
commit 8c44bcb
Showing
39 changed files
with
916 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
from __future__ import annotations | ||
|
||
import pendulum | ||
|
||
from airflow.decorators import dag, task | ||
from airflow.operators.empty import EmptyOperator | ||
|
||
|
||
# [START dag_decorator_usage] | ||
@dag( | ||
schedule=None, | ||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"), | ||
catchup=False, | ||
tags=["example"], | ||
dag_display_name="Sample DAG with Display Name", | ||
) | ||
def example_display_name(): | ||
sample_task_1 = EmptyOperator( | ||
task_id="sample_task_1", | ||
task_display_name="Sample Task 1", | ||
) | ||
|
||
@task(task_display_name="Sample Task 2") | ||
def sample_task_2(): | ||
pass | ||
|
||
sample_task_1 >> sample_task_2() | ||
|
||
|
||
example_dag = example_display_name() | ||
# [END dag_decorator_usage] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
airflow/migrations/versions/0139_2_9_0_add_display_name_for_dag_and_task_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
"""add display name for dag and task instance | ||
Revision ID: ee1467d4aa35 | ||
Revises: b4078ac230a1 | ||
Create Date: 2024-03-24 22:33:36.824827 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'ee1467d4aa35' | ||
down_revision = 'b4078ac230a1' | ||
branch_labels = None | ||
depends_on = None | ||
airflow_version = "2.9.0" | ||
|
||
|
||
def upgrade(): | ||
"""Apply add display name for dag and task instance""" | ||
op.add_column("dag", sa.Column("dag_display_name", sa.String(2000), nullable=True)) | ||
op.add_column("task_instance", sa.Column("task_display_name", sa.String(2000), nullable=True)) | ||
|
||
|
||
def downgrade(): | ||
"""Unapply add display name for dag and task instance""" | ||
op.drop_column("dag", "dag_display_name") | ||
op.drop_column("task_instance", "task_display_name") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.