This is an automated email from the ASF dual-hosted git repository. kaxilnaik pushed a commit to branch v3-0-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 6bf14444bf257ba59579fe71b21c689e1b21dacd Author: Amogh Desai <[email protected]> AuthorDate: Thu Apr 17 18:46:31 2025 +0530 Use Label class from task sdk (#49385) (cherry picked from commit f830f9f4d2c4b5b0ba43bc10bdaf9d6ddcbe6815) --- airflow-core/docs/core-concepts/dags.rst | 6 +++--- airflow-core/src/airflow/example_dags/example_branch_labels.py | 3 +-- airflow-core/src/airflow/example_dags/example_branch_operator.py | 3 +-- .../src/airflow/example_dags/example_branch_operator_decorator.py | 3 +-- airflow-core/tests/unit/serialization/test_dag_serialization.py | 2 +- airflow-core/tests/unit/utils/test_dag_cycle.py | 2 +- airflow-core/tests/unit/utils/test_edgemodifier.py | 2 +- airflow-core/tests/unit/utils/test_task_group.py | 3 +-- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/airflow-core/docs/core-concepts/dags.rst b/airflow-core/docs/core-concepts/dags.rst index a06ee6a9569..5537ea12d94 100644 --- a/airflow-core/docs/core-concepts/dags.rst +++ b/airflow-core/docs/core-concepts/dags.rst @@ -620,7 +620,7 @@ To add labels, you can use them directly inline with the ``>>`` and ``<<`` opera .. code-block:: python - from airflow.utils.edgemodifier import Label + from airflow.sdk import Label my_task >> Label("When empty") >> other_task @@ -628,7 +628,7 @@ Or, you can pass a Label object to ``set_upstream``/``set_downstream``: .. code-block:: python - from airflow.utils.edgemodifier import Label + from airflow.sdk import Label my_task.set_downstream(other_task, Label("When empty")) @@ -638,7 +638,7 @@ Here's an example DAG which illustrates labeling different branches: .. exampleinclude:: /../src/airflow/example_dags/example_branch_labels.py :language: python - :start-after: from airflow.utils.edgemodifier import Label + :start-after: from airflow.sdk import DAG, Label DAG & Task Documentation diff --git a/airflow-core/src/airflow/example_dags/example_branch_labels.py b/airflow-core/src/airflow/example_dags/example_branch_labels.py index edc1b059738..fcff3d5a3a1 100644 --- a/airflow-core/src/airflow/example_dags/example_branch_labels.py +++ b/airflow-core/src/airflow/example_dags/example_branch_labels.py @@ -24,8 +24,7 @@ from __future__ import annotations import pendulum from airflow.providers.standard.operators.empty import EmptyOperator -from airflow.sdk import DAG -from airflow.utils.edgemodifier import Label +from airflow.sdk import DAG, Label with DAG( "example_branch_labels", diff --git a/airflow-core/src/airflow/example_dags/example_branch_operator.py b/airflow-core/src/airflow/example_dags/example_branch_operator.py index d824de4aa08..0bb429a6f8f 100644 --- a/airflow-core/src/airflow/example_dags/example_branch_operator.py +++ b/airflow-core/src/airflow/example_dags/example_branch_operator.py @@ -38,8 +38,7 @@ from airflow.providers.standard.operators.python import ( PythonOperator, PythonVirtualenvOperator, ) -from airflow.sdk import DAG -from airflow.utils.edgemodifier import Label +from airflow.sdk import DAG, Label from airflow.utils.trigger_rule import TriggerRule PATH_TO_PYTHON_BINARY = sys.executable diff --git a/airflow-core/src/airflow/example_dags/example_branch_operator_decorator.py b/airflow-core/src/airflow/example_dags/example_branch_operator_decorator.py index 7bc1d94ee95..d3634acb998 100644 --- a/airflow-core/src/airflow/example_dags/example_branch_operator_decorator.py +++ b/airflow-core/src/airflow/example_dags/example_branch_operator_decorator.py @@ -31,8 +31,7 @@ import tempfile import pendulum from airflow.providers.standard.operators.empty import EmptyOperator -from airflow.sdk import DAG, task -from airflow.utils.edgemodifier import Label +from airflow.sdk import DAG, Label, task from airflow.utils.trigger_rule import TriggerRule PATH_TO_PYTHON_BINARY = sys.executable diff --git a/airflow-core/tests/unit/serialization/test_dag_serialization.py b/airflow-core/tests/unit/serialization/test_dag_serialization.py index a6609454700..69570392158 100644 --- a/airflow-core/tests/unit/serialization/test_dag_serialization.py +++ b/airflow-core/tests/unit/serialization/test_dag_serialization.py @@ -2025,7 +2025,7 @@ class TestStringifiedDAGs: Tests edge_info serialization/deserialization. """ from airflow.providers.standard.operators.empty import EmptyOperator - from airflow.utils.edgemodifier import Label + from airflow.sdk import Label with DAG( "test_edge_info_serialization", diff --git a/airflow-core/tests/unit/utils/test_dag_cycle.py b/airflow-core/tests/unit/utils/test_dag_cycle.py index ff36fddd20a..c436af01c7d 100644 --- a/airflow-core/tests/unit/utils/test_dag_cycle.py +++ b/airflow-core/tests/unit/utils/test_dag_cycle.py @@ -21,8 +21,8 @@ import pytest from airflow.exceptions import AirflowDagCycleException from airflow.models.dag import DAG from airflow.providers.standard.operators.empty import EmptyOperator +from airflow.sdk import Label from airflow.utils.dag_cycle_tester import check_cycle -from airflow.utils.edgemodifier import Label from airflow.utils.task_group import TaskGroup from unit.models import DEFAULT_DATE diff --git a/airflow-core/tests/unit/utils/test_edgemodifier.py b/airflow-core/tests/unit/utils/test_edgemodifier.py index 79749af5cc0..0885230e113 100644 --- a/airflow-core/tests/unit/utils/test_edgemodifier.py +++ b/airflow-core/tests/unit/utils/test_edgemodifier.py @@ -24,8 +24,8 @@ from airflow.models.dag import DAG from airflow.models.xcom_arg import XComArg from airflow.providers.standard.operators.empty import EmptyOperator from airflow.providers.standard.operators.python import PythonOperator +from airflow.sdk import Label from airflow.utils.dag_edges import dag_edges -from airflow.utils.edgemodifier import Label from airflow.utils.task_group import TaskGroup DEFAULT_ARGS = { diff --git a/airflow-core/tests/unit/utils/test_task_group.py b/airflow-core/tests/unit/utils/test_task_group.py index 38db9cd9dd2..60acb78fbb4 100644 --- a/airflow-core/tests/unit/utils/test_task_group.py +++ b/airflow-core/tests/unit/utils/test_task_group.py @@ -1433,8 +1433,7 @@ def test_add_to_another_group(): def test_task_group_edge_modifier_chain(): - from airflow.sdk import chain - from airflow.utils.edgemodifier import Label + from airflow.sdk import Label, chain with DAG(dag_id="test", schedule=None, start_date=pendulum.DateTime(2022, 5, 20)) as dag: start = EmptyOperator(task_id="sleep_3_seconds")
