You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kaxil (via GitHub)" <gi...@apache.org> on 2025/08/23 01:58:28 UTC

[PR] Move `task_group_to_dict` functions to Core [airflow]

kaxil opened a new pull request, #54857:
URL: https://github.com/apache/airflow/pull/54857

   Follow-up of the fix in https://github.com/apache/airflow/pull/54756
   - Move `task_group_to_dict` and `task_group_to_dict_grid` functions from `task-sdk` to `airflow-core` API services
   - Update import paths in `grid.py` and `structure.py` to use new server-side location
   - Update deprecation mappings to point to new FastAPI service module locations
   - Remove `AbstractOperator` from isinstance checks in server-side functions (now handles only serialized objects)
   - Split mixed tests: moved TaskGroup functionality tests to `task-sdk`, keep server function tests in `airflow-core`
   - Add comprehensive TaskGroup tests in `task-sdk` covering creation, relationships, decorators, and validation
   - Create clear architectural boundary: client-side TaskGroup authoring vs server-side serialized DAG processing
   
   <img width="1722" height="693" alt="image" src="https://github.com/user-attachments/assets/1ef30baa-de45-4af8-9fe6-d80fd0634b7c" />
   
   
   <!--
    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.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `TaskGroup` UI & API functions to server-side [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #54857:
URL: https://github.com/apache/airflow/pull/54857#discussion_r2296556643


##########
airflow-core/src/airflow/utils/__init__.py:
##########
@@ -30,8 +30,8 @@
     },
     "task_group": {
         "TaskGroup": "airflow.sdk.TaskGroup",
-        "get_task_group_children_getter": "airflow.sdk.definitions.taskgroup.get_task_group_children_getter",
-        "task_group_to_dict": "airflow.sdk.definitions.taskgroup.task_group_to_dict",
+        "get_task_group_children_getter": "airflow.api_fastapi.core_api.services.ui.task_group.get_task_group_children_getter",
+        "task_group_to_dict": "airflow.api_fastapi.core_api.services.ui.task_group.task_group_to_dict",

Review Comment:
   🤷 



##########
airflow-core/src/airflow/utils/__init__.py:
##########
@@ -30,8 +30,8 @@
     },
     "task_group": {
         "TaskGroup": "airflow.sdk.TaskGroup",
-        "get_task_group_children_getter": "airflow.sdk.definitions.taskgroup.get_task_group_children_getter",
-        "task_group_to_dict": "airflow.sdk.definitions.taskgroup.task_group_to_dict",
+        "get_task_group_children_getter": "airflow.api_fastapi.core_api.services.ui.task_group.get_task_group_children_getter",
+        "task_group_to_dict": "airflow.api_fastapi.core_api.services.ui.task_group.task_group_to_dict",

Review Comment:
   🤷 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `task_group_to_dict` functions to Core [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #54857:
URL: https://github.com/apache/airflow/pull/54857#discussion_r2295016548


##########
.pre-commit-config.yaml:
##########
@@ -1667,58 +1667,59 @@ repos:
           ^airflow-core/src/airflow/listeners/spec/asset\.py$|
           ^airflow-core/src/airflow/listeners/spec/taskinstance\.py$|
           ^airflow-core/src/airflow/logging/remote\.py$|
+          ^airflow-core/src/airflow/models/__init__\.py$|
           ^airflow-core/src/airflow/models/asset\.py$|
           ^airflow-core/src/airflow/models/baseoperator\.py$|
           ^airflow-core/src/airflow/models/connection\.py$|
           ^airflow-core/src/airflow/models/dag\.py$|
-          ^airflow-core/src/airflow/models/deadline\.py$|
           ^airflow-core/src/airflow/models/dagbag\.py$|
           ^airflow-core/src/airflow/models/dagrun\.py$|
+          ^airflow-core/src/airflow/models/deadline\.py$|
+          ^airflow-core/src/airflow/models/expandinput\.py$|
           ^airflow-core/src/airflow/models/mappedoperator\.py$|
           ^airflow-core/src/airflow/models/operator\.py$|
           ^airflow-core/src/airflow/models/param\.py$|
+          ^airflow-core/src/airflow/models/renderedtifields\.py$|
           ^airflow-core/src/airflow/models/serialized_dag\.py$|
           ^airflow-core/src/airflow/models/taskinstance\.py$|
           ^airflow-core/src/airflow/models/taskinstancekey\.py$|
           ^airflow-core/src/airflow/models/taskmap\.py$|
+          ^airflow-core/src/airflow/models/taskmixin\.py$|
           ^airflow-core/src/airflow/models/taskreschedule\.py$|
           ^airflow-core/src/airflow/models/variable\.py$|
+          ^airflow-core/src/airflow/models/xcom\.py$|
+          ^airflow-core/src/airflow/models/xcom_arg\.py$|
           ^airflow-core/src/airflow/operators/subdag\.py$|
+          ^airflow-core/src/airflow/plugins_manager\.py$|
+          ^airflow-core/src/airflow/providers_manager\.py$|
           ^airflow-core/src/airflow/serialization/dag\.py$|
           ^airflow-core/src/airflow/serialization/enums\.py$|
+          ^airflow-core/src/airflow/serialization/helpers\.py$|
           ^airflow-core/src/airflow/serialization/serialized_objects\.py$|
+          ^airflow-core/src/airflow/settings\.py$|
           ^airflow-core/src/airflow/task/task_runner/bash_task_runner\.py$|
           ^airflow-core/src/airflow/task/task_runner/standard_task_runner\.py$|
+          ^airflow-core/src/airflow/ti_deps/deps/mapped_task_upstream_dep\.py$|
+          ^airflow-core/src/airflow/ti_deps/deps/prev_dagrun_dep\.py$|
+          ^airflow-core/src/airflow/ti_deps/deps/trigger_rule_dep\.py$|
+          ^airflow-core/src/airflow/timetables/assets\.py$|
+          ^airflow-core/src/airflow/timetables/base\.py$|
+          ^airflow-core/src/airflow/timetables/simple\.py$|
+          ^airflow-core/src/airflow/utils/cli\.py$|
+          ^airflow-core/src/airflow/utils/context\.py$|
           ^airflow-core/src/airflow/utils/dag_cycle_tester\.py$|
+          ^airflow-core/src/airflow/utils/dag_edges\.py$|
           ^airflow-core/src/airflow/utils/dag_parsing_context\.py$|
           ^airflow-core/src/airflow/utils/decorators\.py$|
+          ^airflow-core/src/airflow/utils/dot_renderer\.py$|
+          ^airflow-core/src/airflow/utils/edgemodifier\.py$|
+          ^airflow-core/src/airflow/utils/email\.py$|
+          ^airflow-core/src/airflow/utils/helpers\.py$|
           ^airflow-core/src/airflow/utils/operator_helpers\.py$|
           ^airflow-core/src/airflow/utils/session\.py$|
           ^airflow-core/src/airflow/utils/task_group\.py$|
           ^airflow-core/src/airflow/utils/trigger_rule\.py$|
-          ^airflow-core/src/airflow/utils/xcom\.py$|
-          ^airflow-core/src/airflow/providers_manager\.py$|
-          ^airflow-core/src/airflow/timetables/assets\.py$|
-          ^airflow-core/src/airflow/ti_deps/deps/prev_dagrun_dep\.py$|
-          ^airflow-core/src/airflow/utils/context\.py$|
-          ^airflow-core/src/airflow/models/taskmixin\.py$|
-          ^airflow-core/src/airflow/utils/edgemodifier\.py$|
-          ^airflow-core/src/airflow/utils/email\.py$|
-          ^airflow-core/src/airflow/ti_deps/deps/trigger_rule_dep\.py$|
-          ^airflow-core/src/airflow/utils/helpers\.py$|
-          ^airflow-core/src/airflow/ti_deps/deps/mapped_task_upstream_dep\.py$|

Review Comment:
   I have just sorted this list alphabetically and added `^airflow-core/src/airflow/api_fastapi/core_api/services/ui/task_group.py`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `TaskGroup` UI & API functions to server-side [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #54857:
URL: https://github.com/apache/airflow/pull/54857#discussion_r2301655078


##########
airflow-core/src/airflow/utils/__init__.py:
##########
@@ -30,8 +30,8 @@
     },
     "task_group": {
         "TaskGroup": "airflow.sdk.TaskGroup",
-        "get_task_group_children_getter": "airflow.sdk.definitions.taskgroup.get_task_group_children_getter",
-        "task_group_to_dict": "airflow.sdk.definitions.taskgroup.task_group_to_dict",
+        "get_task_group_children_getter": "airflow.api_fastapi.core_api.services.ui.task_group.get_task_group_children_getter",
+        "task_group_to_dict": "airflow.api_fastapi.core_api.services.ui.task_group.task_group_to_dict",

Review Comment:
   Remvoed and added newsfragment



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `TaskGroup` UI & API functions to server-side [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #54857:
URL: https://github.com/apache/airflow/pull/54857#discussion_r2296357968


##########
airflow-core/src/airflow/utils/__init__.py:
##########
@@ -30,8 +30,8 @@
     },
     "task_group": {
         "TaskGroup": "airflow.sdk.TaskGroup",
-        "get_task_group_children_getter": "airflow.sdk.definitions.taskgroup.get_task_group_children_getter",
-        "task_group_to_dict": "airflow.sdk.definitions.taskgroup.task_group_to_dict",
+        "get_task_group_children_getter": "airflow.api_fastapi.core_api.services.ui.task_group.get_task_group_children_getter",
+        "task_group_to_dict": "airflow.api_fastapi.core_api.services.ui.task_group.task_group_to_dict",

Review Comment:
   Should we even catch that then? Just remove and add a note in release notes?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `TaskGroup` UI & API functions to server-side [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil merged PR #54857:
URL: https://github.com/apache/airflow/pull/54857


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `TaskGroup` UI & API functions to server-side [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #54857:
URL: https://github.com/apache/airflow/pull/54857#issuecomment-3225215919

   ### Backport failed to create: v3-0-test. View the failure log <a href='https://github.com/apache/airflow/actions/runs/17246678473'> Run details </a>
   
   <table>
       <tr>
           <th>Status</th>
           <th>Branch</th>
           <th>Result</th>
       </tr>
       <tr>
           <td>❌</td>
           <td>v3-0-test</td>
           <td><a href="https://github.com/apache/airflow/commit/c8a0f51f89dc5c75b86c6888154073c08c2a0671"><img src='https://img.shields.io/badge/Commit-c8a0f51-red' alt='Commit Link'></a></td>
       </tr>
   </table>
   
   You can attempt to backport this manually by running:
   
   ```bash
   cherry_picker c8a0f51 v3-0-test
   ```
   
   This should apply the commit to the v3-0-test branch and leave the commit in conflict state marking
   the files that need manual conflict resolution.
   
   After you have resolved the conflicts, you can continue the backport process by running:
   
   ```bash
   cherry_picker --continue
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `task_group_to_dict` functions to Core [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #54857:
URL: https://github.com/apache/airflow/pull/54857#discussion_r2295016871


##########
task-sdk/src/airflow/sdk/definitions/taskgroup.py:
##########
@@ -673,97 +670,3 @@ def iter_mapped_dependencies(self) -> Iterator[Operator]:
 
         for op, _ in XComArg.iter_xcom_references(self._expand_input):
             yield op
-
-
-@cache
-def get_task_group_children_getter() -> Callable:
-    """Get the Task Group Children Getter for the DAG."""
-    sort_order = conf.get("api", "grid_view_sorting_order")
-    if sort_order == "topological":
-        return methodcaller("topological_sort")
-    return methodcaller("hierarchical_alphabetical_sort")
-
-
-def task_group_to_dict(task_item_or_group, parent_group_is_mapped=False):

Review Comment:
   This are purely used in UI & API to display in Grid & Graph view



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `task_group_to_dict` functions to Core [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #54857:
URL: https://github.com/apache/airflow/pull/54857#discussion_r2295016948


##########
task-sdk/src/airflow/sdk/definitions/taskgroup.py:
##########
@@ -673,97 +670,3 @@ def iter_mapped_dependencies(self) -> Iterator[Operator]:
 
         for op, _ in XComArg.iter_xcom_references(self._expand_input):
             yield op
-
-
-@cache
-def get_task_group_children_getter() -> Callable:
-    """Get the Task Group Children Getter for the DAG."""
-    sort_order = conf.get("api", "grid_view_sorting_order")
-    if sort_order == "topological":
-        return methodcaller("topological_sort")
-    return methodcaller("hierarchical_alphabetical_sort")
-
-
-def task_group_to_dict(task_item_or_group, parent_group_is_mapped=False):

Review Comment:
   So they have been moved to the Airflow Core side



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move `TaskGroup` UI & API functions to server-side [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #54857:
URL: https://github.com/apache/airflow/pull/54857#discussion_r2296263983


##########
airflow-core/src/airflow/utils/__init__.py:
##########
@@ -30,8 +30,8 @@
     },
     "task_group": {
         "TaskGroup": "airflow.sdk.TaskGroup",
-        "get_task_group_children_getter": "airflow.sdk.definitions.taskgroup.get_task_group_children_getter",
-        "task_group_to_dict": "airflow.sdk.definitions.taskgroup.task_group_to_dict",
+        "get_task_group_children_getter": "airflow.api_fastapi.core_api.services.ui.task_group.get_task_group_children_getter",
+        "task_group_to_dict": "airflow.api_fastapi.core_api.services.ui.task_group.task_group_to_dict",

Review Comment:
   These feel like they should issue a "don't use this anymore warning", not just an "it's moved warning" as we don't want people importing anything from the api do we?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org