Skip to content

[azure-ai-ml] Fix deployment_templates.get(name) resolving latest version (Bug 5402671)#47975

Merged
swarupecenits merged 2 commits into
Azure:mainfrom
swarupecenits:fix/deployment-template-get-latest-version
Jul 10, 2026
Merged

[azure-ai-ml] Fix deployment_templates.get(name) resolving latest version (Bug 5402671)#47975
swarupecenits merged 2 commits into
Azure:mainfrom
swarupecenits:fix/deployment-template-get-latest-version

Conversation

@swarupecenits

Copy link
Copy Markdown
Member

Notes

  • Fixes internal bug #5402671: deployment_templates.get(name) with no version failed with DeploymentTemplate {name}:latest not found (404), and there was no way to resolve a labels/latest reference.
  • Root cause: get() did version = version or "latest" and sent the literal string "latest" in the version slot. The service treats that as a label (a nickname), not "highest version". These templates have numeric versions (e.g. 1..5) with no "latest" label, so the lookup 404'd. There is also no label= parameter, so a Model's allowedDeploymentTemplates reference (.../deploymenttemplates//labels/latest) could not be resolved.
  • Fix: the latest version is now resolved client-side by listing the available (active) versions and selecting the highest. This is required because the deployment-template REST surface exposes no latest label and its list endpoint has no server-side ordering (unlike Index/Prompt, which have a dedicated get_latest endpoint).
  • get() now also accepts a label keyword, mirroring models.get(): label="latest" resolves to the latest version, version and label are mutually exclusive, and any other (unsupported) label raises a clear error instead of a bare :latest not found.
  • delete(name) had the same latent version or "latest" bug and now resolves the latest version the same way. archive(name) / restore(name) are fixed transitively because they call get().

Testing

  • Added test_get_no_version_resolves_latest and test_delete_no_version_resolves_latest — assert the highest version is selected (not the literal "latest").
  • Added test_get_label_latest_resolves_latestlabel="latest" resolves to the latest version.
  • Added test_get_version_and_label_raises (both supplied → ValueError) and test_get_unsupported_label_raises (non-latest label → ResourceNotFoundError naming the label).
  • Added test_get_no_versions_raises_not_found — no versions available → clear ResourceNotFoundError.
  • Updated test_get_default_version / test_delete_default_version, which previously asserted the buggy version == "latest", to assert the resolved highest version.
  • Verified live against the azure-huggingface registry: get(name) and get(name, label="latest") both return the latest version (v5), get(name, version, label) raises ValueError, and get(name, <unsupported label>) raises ResourceNotFoundError.
  • Full deployment_template unit suite passes (111 tests); black and isort clean.

Description

Fixes internal bug #5402671. deployment_templates.get(name) no longer fails with DeploymentTemplate {name}:latest not found when called without a version. Previously the literal string "latest" was sent as the version, which the service interprets as a label rather than "highest version". The latest version is now resolved client-side (list versions, pick the highest), since the deployment-template service exposes no latest label and no server-side ordering. get() additionally accepts a label keyword (label="latest" resolves to the latest version) mirroring models.get(), so labels/latest references carried on a Model's allowedDeploymentTemplates can be resolved; version and label are mutually exclusive and unsupported labels raise a clear error. delete(name) resolves the latest version the same way, and archive() / restore() inherit the fix via get().

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Verification

All checks below were run against the live azure-huggingface registry (and the in-repo unit tests), on the branch with this fix.

1. Repro - the crash is gone

Screenshot 2026-07-09 195543

2. Reporter's suggested acceptance test - passing

Screenshot 2026-07-09 200306

3. In-repo unit tests - passing

Screenshot 2026-07-09 195944

Testing Guidelines

  • Pull request includes test coverage for the included changes.

…sion

deployment_templates.get(name) with no version sent the literal "latest" in the version slot, which the service treats as a (nonexistent) label rather than "highest version", causing a 404 (DeploymentTemplate {name}:latest not found). The latest version is now resolved client-side by listing the available versions and selecting the highest (the service exposes no "latest" label and no server-side ordering). get() also accepts a `label` keyword (label="latest" resolves to the latest version) mirroring models.get(), so a Model allowedDeploymentTemplates .../labels/latest reference can be resolved; unsupported labels raise a clear error. delete(name) resolves the latest version the same way.

Bug 5402671

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an internal bug in the experimental azure-ai-ml DeploymentTemplateOperations where deployment_templates.get(name) (and delete(name)) sent the literal string "latest" in the version slot when no version was supplied. The service interprets that as a label, and since these templates only have numeric versions with no "latest" label, the call 404'd. The fix resolves the latest version client-side (list active versions, pick the highest) because the deployment-template REST surface exposes neither a latest label nor server-side ordering. get() additionally gains a label keyword to mirror models.get(). archive()/restore() inherit the fix transitively via get().

Changes:

  • Added _resolve_latest_version() helper that lists versions and selects the highest (numeric-aware sort with a deterministic string fallback), raising ResourceNotFoundError when none exist.
  • get() now accepts a mutually-exclusive label keyword (label="latest" → latest version; other labels raise a clear error) and resolves the latest version client-side instead of sending "latest"; delete() uses the same resolution.
  • Updated/added unit tests and a CHANGELOG entry documenting the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sdk/ml/azure-ai-ml/azure/ai/ml/operations/_deployment_template_operations.py Adds _resolve_latest_version, label support and client-side latest resolution in get()/delete().
sdk/ml/azure-ai-ml/tests/deployment_template/unittests/test_deployment_template_operations.py Adds/updates tests asserting the highest version is resolved (not "latest") and label/error behavior.
sdk/ml/azure-ai-ml/CHANGELOG.md Documents the get(name) 404 fix and new label keyword under 1.35.0 Bugs Fixed.

… label parameter

Adds the `label: Optional[str] = None` parameter to the DeploymentTemplate.get signature in the API surface snapshot and updates apiMdSha256 accordingly, so the API.md consistency CI check passes.
@swarupecenits swarupecenits merged commit 7ed6bad into Azure:main Jul 10, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants