Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: get rid of hardcoded attribute filtering in find_tasks #225

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

bhearsum
Copy link
Contributor

No description provided.

@bhearsum bhearsum requested a review from a team as a code owner December 13, 2024 21:08
Copy link
Contributor

@hneiva hneiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - with a minor/optional improvement recommendation

Copy link
Contributor

@ahal ahal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes to use attrmatch

@@ -25,8 +25,12 @@ def make_firefoxci_artifact_tasks(config, tasks):
for task in tasks:
# Format: { <task id>: [<artifact name>]}
tasks_to_create = defaultdict(list)
include_attrs = task.pop("include-attrs", {})
exclude_attrs = task.pop("exclude-attrs", {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done in a follow-up, but it might be nice to group include-attrs/exclude-attrs with individual index paths. E.g:

from-decision-indices:
    - path: <index path>
      include-attrs: [<attrs>]
      exclude-attrs: [<attrs>]

This would allow a bit more flexibility.


for attr, values in dict(exclude_attrs).items():
if any([attributes.get(attr, "").startswith(v) for v in values]):
skip = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it should be using attrmatch:
https://github.com/taskcluster/taskgraph/blob/main/src/taskgraph/util/attributes.py#L9

But I guess that wouldn't support the exclude case? It might be nice for attrmatch to support excluding attributes as well (maybe by prepending ! to the name or something).

But this is also follow-up territory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you could call attrmatch twice. Once for include-attrs, and a second time for exclude-attrs but then negate the return value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about attrmatch. Indeed, let's use that instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to this has highlighted that it also may be nice to support prefixes natively in attrmatch; for now I've wrapped that portion in a callable that attrmatch can use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed the startswith, good call

@bhearsum bhearsum merged commit bed883e into mozilla-releng:main Dec 16, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants