guan404ming opened a new pull request, #54322: URL: https://github.com/apache/airflow/pull/54322
<!-- 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/ --> ## Why - task group page is lack of support of hitl currently ## How - add the tab like other pages <img width="1371" height="860" alt="image" src="https://github.com/user-attachments/assets/fb025798-9237-4502-b9d5-2943209976ea" /> tested with this example ```python from __future__ import annotations # [START hitl_tutorial] import datetime import pendulum from airflow.providers.standard.operators.hitl import ( ApprovalOperator, HITLBranchOperator, HITLEntryOperator, HITLOperator, ) from airflow.sdk import DAG, Param, task from airflow.sdk.definitions.taskgroup import TaskGroup with DAG( dag_id="aip_90_dag", start_date=pendulum.datetime(2021, 1, 1, tz="UTC"), catchup=False, tags=["example", "HITL"], ) as dag: # [START howto_task_group_input_collection] with TaskGroup("input_collection", tooltip="Collect user inputs and options") as input_collection: # [START howto_hitl_entry_operator] wait_for_input = HITLEntryOperator( task_id="wait_for_input", subject="Please provide required information: ", params={"information": Param("", type="string")}, ) # [END howto_hitl_entry_operator] # [START howto_hitl_operator] wait_for_option = HITLOperator( task_id="wait_for_option", subject="Please choose one option to proceed: ", options=["option 1", "option 2", "option 3"], ) # [END howto_hitl_operator] # [END howto_task_group_input_collection] # [START howto_task_group_validation] with TaskGroup("validation", tooltip="Validate collected inputs and options") as validation: # [START howto_hitl_approval_operator] valid_input_and_options = ApprovalOperator( task_id="valid_input_and_options", subject="Are the following input and options valid?", body=""" * Input: {{ task_instance.xcom_pull(task_ids='input_collection.wait_for_input', key='return_value')["params_input"]["information"] }} * Option: {{ task_instance.xcom_pull(task_ids='input_collection.wait_for_option', key='return_value')["chosen_options"] }} """, defaults="Reject", execution_timeout=datetime.timedelta(minutes=1), ) # [END howto_hitl_approval_operator] # [START howto_hitl_branch_operator] choose_a_branch_to_run = HITLBranchOperator( task_id="choose_a_branch_to_run", subject="You're now allowed to proceeded. Please choose one task to run: ", options=["task_1", "task_2", "task_3"], ) # [END howto_hitl_branch_operator] valid_input_and_options >> choose_a_branch_to_run # [END howto_task_group_validation] # [START howto_task_group_execution] with TaskGroup("execution", tooltip="Execute selected tasks") as execution: # [START howto_hitl_workflow] @task def task_1(): ... @task def task_2(): ... @task def task_3(): ... [task_1(), task_2(), task_3()] # [END howto_hitl_workflow] # [END howto_task_group_execution] # Define task group dependencies input_collection >> validation >> execution # [END hitl_tutorial] ``` <!-- 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-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org