feat: expose label and property discovery for major resource types #1032
Claude finished @drake-nominal's task in 1m 3s —— View job
---
Code review
paginate_grpc, _workspace_rid_for_search)Overview: This only adds API; nothing existing changes. The public surface fits the rest of the client:
resource_type and property_key are positional and workspace is keyword-only.workspace goes through the existing WorkspaceSearchT resolution.paginate_grpc is reused, so a failure on a later page raises a translated error instead of returning partial results.MetadataResourceType selector is the right call: callers don't need to know which resource types are indexed. The page-500+ and later-page-failure tests cover the behavior that matters most.I found no correctness bugs or breaking changes. The inline comments cover:
1. Docstrings: the three public methods have no Returns:/Raises: blocks, and "retrieving every page" describes the implementation.
2. Structure: the indexed-vs-dedicated dispatch is repeated in all three _list_* functions. I suggest one table covering all 8 enum members.
3. Docs: feature prose sits above the whole nominal.core autodoc page, while the other reference pages are bare stubs.
4. Tests: two tests have no docstring, and two assertions can never fail.
I couldn't confirm statically that workspaces=[] means "all permitted workspaces" on the indexed backend.
✅ Devin Review: No Issues Found
Devin Review analyzed this PR and found no bugs or issues to report.
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/nominal-io/nominal-client/pull/1032" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
<!-- devin-review-summary -->
Missing Returns: (and Raises:) block. Other public methods in client.py document both. The same gap is in list_property_keys and list_property_values. Two other notes:
resolve_workspace, so NominalPermissionDeniedError can come from that lookup or from a later page. Returns:
Distinct labels, sorted alphabetically.
Raises:
NominalConfigError: If `workspace` is DEFAULT/None and no default workspace is configured.
"""
The indexed-vs-dedicated split is decided in three places. Each of _list_labels, _list_property_keys, and _list_property_values repeats if resource_type in _INDEXED_RESOURCE_TYPES, then the same paginate → set → sort block. _get_dedicated_metadata also has a case _: raise ValueError, which only stays unreachable because of that membership check.
Suggestion: handle all 8 members in one table. Map indexed types to their proto enum, and dedicated types to a ClientsBunch -> service accessor (lambda c: c.notebook, …). Then each _list_* does one lookup and the fallthrough ValueError goes away. If someone adds a 9th MetadataResourceType member without a mapping, it fails at the table instead of in a match default. A small _collect_sorted(rpc, request_factory, extract) helper would also remove the three copies of the paginate+sort block.
Every other page under docs/src/reference/ is a bare ::: module autodoc stub. This change puts feature-specific prose above the whole nominal.core reference, so the core API page now starts with one niche feature. The backend-visibility and string-only-values notes fit better in the MetadataResourceType / method docstrings, where mkdocstrings will render them next to the API anyway. If a narrative guide is wanted, put it in a separate page and link to it from here.
test_default_workspace_is_scoped_and_all_searches_every_permitted_workspace and test_later_page_failure_raises_nominal_error_instead_of_returning_partial_labels have no one-line docstring. The other tests in this file have one, and it's the repo's test convention.
This asserts that an RPC the implementation never references wasn't called. It can't fail, so it tests nothing. The same goes for assert all(type(value) is str ...) on L115: the equality check on L114 already pins the exact values, and protobuf string fields are always str. Suggest dropping both.
Why not combine these two methods (keys+values) into a single mapping?
The backend doesn't actually return "these keys map to these values" -> I'd love to return some dict[str, set[str]], but the only way to reconstruct that today would be really expensive in terms of api requests needed. What we have instead are inventories of "these are all the unique keys" and "these are all the unique values" given that key".
If a user needs to do this, they could just call:
{key: client.list_property_values(key) for key in client.list_property_keys()}
but ideally we have a batch version of this or otherwise a direct version of this in the backend before we port that ergonomic improvement to the SDK.
stefanv
drake-nominal
Adds label and property discovery for major resource types, with workspace filtering and pagination.
Exports the shared
PropertyValue(str | float) type for property-value results. The discovery routes currently enumerate string values; numeric property keys are included.Validation:
just verify(1,441 tests), Python 3.11 typing, and strict documentation build. Coverage includes multi-page discovery and workspace scoping. Live backend tests were not run.