Commit c8ff4e7
authored
feat(models): add typed NemoClient models foundation (#993)
* feat(models): add typed NemoClient models foundation
Introduces the typed Models service client that the AIRCORE-876 consumer
migration will build on: request/response DTOs (types), PreparedRequest
endpoint builders (endpoints), and the sync/async ModelsClient surface
(client).
Purely additive: no existing code imports it yet, so it changes no runtime
behavior and carries zero risk to current consumers. Also carries the
method() descriptor fix that this client requires -- class-level attribute
access now resolves without invoking the wrapped callable, so
Mock(spec=ModelsClient) and other introspection no longer break -- plus a
response docstring note on distinguishing 202/204 deletes.
The consumer repoint, the packages/models resources rewrite, and the
vendored SDK sync land separately as the breaking, coupled steps. Covered
by endpoint-builder, client-surface, and descriptor tests.
Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
* fix(models): async-mockable client, non-stale delete status, guarded provider id
Address review findings on the typed Models client foundation:
- method() class-level access returns a per-owning-class callable stub
(async def for async clients, def for sync) instead of the raw
descriptor, so unittest.mock classifies async endpoints as AsyncMock.
Previously Mock(spec=AsyncModelsClient).create_model was a sync
MagicMock and could not be awaited, and create_autospec yielded
non-callable stubs -- defeating the typed async client's purpose.
- delete_deployment appends a DELETING entry to status_history so the
client (which reads status_history[-1] as current) no longer sees a
stale status after a delete request.
- get_provider_route_openai_url_for_deployment guards a model_provider_id
that lacks the workspace/ prefix with a clear ValueError instead of an
opaque unpack crash.
Adds regression tests for all three.
Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
* test(models): use top-level imports instead of dynamic __import__
Replace two call-time __import__("...types", fromlist=[...]) lookups in
the endpoint tests with normal names added to the existing top-level
import block (CreateModelAdapterRequest, UpdateModelDeploymentConfigRequest).
Addresses a CodeRabbit maintainability nit on PR #993.
Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
* fix(models): ruff-format client.py and suppress class-level ty errors
CI Lint all caught two issues from the earlier commits:
- ruff format collapses the malformed-model_provider_id message onto one
line in client.py.
- ty reports call-non-callable / invalid-argument-type on the new
class-level-access tests: EndpointMethod.__get__(obj=None) is typed as
the descriptor because the overload cannot distinguish the sync vs async
owning class, so ty cannot see the callable stub returned at runtime.
The three tests deliberately exercise that runtime stub, so they carry
targeted ty: ignore suppressions with an explanatory note.
Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
---------
Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>1 parent 725ad48 commit c8ff4e7
10 files changed
Lines changed: 3298 additions & 1 deletion
File tree
- packages/nemo_platform_plugin
- src/nemo_platform_plugin
- client
- models
- tests
- client
- models
- services/core/models
- src/nmp/core/models/api/service
- tests/unit
Lines changed: 77 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
74 | 83 | | |
75 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
76 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
77 | 146 | | |
78 | 147 | | |
79 | 148 | | |
80 | 149 | | |
81 | 150 | | |
82 | 151 | | |
83 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
84 | 160 | | |
85 | 161 | | |
86 | 162 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| |||
0 commit comments