pierrejeambrun commented on code in PR #58092:
URL: https://github.com/apache/airflow/pull/58092#discussion_r2603140969


##########
airflow-core/src/airflow/api_fastapi/common/parameters.py:
##########
@@ -185,6 +185,64 @@ def depends(cls, *args: Any, **kwargs: Any) -> Self:
         raise NotImplementedError("Use search_param_factory instead , depends 
is not implemented.")
 
 
+class QueryTITaskGroupDisplayNamePattern(BaseParam[str]):
+    """Task group display name pattern filter - returns all tasks in matching 
groups."""
+
+    def __init__(self, dag=None, skip_none: bool = True):
+        super().__init__(skip_none=skip_none)
+        self.dag = dag
+
+    def to_orm(self, select: Select) -> Select:
+        if self.value is None and self.skip_none:
+            return select
+
+        if self.dag and hasattr(self.dag, "task_group"):
+            task_groups = self.dag.task_group.get_task_group_dict()
+
+            # Pattern matching on both group display name and group_id
+            matching_task_ids = []
+            for group_id, task_group in task_groups.items():
+                if group_id is None:  # Skip root group
+                    continue
+
+                # Check both the display name (label) and the group_id for 
pattern matching
+                display_name = getattr(task_group, "label", None)
+                if (
+                    display_name and self._matches_pattern(display_name, 
self.value)
+                ) or self._matches_pattern(group_id, self.value):
+                    matching_task_ids.extend([task.task_id for task in 
task_group.iter_tasks()])
+
+            if matching_task_ids:
+                return 
select.where(TaskInstance.task_id.in_(matching_task_ids))

Review Comment:
   We shouldn't do 'pattern' matching, but exact match on group because it will 
be too hard to implement properly. What we want are really 'all tasks' from 
'this group'. We don't want, 'all tasks' that belongs to a group that match 
'that pattern'. (And potentially having cross group TI in the response)



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