Skip to content

refactor(models): migrate downstream consumers to typed NemoClient - #1277

Draft
maxdubrinsky wants to merge 2 commits into
mainfrom
aircore-876-migrate-model-consumers/md
Draft

refactor(models): migrate downstream consumers to typed NemoClient#1277
maxdubrinsky wants to merge 2 commits into
mainfrom
aircore-876-migrate-model-consumers/md

Conversation

@maxdubrinsky

Copy link
Copy Markdown
Contributor

Summary

Migrates the downstream model consumers off the Stainless-generated sdk.inference.* / sdk.models.* CRUD surface onto the typed AsyncModelsClient from the foundation landed in #993. This is the "downstream consumers" half of AIRCORE-876; the core services/core/models controllers are migrated in a separate sibling PR.

Related Issue

Linear: AIRCORE-876 (Migrate Models service to NemoClient typed HTTP client), parent epic AIRCORE-827.

Changes

  • services/platform-seed: seed_model_provider now routes through client_from_platform(sdk, AsyncModelsClient) + models.create_provider(..., body=CreateModelProviderRequest(...)) instead of sdk.inference.providers.create(...).
  • services/core/entities WorkspaceCleanup._cleanup_deployments: routes deployment listing/deletion through AsyncModelsClient.list_deployments / delete_deployment (preserving the HeartbeatMixin heartbeat calls recently added on main).
  • packages/nmp_customization_common (model entity run task + platform client) and packages/data_designer_nemo model provider: switch to the typed models client.
  • services/automodel, services/rl, services/unsloth job compilers: adopt the typed client.
  • services/guardrails model routing / config utils: adopt the typed client.
  • Adds test_models_client_migration.py focused tests for data_designer_nemo, nmp_customization_common, and automodel; updates existing suites (test_workspace_cleanup, test_platform_seed_runner, test_model_routing, test_compiler, test_model_entity, etc.) to the typed client mocking style.

The branch was rebased onto origin/main so the typed-client foundation comes from #993; the divergent in-branch foundation copy was dropped.

Type of Change

  • Code change (feature, bug fix, or refactor)

Quality Gates

  • Tests added or updated for changed behavior
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification: internal client migration, no user-visible behavior change.

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Targeted validation:

  • uv run ruff check <changed .py files> — All checks passed.
  • uv run --frozen pytest -q <affected test files> — 101 passed in 0.45s (migration tests + updated existing suites for data_designer_nemo, nmp_customization_common, automodel, core/entities workspace_cleanup, guardrails, platform-seed, rl, unsloth).
  • uv run --frozen ty check <changed packages> — 300 diagnostics, all pre-existing on origin/main (308 on main for the same set); the migration introduces no new type errors and removes 8 by replacing untyped SDK dict access with typed AsyncModelsClient calls.
  • uv run pre-commit run --files <changed files> — ruff, ruff format, ty, copyright headers, merge-conflict checks all Passed.
  • DCO audit: single commit af4f86533, Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com> matches author email.

Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 33347/42110 79.2% 64.1%
Integration Tests 19477/39910 48.8% 21.1%

The NemoClient migration rewrote fetch_model_entity to resolve models via
client_from_platform(sdk, AsyncModelsClient).get_model(...).data() instead of
sdk.models.retrieve(...). The unsloth plugin tests were not updated: they still
stubbed sdk.models.retrieve and patched client_from_platform with a files-only
mock returned for every call, so the new AsyncModelsClient call got the files
mock back, get_model() returned an unawaited AsyncMock coroutine, and
response.data() yielded that coroutine. transform_input_to_output then hit
AttributeError: 'coroutine' object has no attribute 'spec'.

Dispatch client_from_platform by client class: return a models mock (whose
get_model(...).data() yields the stub model entity) for AsyncModelsClient and
the files mock for AsyncFilesClient. Mirrors the pattern in the PR's new
test_models_client_migration.py.

Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant