raulcd commented on code in PR #14456:
URL: https://github.com/apache/arrow/pull/14456#discussion_r999204065


##########
dev/archery/archery/crossbow/core.py:
##########
@@ -1185,34 +1185,49 @@ def select(self, tasks=None, groups=None):
                     "Unable to match any tasks for `{}`".format(pattern)
                 )
 
-        requested_group_tasks = set()
-        for group in group_allowlist:
-            # separate the patterns from the blocklist patterns
-            task_patterns = list(config_groups[group])
-            task_blocklist_patterns = [
-                x.strip("~") for x in task_patterns if x.startswith("~")]
-            task_patterns = [x for x in task_patterns if not x.startswith("~")]
-
-            # treat the task names as glob patterns to select tasks more easily
-            for pattern in task_patterns:
-                matches = fnmatch.filter(valid_tasks, pattern)
-                if len(matches):
-                    requested_group_tasks.update(matches)
-                else:
+        def resolve_group(group):
+            group_tasks = set()
+            patterns = list(config_groups[group])
+            blocklist_patterns = [
+                x.strip("~") for x in patterns if x.startswith("~")]
+            patterns = [x for x in patterns if not x.startswith("~")]
+
+            # treat the task/group names as glob patterns to select
+            # tasks/groups more easily
+            for pattern in patterns:
+                matched_tasks = fnmatch.filter(valid_tasks, pattern)
+                matched_groups = fnmatch.filter(valid_groups, pattern)
+                matched_groups = set(matched_groups).difference([group])
+                if len(matched_tasks) == 0 and len(matched_groups) == 0:
                     raise CrossbowError(
-                        "Unable to match any tasks for `{}`".format(pattern)
+                        "Unable to match any tasks/groups for `{}`".format(
+                            pattern)
                     )
-
-            # remove any tasks that are negated with ~task-name
-            for block_pattern in task_blocklist_patterns:
-                matches = fnmatch.filter(valid_tasks, block_pattern)
-                if len(matches):
-                    requested_group_tasks = requested_group_tasks.difference(
-                        matches)
-                else:
+                group_tasks.update(matched_tasks)
+                for matched_group in matched_groups:
+                    group_tasks.update(resolve_group(matched_group))
+
+            # remove any tasks/groups that are negated with
+            # ~task-name/~group-name
+            for block_pattern in blocklist_patterns:
+                matched_tasks = fnmatch.filter(valid_tasks, block_pattern)
+                matched_groups = fnmatch.filter(valid_groups, block_pattern)
+                matched_groups = set(matched_groups).difference([group])
+                if len(matched_tasks) == 0 and len(matched_groups) == 0:
                     raise CrossbowError(
-                        "Unable to match any tasks for `{}`".format(pattern)
+                        "Unable to match any tasks/groups for `{}`".format(
+                            pattern)
                     )
+                group_tasks = group_tasks.difference(matched_tasks)
+                for matched_group in matched_groups:
+                    group_tasks = group_tasks.differece(

Review Comment:
   ```suggestion
                       group_tasks = group_tasks.difference(
   ```
   



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