fix(models): model deployment wait for IGW ready - #940
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe models client now waits for OpenAI gateway model readiness through synchronous and asynchronous polling. Container-agent deployment invokes the agent only after the expected model is available. ChangesIGW model readiness
Sequence Diagram(s)sequenceDiagram
participant DeploymentHelper
participant ModelsResource
participant OpenAIGatewayModels
participant AgentsGateway
DeploymentHelper->>ModelsResource: wait_for_openai_model(model_name, workspace)
ModelsResource->>OpenAIGatewayModels: poll models.get(route_name)
OpenAIGatewayModels-->>ModelsResource: model response or NotFoundError
ModelsResource-->>DeploymentHelper: ready model or TimeoutError
DeploymentHelper->>AgentsGateway: invoke agent
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@services/core/models/src/nmp/core/models/controllers/provider_reconciler.py`:
- Around line 1048-1055: Update the autoprovisioned VirtualModel deletion flow
around _virtual_model_changed_after_snapshot and delete() to pass the resource
version, etag, or equivalent version captured during listing as a server-side
delete precondition. Preserve the existing snapshot check, but ensure delete is
rejected when the VirtualModel changes between listing and deletion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c0ac6f28-197c-497a-b5de-e4c71bed233b
📒 Files selected for processing (6)
e2e/agents_deploy_helpers.pypackages/nmp_testing/src/nmp/testing/__init__.pypackages/nmp_testing/src/nmp/testing/utils.pypackages/nmp_testing/tests/unit/test_utils.pyservices/core/models/src/nmp/core/models/controllers/provider_reconciler.pyservices/core/models/tests/unit/controllers/test_provider_reconciler.py
|
36d52c9 to
b7c37ca
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/models/src/models/resources.py`:
- Around line 322-330: Bound the retry delays by the remaining timeout in both
polling methods: update the synchronous loop at
packages/models/src/models/resources.py#L322-L330 to sleep for the smaller of
poll_interval and the remaining timeout, and apply the equivalent min-bound to
asyncio.sleep at packages/models/src/models/resources.py#L764-L772. Add a test
using a nonzero poll interval that verifies neither method waits beyond its
configured timeout.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 07547025-32fc-4059-b61d-a8d91d810313
⛔ Files ignored due to path filters (1)
sdk/python/nemo-platform/src/nemo_platform/models/resources.pyis excluded by!sdk/**
📒 Files selected for processing (5)
e2e/agents_deploy_helpers.pypackages/models/src/models/resources.pypackages/models/tests/test_client.pyservices/core/models/src/nmp/core/models/controllers/provider_reconciler.pyservices/core/models/tests/unit/controllers/test_provider_reconciler.py
🚧 Files skipped from review as they are similar to previous changes (1)
- services/core/models/tests/unit/controllers/test_provider_reconciler.py
b7c37ca to
23ec486
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@services/core/models/tests/unit/controllers/test_provider_reconciler.py`:
- Around line 1912-1926: Update the VirtualModel test helper and its callers to
distinguish an omitted updated_at from an explicit None using an unset sentinel,
while preserving the updated_at or created_at or now precedence. Expand the
relevant tests around the reconciler cases to cover created_at < snapshot <
updated_at and explicit updated_at=None with created_at both before and after
the snapshot, ensuring regressions in updated_at precedence or fallback are
detected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f67a1c41-e15f-4c22-9318-9d682341482b
⛔ Files ignored due to path filters (1)
sdk/python/nemo-platform/src/nemo_platform/models/resources.pyis excluded by!sdk/**
📒 Files selected for processing (5)
e2e/agents_deploy_helpers.pypackages/models/src/models/resources.pypackages/models/tests/test_client.pyservices/core/models/src/nmp/core/models/controllers/provider_reconciler.pyservices/core/models/tests/unit/controllers/test_provider_reconciler.py
🚧 Files skipped from review as they are similar to previous changes (4)
- e2e/agents_deploy_helpers.py
- packages/models/tests/test_client.py
- services/core/models/src/nmp/core/models/controllers/provider_reconciler.py
- packages/models/src/models/resources.py
23ec486 to
47b1040
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/models/src/models/resources.py (1)
57-84: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winPoll loops only tolerate
NotFoundError/id-mismatch, unlikewait_for_gateway.
_poll_until_ready/_async_poll_until_readycatch only_PollPendingandNotFoundError; any other exception (e.g. a transientAPIStatusErrorsuch as a 503 during gateway warm-up, once SDK auto-retries are exhausted) aborts the poll immediately instead of retrying for the remainingtimeout.wait_for_gatewayin this same file deliberately catches broadExceptionfor this exact "gateway isn't ready yet" scenario. Given this PR's goal is to close a deployment race condition, a stray transient error here would just reintroduce flakiness at the model-readiness step instead of the provider-readiness step.nemo_platform's SDK auto-retries connection errors/408/409/429/5xx twice by default, so this is a residual-risk gap rather than a guaranteed failure.
♻️ Broaden retry tolerance to match `wait_for_gateway`
while time.time() - start_time < timeout: try: return attempt() except _PollPending as exc: last_error = exc.reason - except NotFoundError as exc: + except (NotFoundError, APIStatusError, APIConnectionError) as exc: last_error = excApply the same change in
_async_poll_until_ready. ConfirmAPIStatusError/APIConnectionErrorare the correct base classes exported fromnemo_platformfor this SDK version.Also applies to: 97-114
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/models/src/models/resources.py` around lines 57 - 84, Broaden exception handling in both _poll_until_ready and _async_poll_until_ready to retry transient gateway-readiness failures, including the appropriate nemo_platform API status and connection error base classes, instead of aborting immediately. Match wait_for_gateway’s established broad retry behavior while preserving _PollPending/NotFoundError handling, timeout tracking, and final timeout_message construction; verify the imported exception classes are supported by this SDK version.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/models/src/models/resources.py`:
- Around line 57-84: Broaden exception handling in both _poll_until_ready and
_async_poll_until_ready to retry transient gateway-readiness failures, including
the appropriate nemo_platform API status and connection error base classes,
instead of aborting immediately. Match wait_for_gateway’s established broad
retry behavior while preserving _PollPending/NotFoundError handling, timeout
tracking, and final timeout_message construction; verify the imported exception
classes are supported by this SDK version.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 70057f11-5b68-49cd-a344-ba40c5e40454
⛔ Files ignored due to path filters (1)
sdk/python/nemo-platform/src/nemo_platform/models/resources.pyis excluded by!sdk/**
📒 Files selected for processing (3)
e2e/agents_deploy_helpers.pypackages/models/src/models/resources.pypackages/models/tests/test_client.py
47b1040 to
d6c44a7
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/models/tests/test_client.py (1)
511-546: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAsync coverage lags sync. No async test for mismatched
id(the_PollPendingpath) or workspace-qualified names. Cheap to mirrortest_wait_for_openai_model_retries_unexpected_model_idwith anAsyncMock.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/models/tests/test_client.py` around lines 511 - 546, Extend the async wait_for_openai_model tests with AsyncMock coverage for the _PollPending path when the returned model id does not match, mirroring test_wait_for_openai_model_retries_unexpected_model_id. Also add an async case using a workspace-qualified model name, verifying the expected workspace/name arguments and retry behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/models/tests/test_client.py`:
- Around line 511-546: Extend the async wait_for_openai_model tests with
AsyncMock coverage for the _PollPending path when the returned model id does not
match, mirroring test_wait_for_openai_model_retries_unexpected_model_id. Also
add an async case using a workspace-qualified model name, verifying the expected
workspace/name arguments and retry behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f91c640e-696f-47f2-bd0a-2b60a6741f47
⛔ Files ignored due to path filters (1)
sdk/python/nemo-platform/src/nemo_platform/models/resources.pyis excluded by!sdk/**
📒 Files selected for processing (3)
e2e/agents_deploy_helpers.pypackages/models/src/models/resources.pypackages/models/tests/test_client.py
Signed-off-by: Ryan S <267728323+ironcommit@users.noreply.github.com>
d6c44a7 to
a6bd306
Compare
Summary by CodeRabbit
New Features
Bug Fixes