Skip to content

Add tag filtering support for automations #18288

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

Merged
merged 2 commits into from
Jun 16, 2025

Conversation

chrisguidry
Copy link
Collaborator

Summary

This implements the next part of #16771 by adding comprehensive tag filtering capabilities for automations, following the same pattern used by other entities in Prefect (flows, deployments, etc.).

Changes

  • Add tags field to Automation database model with JSON column and migrations
  • Update automation schemas (client and server) to include tags field
  • Implement AutomationFilterTags with all_, any_, and is_null_ filter options
  • Add comprehensive test coverage for all filtering scenarios
  • Ensure API compatibility with existing automation functionality

Filtering Options

The filtering supports:

  • all_: Return automations that have ALL specified tags (superset match)
  • any_: Return automations that have ANY of the specified tags
  • is_null_: Return automations with no tags (true) or with tags (false)

Closes #16771

🤖 Generated with Claude Code

chrisguidry and others added 2 commits June 16, 2025 09:34
This implements the next part of #16771 by adding comprehensive tag filtering
capabilities for automations, following the same pattern used by other entities
in Prefect (flows, deployments, etc.).

Changes:
- Add tags field to Automation database model with JSON column and migrations
- Update automation schemas (client and server) to include tags field
- Implement AutomationFilterTags with all_, any_, and is_null_ filter options
- Add comprehensive test coverage for all filtering scenarios
- Ensure API compatibility with existing automation functionality

The filtering supports:
- all_: Return automations that have ALL specified tags (superset match)
- any_: Return automations that have ANY of the specified tags
- is_null_: Return automations with no tags (true) or with tags (false)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove duplicate migration files that conflicted with existing migrations
- Fix duplicate tags field definition in client automation schema
- Existing migrations aa1234567890 (PostgreSQL) and bb2345678901 (SQLite) already handle tags column

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@chrisguidry chrisguidry force-pushed the add-automation-tag-filtering branch from adaf06b to a28a07d Compare June 16, 2025 13:43
Copy link

codspeed-hq bot commented Jun 16, 2025

CodSpeed Performance Report

Merging #18288 will not alter performance

Comparing add-automation-tag-filtering (a28a07d) with main (5486631)

Summary

✅ 2 untouched benchmarks

Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

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

lgtm!

@@ -416,7 +416,7 @@ class AutomationCore(PrefectBaseModel, extra="ignore"): # type: ignore[call-arg
enabled: bool = Field(
default=True, description="Whether this automation will be evaluated"
)
tags: list[str] = Field(
tags: List[str] = Field(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tags: List[str] = Field(
tags: list[str] = Field(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahh, the rest of that model is using the typing module types, I'll just change them all

Copy link
Collaborator

Choose a reason for hiding this comment

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

ohh my bad. I didn't notice that, either way 🙇

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll send a followup PR, actually, just to do them all together

@chrisguidry chrisguidry merged commit a6bfe20 into main Jun 16, 2025
52 checks passed
@chrisguidry chrisguidry deleted the add-automation-tag-filtering branch June 16, 2025 15:28
@chrisguidry chrisguidry restored the add-automation-tag-filtering branch June 16, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for tags to Automation
2 participants