Skip to content

Add labels to create run /list runs api.#7430

Merged
afbrock merged 1 commit into
mainfrom
adam/labels-phase-one
Jun 9, 2026
Merged

Add labels to create run /list runs api.#7430
afbrock merged 1 commit into
mainfrom
adam/labels-phase-one

Conversation

@afbrock

@afbrock afbrock commented May 27, 2026

Copy link
Copy Markdown
Contributor

Tracking issue

https://linear.app/unionai/issue/PRD-422/be-listruns-should-include-run-labels

Why are the changes needed?

These changes add labels to the list runs api. This is done by adding effectively a duplication of the labels that are currently in runspec into the top level run object, as list runs only returns a repeated run object instead of the full
run details object (which is the right thing to do.) The other change is that I added operators specific to (and important for) filtering key value pairs into the common list filters enum. A user can add flyte specific key value pair labels in order to organize and filter their runs by adding filters where the field is the concatenation of 'labels." and the key name.

How was this patch tested?

Along with
flyteorg/flyte-sdk#1140
and https://github.com/unionai/cloud/pull/16161
running in devbox, runs can be created and filtered based on label data that is persisted along with run information.

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Docs link

@afbrock afbrock force-pushed the adam/labels-phase-one branch 2 times, most recently from 6a5f47c to faff232 Compare June 1, 2026 21:01
@afbrock afbrock requested a review from EngHabu June 2, 2026 18:05
@afbrock afbrock force-pushed the adam/labels-phase-one branch 4 times, most recently from 3c91886 to a9c32ab Compare June 3, 2026 23:15
Comment thread flyteidl2/workflow/run_service.proto Outdated
Comment thread flyteidl2/workflow/run_service.proto Outdated
Comment thread flyteidl2/workflow/run_definition.proto Outdated
// execution time, also configurable via settings). On create, labels supplied on
// the request are merged with settings/RunSpec labels, with request labels taking
// precedence, and the merged set is stored here and on the RunSpec.
map<string, string> labels = 2;

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.

Why do we need it here? RunDetails message has the RunSpec which has Labels

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It needs to be in this one because a list request returns Run not RunDetail.

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.

ah I see... is there a Label type to use here 👇🏽 ?

@afbrock afbrock force-pushed the adam/labels-phase-one branch 3 times, most recently from 08277db to c206519 Compare June 5, 2026 20:17
Comment thread flyteidl2/workflow/run_definition.proto Outdated
Comment on lines +519 to +531
enum LabelSelectorOperator {
LABEL_SELECTOR_OPERATOR_UNSPECIFIED = 0;
LABEL_SELECTOR_OPERATOR_IN = 1;
LABEL_SELECTOR_OPERATOR_NOT_IN = 2;
LABEL_SELECTOR_OPERATOR_EXISTS = 3;
LABEL_SELECTOR_OPERATOR_DOES_NOT_EXIST = 4;
}

message LabelSelectorRequirement {
string key = 1;
LabelSelectorOperator operator = 2;
repeated string values = 3;
}

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no, we can't because we are matching key value pairs, and so the selector can express something like the key 'team' exists, or the key 'team' has values in 'infra' 'frontend' or 'ml'
the operators seem similar, but the requirements are really different than common.list.filters.

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.

I get that label selector semantics are different because they operate on the labels map, not directly on a top-level field.

But since Flyte runs are already filtered through ListRequest.filters, I’m wondering if labels should still be modeled inside the same filtering abstraction.

Example query:

status = SUCCEEDED
created_by = praful
label team in (infra, frontend, ml)
label env exists

With separate LabelSelectorRequirement, clients now need to split this into two APIs:

filters[]:
status = SUCCEEDED
created_by = praful

label_selectors[]:
team in (infra, frontend, ml)
env exists

Could we instead model this as one filter system, e.g.

filters[]:
status EQUAL SUCCEEDED
created_by EQUAL praful
labels.team VALUE_IN [infra, frontend, ml]
labels.env EXISTS

or add a filter target/scope like FIELD vs LABEL?

That keeps ListRequest as the single query abstraction while still preserving label-specific semantics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, yeah I like that - let me double check that it works impl wise. I do like the idea of just using common list but i couldnt see how it could work. the dot separated labels key makes sense.

@pmahindrakar-oss pmahindrakar-oss left a comment

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.

Can we use the existing ListRequest filter instead of introducing a parallel label selector filtering and the comparision parameter around those

// the request are merged with settings/RunSpec labels, with request labels taking
// precedence, and the merged set is stored here and on the RunSpec.
// It is part of Run so that it gets returned in a list request.
map<string, string> labels = 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we use Label as type here?

Labels labels = 1;

Comment thread flyteidl2/workflow/run_definition.proto Outdated
Comment on lines +512 to +516
// ALL of these key=value pairs must be present (AND semantics).
map<string, string> match_labels = 1;

// Set-based requirements — reserved for future use.
repeated LabelSelectorRequirement match_expressions = 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we decided to add this, should we add buf.validate here to limit the max length? We can follow the limit set in Kubernetes

https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

@afbrock afbrock force-pushed the adam/labels-phase-one branch from c206519 to eb16c67 Compare June 8, 2026 17:33
Signed-off-by: Adam Brock <adam@union.ai>
@afbrock afbrock force-pushed the adam/labels-phase-one branch from 665c740 to 458a72a Compare June 9, 2026 19:29
@afbrock afbrock merged commit 737136b into main Jun 9, 2026
22 checks passed
@afbrock afbrock deleted the adam/labels-phase-one branch June 9, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants