Skip to content

Add Tag field to Run table and controller#140

Draft
amathuria wants to merge 4 commits into
ceph:mainfrom
amathuria:wip-amat-add-metadata-tag-74166
Draft

Add Tag field to Run table and controller#140
amathuria wants to merge 4 commits into
ceph:mainfrom
amathuria:wip-amat-add-metadata-tag-74166

Conversation

@amathuria
Copy link
Copy Markdown
Contributor

No description provided.

Add an optional metadata string tag to runs, allowing users to associate
a tag with a collection of runs.

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>
Support tag in run creation (POST) and query-param filtering (?tag=foo).

Add TagsController/TagController for path-based access (/runs/tag/foo/)
and wire tag into all existing filter controllers for composable queries.

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>
Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>
@amathuria amathuria requested a review from zmc March 13, 2026 18:33
@amathuria
Copy link
Copy Markdown
Contributor Author

@zmc There's no PUT/PATCH on RunController - it only has GET and DELETE. So if we want to stick to the current workflow, tags can only be added at run creation.
If we want the option to UPDATE a Run, you can let me know - keeping the PR in draft state till then.

@kshtsk
Copy link
Copy Markdown
Contributor

kshtsk commented Mar 14, 2026

Do I understand correctly this only implements a single tag? I would suggest to implement tags, so a run can have several tags.

@zmc
Copy link
Copy Markdown
Member

zmc commented Mar 17, 2026

@amathuria Thanks!
I think we may as well add a PUT at this point. I think we ought to start moving some of the items we duplicate across Jobs into the Run object, and we'll need to be able to modify them directly to do that. Further in the future we could choose to implement PATCH, but the semantics are quite different so that's probably best left to a dedicated effort.
Diffs like this make me look forward to us moving away from the path-based Run routing we use currently :)
Thinking about @kshtsk's comment about multiple tags, and I think maybe we ought to just go ahead and store an array of tags in each Run row, even if the main use-case is only one tag per run. What do you think?

@batrick
Copy link
Copy Markdown
Member

batrick commented Mar 24, 2026

Thinking about @kshtsk's comment about multiple tags, and I think maybe we ought to just go ahead and store an array of tags in each Run row, even if the main use-case is only one tag per run. What do you think?

Actually, this was a gap in my feature request. I think multiple tags is best. Many thanks to @kshtsk thinking of that.

I've updated the ticket: https://tracker.ceph.com/issues/74166

@amathuria
Copy link
Copy Markdown
Contributor Author

@amathuria Thanks! I think we may as well add a PUT at this point. I think we ought to start moving some of the items we duplicate across Jobs into the Run object, and we'll need to be able to modify them directly to do that. Further in the future we could choose to implement PATCH, but the semantics are quite different so that's probably best left to a dedicated effort. Diffs like this make me look forward to us moving away from the path-based Run routing we use currently :) Thinking about @kshtsk's comment about multiple tags, and I think maybe we ought to just go ahead and store an array of tags in each Run row, even if the main use-case is only one tag per run. What do you think?

@zmc @batrick multiple tags makes sense to me! I'll update the PR soon.
Thanks @kshtsk!

Replace Run.tag with Run.tags (JSONType list) and add PUT /runs/<name>/
to update tags.
Update tag filtering/listing to work with tag arrays,
including comma-separated ?tag=
We have to add a cast to UnicodeText for filtering to avoid JSONType bind-param JSON encoding.

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>
@amathuria
Copy link
Copy Markdown
Contributor Author

@kshtsk @zmc @batrick I have added the multi-tag support and PUT to RunController.
Let me know what you think.
The CI is failing due to a new unit test I have added failing - I'm looking into this.


def latest_runs(fields=None, count=conf.default_latest_runs_count, page=1):
query = Run.query.order_by(Run.posted.desc())
def latest_runs(fields=None, count=conf.default_latest_runs_count, page=1, tag=None):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't we want tags=None?

# JSON-encoded unless we compare as plain text:
tags_text = cast(Run.tags, UnicodeText)
for t in tag.split(','):
query = query.filter(tags_text.contains('"%s"' % t.strip()))
Copy link
Copy Markdown
Contributor

@kshtsk kshtsk Apr 8, 2026

Choose a reason for hiding this comment

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

(minor)

for tag in (t.strip() for t in tags.split(',')):
    . . . filter(tags_text.contains(tag))

so if tags_text is json "[abc,xyz]" the contains('bc') matches?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If tags_text is comma separated text wouldn't it be less effective to use:

run_tags = (t.strip() for t in tags_text.split(','))
for tag in (t.strip() for t in tags.split(',')):
   query = query.filter(tag in run_tags)

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.

4 participants