[Runs] Filter ListRuns by run label
flyte.remote.Run.listall(with_labels=...) and with_label_keys=... send labels.<key> filters, but the runs service rejects them in Flyte 2 OSS:
ConnectError: failed to convert filters: invalid filter field: labels.example.com/job-id
ConvertProtoFilters only accepts fields from the column allow-list (runs/repository/impl/filters.go), and a run's labels are stored inside the serialized RunSpec in run_spec (runs/repository/models/action.go), so there is nothing to filter on.
We tag every run with labels that group runs launched together (a job id) and find them again to await or abort them. flyteadmin (Flyte 1) supports this through execution_tag.key / execution_tag.value filters.
Proposal: store run labels in a queryable form, e.g. a JSONB column on the root action (or a separate tags table), and accept labels.<key> in ListRuns filters with EQUAL and EXISTS, which is what the SDK already sends. Several label filters AND together like the other filters.
Open question: is JSONB acceptable for the runs store, or would you prefer a tags table like flyteadmin's execution_tags?
We're happy to implement this once the direction is agreed.
It seems likely the SDK already sends the proposed labels.<key> filters, with multiple label filters combined using AND; the supplied sources don’t establish whether JSONB or a tags table is preferred or supported by the OSS runs store. So I can confirm the SDK-side expectation, but not recommend a storage design from these sources. Run listing and label filters
Would you like me to help draft a response to the issue or compare the two storage options?
Sources:
This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not.
Mention @herald to ask follow-up questions. See runllm.com for more!
ListRuns also leaves Run.labels empty (convertRunToProto in runs/service/run_service.go sets only Action), although the field exists in the proto and RunDetails returns the labels. A client that lists runs and groups them by label has to fetch every run's details instead. Once labels are stored in a queryable form as proposed above, could ListRuns also return them on each run? We'd include that in the same change.
JSONB sounds good to me. Would you like to contribute?