hyeong10 opened a new issue, #31604:
URL: https://github.com/apache/airflow/issues/31604

   ### What do you see as an issue?
   
   Hello!
   
   I don't know if this is intended, but default_args is not an override when 
using nested TaskGroups.
   
   ```python
   def callback_in_dag(context: Context):
       print("DAG!")
   
   def callback_in_task_group(context: Context):
       print("Parent TaskGroup!")
   
   with DAG(
           "some_dag_id",
           default_args={
               "on_failure_callback": callback_in_dag
           },
           schedule=None,
           start_date=datetime(2023, 1, 1)
   ) as dag:
       with TaskGroup("parent_tg", default_args={"on_failure_callback": 
callback_in_task_group}) as parent_tg:
           with TaskGroup("child_tg") as child_tg:
               t1 = BashOperator(task_id="task_1", 
bash_command="nooooo_command")
   ```
   
   I want the result to be "Parent TaskGroup!", but I get "DAG!".
   
   ```
   [2023-05-30, 10:38:52 KST] {logging_mixin.py:137} INFO - DAG!
   ```
   
   ### Solving the problem
   
   Add `_update_default_args` like 
[link](https://github.com/apache/airflow/blob/f6bb4746efbc6a94fa17b6c77b31d9fb17305ffc/airflow/models/baseoperator.py#L139)
   
   #### airflow/utils/task_group.py
   ```python
   class TaskGroup(DAGNode):
       def __init__(...):
           ...
           self.default_args = copy.deepcopy(default_args or {})
   
           # Call 'self._update_default_args' when exists parent_group
           if parent_group is not None:
               self._update_default_args(parent_group)
           ...
       ...
       # Update self.default_args
       def _update_default_args(parent_group: TaskGroup):
           if parent_group.default_args:
               self.default_args.update(parent_group.default_args) 
   ```
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to