Repository navigation
feat(client): Create a new entities client #583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
matthewgrossman
wants to merge
3
commits into
main
from
mgrossman/aircore-875-migrate-entities-service-to-nemoclient-typed-http-client
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/nemo_platform_plugin/src/nemo_platform_plugin/entities/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Entity Store client package. | ||
|
|
||
| Re-exports the legacy Stainless-backed :class:`EntityClient` and shared entity | ||
| types (``entities.legacy``) so existing ``from nemo_platform_plugin.entities | ||
| import ...`` imports keep working, alongside the new NemoClient-backed | ||
| :class:`EntityStoreResource` (``entities.resource``) and its low-level | ||
| :class:`EntitiesClient` (``entities.client``). | ||
| """ | ||
|
|
||
| from nemo_platform_plugin.entities.client import AsyncEntitiesClient as AsyncEntitiesClient | ||
| from nemo_platform_plugin.entities.client import EntitiesClient as EntitiesClient | ||
| from nemo_platform_plugin.entities.legacy import EntityBase as EntityBase | ||
| from nemo_platform_plugin.entities.legacy import EntityClient as EntityClient | ||
| from nemo_platform_plugin.entities.legacy import EntityClientProtocol as EntityClientProtocol | ||
| from nemo_platform_plugin.entities.legacy import EntityConflictError as EntityConflictError | ||
| from nemo_platform_plugin.entities.legacy import EntityNotFoundError as EntityNotFoundError | ||
| from nemo_platform_plugin.entities.legacy import EntityStoreError as EntityStoreError | ||
| from nemo_platform_plugin.entities.legacy import EntityT as EntityT | ||
| from nemo_platform_plugin.entities.legacy import EntityToken as EntityToken | ||
| from nemo_platform_plugin.entities.legacy import EntityTypeDefault as EntityTypeDefault | ||
| from nemo_platform_plugin.entities.legacy import EntityTypeLike as EntityTypeLike | ||
| from nemo_platform_plugin.entities.legacy import EntityValidationError as EntityValidationError | ||
| from nemo_platform_plugin.entities.legacy import ListResponse as ListResponse | ||
| from nemo_platform_plugin.entities.legacy import PaginationInfo as PaginationInfo | ||
| from nemo_platform_plugin.entities.legacy import _convert_filter_obj_to_filter_str as _convert_filter_obj_to_filter_str | ||
| from nemo_platform_plugin.entities.legacy import _convert_sort_to_api_sort as _convert_sort_to_api_sort | ||
| from nemo_platform_plugin.entities.legacy import _get_entity_type as _get_entity_type | ||
| from nemo_platform_plugin.entities.legacy import parse_qualified_name as parse_qualified_name | ||
| from nemo_platform_plugin.entities.resource import EntityStoreResource as EntityStoreResource |
31 changes: 31 additions & 0 deletions
31
packages/nemo_platform_plugin/src/nemo_platform_plugin/entities/client.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Low-level typed HTTP clients for the Entity Store service. | ||
|
|
||
| Wraps the endpoint functions from ``entities.endpoints`` as direct methods via | ||
| the ``method()`` descriptor, following the files-service ``FilesClient`` pattern. | ||
| These are the transport layer; the ergonomic, entity-model-aware wrapper is | ||
| ``EntityStoreResource`` in ``entities.resource``. | ||
| """ | ||
|
|
||
| from nemo_platform_plugin.client.client import AsyncNemoClient, NemoClient | ||
| from nemo_platform_plugin.client.method import method | ||
| from nemo_platform_plugin.entities import endpoints | ||
|
|
||
|
|
||
| class _EntitiesMethods: | ||
| create_entity = method(endpoints.create_entity) | ||
| list_entities = method(endpoints.list_entities) | ||
| get_entity_by_name = method(endpoints.get_entity_by_name) | ||
| get_entity_by_id = method(endpoints.get_entity_by_id) | ||
| update_entity_by_name = method(endpoints.update_entity_by_name) | ||
| delete_entity_by_name = method(endpoints.delete_entity_by_name) | ||
|
|
||
|
|
||
| class EntitiesClient(_EntitiesMethods, NemoClient): | ||
| """Sync low-level client for the Entity Store API.""" | ||
|
|
||
|
|
||
| class AsyncEntitiesClient(_EntitiesMethods, AsyncNemoClient): | ||
| """Async low-level client for the Entity Store API.""" |
67 changes: 67 additions & 0 deletions
67
packages/nemo_platform_plugin/src/nemo_platform_plugin/entities/endpoints.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Typed endpoint definitions for the Entity Store service (generic routes). | ||
|
|
||
| Single source of truth for the HTTP contract of the generic entity routes. | ||
| Projects and workspaces routers are out of scope — the entity client only | ||
| uses the generic ``/entities`` routes. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from abc import abstractmethod | ||
|
|
||
| from nemo_platform_plugin.client.endpoint import delete, get, post, put | ||
| from nemo_platform_plugin.client.types import Paginated | ||
| from nemo_platform_plugin.entities.types import ( | ||
| DeleteResponse, | ||
| EntityCreateInput, | ||
| EntityResponse, | ||
| EntityUpdate, | ||
| ListEntitiesQueryParams, | ||
| ParentQueryParams, | ||
| ) | ||
|
|
||
|
|
||
| @post("/apis/entities/v2/workspaces/{workspace}/entities/{entity_type}") | ||
| @abstractmethod | ||
| def create_entity(*, workspace: str | None = None, entity_type: str, body: EntityCreateInput) -> EntityResponse: ... | ||
|
|
||
|
|
||
| @get("/apis/entities/v2/workspaces/{workspace}/entities/{entity_type}") | ||
| @abstractmethod | ||
| def list_entities( | ||
| *, workspace: str | None = None, entity_type: str, query_params: ListEntitiesQueryParams | None = None | ||
| ) -> Paginated[EntityResponse]: ... | ||
|
|
||
|
|
||
| @get("/apis/entities/v2/workspaces/{workspace}/entities/{entity_type}/{name}") | ||
| @abstractmethod | ||
| def get_entity_by_name( | ||
| *, workspace: str | None = None, entity_type: str, name: str, query_params: ParentQueryParams | None = None | ||
| ) -> EntityResponse: ... | ||
|
|
||
|
|
||
| @get("/apis/entities/v2/entities/{id}") | ||
| @abstractmethod | ||
| def get_entity_by_id(*, id: str) -> EntityResponse: ... | ||
|
|
||
|
|
||
| @put("/apis/entities/v2/workspaces/{workspace}/entities/{entity_type}/{name}") | ||
| @abstractmethod | ||
| def update_entity_by_name( | ||
| *, | ||
| workspace: str | None = None, | ||
| entity_type: str, | ||
| name: str, | ||
| body: EntityUpdate, | ||
| query_params: ParentQueryParams | None = None, | ||
| ) -> EntityResponse: ... | ||
|
|
||
|
|
||
| @delete("/apis/entities/v2/workspaces/{workspace}/entities/{entity_type}/{name}") | ||
| @abstractmethod | ||
| def delete_entity_by_name( | ||
| *, workspace: str | None = None, entity_type: str, name: str, query_params: ParentQueryParams | None = None | ||
| ) -> DeleteResponse: ... |
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Don’t default-retry write requests without an idempotency guard.
This policy is now the default, and the retry loop replays request bodies. 502/503/504/429 can occur after backend processing, so POST/PATCH/PUT may be duplicated or surface false conflicts. Gate default retries to safe/idempotent methods, or require an
Idempotency-Keybefore retrying writes.🤖 Prompt for AI Agents