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


##########
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:
   I have tried to work out this, but it seems it won't be possible for this 
use case. For example, `TaskGroup` is a subclass of `DependencyMixin` but here 
I don't want to add a task group into `TaskGroup.add`. This means I need to 
filter it out. TaskGroup.add can accept a TaskGroup since a TaskGroup is a 
subclass of DAGNode but for this use case, I don't want a TaskGroup to be added 
into it. The `isinstance` on EdgeModifier seems inevitable too since I don't 
also want an EdgeModifier in TaskGroup.add. 
   I'm open to ideas on how to do it.



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