Skip to content

Re-pin deployment desired_worker to current model_version on serve#1024

Open
ackizilkale wants to merge 2 commits intomasterfrom
fix/serve-redeploy-binding
Open

Re-pin deployment desired_worker to current model_version on serve#1024
ackizilkale wants to merge 2 commits intomasterfrom
fix/serve-redeploy-binding

Conversation

@ackizilkale
Copy link
Copy Markdown
Contributor

When clarifai model serve reuses an existing deployment, the patch silently failed for two reasons:

  1. PatchDeployments only accepts action='overwrite' — 'merge' is rejected by the backend ("Invalid action: Unrecognized action 'merge'. Supported actions: overwrite"). The CLI used 'merge', and the failure was swallowed by except Exception: pass, so even the visibility patch this code claimed to do was never landing.

  2. Deployment.worker is the observed state (read-only on input); writes to it are silently ignored by the backend. The writable input is Deployment.desired_worker.

With deploy_latest_version=False (set in #1022 for serve deployments), the deployment is pinned to whatever desired_worker.model.model_version.id it has. When the method-signatures hash changes a new model_version and runner are created, but the deployment's desired_worker stayed on the old version_id — leaving API calls routed to a version with no live runner ("Model is still deploying...").

Switch action to 'overwrite', patch desired_worker (not worker), and surface non-success responses + exceptions as warnings instead of swallowing them. Idempotent when the version is unchanged; heals the binding when it changed.

When `clarifai model serve` reuses an existing deployment, the patch
silently failed for two reasons:

  1. PatchDeployments only accepts action='overwrite' — 'merge' is
     rejected by the backend ("Invalid action: Unrecognized action
     'merge'. Supported actions: overwrite"). The CLI used 'merge', and
     the failure was swallowed by `except Exception: pass`, so even the
     visibility patch this code claimed to do was never landing.

  2. `Deployment.worker` is the *observed* state (read-only on input);
     writes to it are silently ignored by the backend. The writable input
     is `Deployment.desired_worker`.

With deploy_latest_version=False (set in #1022 for serve deployments),
the deployment is pinned to whatever desired_worker.model.model_version.id
it has. When the method-signatures hash changes a new model_version and
runner are created, but the deployment's desired_worker stayed on the old
version_id — leaving API calls routed to a version with no live runner
("Model is still deploying...").

Switch action to 'overwrite', patch desired_worker (not worker), and
surface non-success responses + exceptions as warnings instead of
swallowing them. Idempotent when the version is unchanged; heals the
binding when it changed.
@ackizilkale ackizilkale requested a review from a team April 27, 2026 22:28
@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Health
clarifai 45%
clarifai.cli 62%
clarifai.cli.templates 67%
clarifai.cli.templates.toolkits 100%
clarifai.client 64%
clarifai.client.auth 67%
clarifai.constants 100%
clarifai.datasets 100%
clarifai.datasets.export 69%
clarifai.datasets.upload 75%
clarifai.datasets.upload.loaders 37%
clarifai.models 100%
clarifai.rag 0%
clarifai.runners 52%
clarifai.runners.models 61%
clarifai.runners.pipeline_steps 45%
clarifai.runners.pipelines 77%
clarifai.runners.utils 61%
clarifai.runners.utils.data_types 72%
clarifai.schema 100%
clarifai.urls 58%
clarifai.utils 62%
clarifai.utils.evaluation 16%
clarifai.workflows 95%
examples 64%
Summary 61% (12505 / 20572)

Minimum allowed line rate is 50%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant