uranusjr commented on code in PR #32351:
URL: https://github.com/apache/airflow/pull/32351#discussion_r1254033727


##########
airflow/utils/task_group.py:
##########
@@ -645,6 +659,20 @@ def get_current_task_group(cls, dag: DAG | None) -> 
TaskGroup | None:
 
         return cls._context_managed_task_group
 
+    @classmethod
+    def add_task(cls, task: DependencyMixin) -> None:
+        """Add the task to the current TaskGroup if not already there."""
+        from airflow.utils.edgemodifier import EdgeModifier
+
+        if isinstance(task, TaskGroup) or isinstance(task, EdgeModifier):
+            return
+        task_ = cast(DAGNode, task)

Review Comment:
   Maybe we can add a method on `DependencyMixin` called something like 
`add_to_task_group(self, tg)` (name suggestions welcomed). A `TaskGroup` or 
`EdgeModifier` can implement this as a single `pass` (i.e. do nothing at all) 
and other subclasses can implement it as appropriate. Alternatively 
`get_nodes_to_add_to_task_group()` where `TaskGroup` returns None, operator 
returns itself, and XComArg returns `self.operator` etc.



-- 
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

Reply via email to