Skip to content

Entity lists: Filter by labels in get_entity_lists - #385

Draft
BigRoy wants to merge 1 commit into
developfrom
enhancement/entity-lists-label-filter
Draft

BigRoy wants to merge 1 commit into
developfrom
enhancement/entity-lists-label-filter

Conversation

@BigRoy

@BigRoy BigRoy commented Nov 14, 2026

Copy link
Copy Markdown
Member

Changelog Description

Add a labels argument to get_entity_lists to filter entity lists by exact label match on the server.

Additional info

Finding a few lists by label meant fetching every list in the project and filtering on the client, 300 lists per GraphQL page. On projects with thousands of lists that takes many sequential requests, and the number of requests grows as more lists are created.

  • New keyword argument: get_entity_lists(project_name, *, list_ids=None, labels=None, active=None, fields=None).
  • On AYON server 1.8.3+ the labels are sent as a QueryFilter (label in [...]) via the filter argument of project.entityLists. Labels are unique per project and indexed, so this is a single cheap request.
  • On older servers the labels are filtered on the client, with the same results as before.
  • An empty labels iterable returns nothing, the same as an empty list_ids. list_ids is now converted to a set before the emptiness check, so an empty generator also returns nothing; before, it returned all lists.
  • _api.py regenerated with automated_api.py.

Expected to ship in ayon-python-api 1.2.29.

Testing notes:

  1. Offline: pytest tests/test_entity_lists_labels.py checks that the filter is sent to the server on 1.8.3+, that labels are filtered on the client below 1.8.3, and that empty labels send no request.
  2. Live server: pytest tests/test_review_tasks_lists_api.py -k entity_lists_by_labels runs both the server-side path and the forced client-side fallback. It covers exact match, case sensitivity, quotes, %/_ characters, unknown labels and empty input.
  3. Manual check on a local server (1.17.5) with 950 lists: looking up 2 labels took 4 GraphQL requests without the filter and 1 request with labels=. All paths returned the same lists.

Filter entity lists by exact label on server using 'filter' argument
of 'entityLists' (AYON server 1.8.3+), with client side fallback for
older servers. Empty 'labels' or 'list_ids' iterables return nothing.
client_labels = labels
fields.add("label")
else:
filters["filter"] = json.dumps({

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wonder if it actually'd make sense to also expose filters itself 🤔

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant