Skip to content

Byow command aliasing#8095

Open
achauhan-scc wants to merge 16 commits intoAzure:mainfrom
achauhan-scc:byow-command-aliasing
Open

Byow command aliasing#8095
achauhan-scc wants to merge 16 commits intoAzure:mainfrom
achauhan-scc:byow-command-aliasing

Conversation

@achauhan-scc
Copy link
Copy Markdown
Member

@achauhan-scc achauhan-scc commented May 7, 2026

Fixes #8105

Summary

Enhancements to the \�zure.ai.models\ azd extension:

  1. Promote custom model commands to top-level - \�zd ai models create/list/show/delete/update\ instead of \�zd ai models custom .... The \custom\ subgroup is deprecated with a warning.
  2. Add \�zd ai models update\ command - Update model description and tags via JSON Merge Patch (RFC 7396).
  3. Fix PollOperation auth - Use \�i.azure.com\ token scope for data-plane poll operations.
  4. Build-scope API alignment - Add --weight-type, --source-job-id\ filter, \pendingUploadType\ in upload request, new response fields.
  5. Code quality - Typed \APIError, unit tests, fix empty base-model URI, remove unused constants.

Changes

  • \internal/cmd/root.go\ - Top-level command registration with shared flags
  • \internal/cmd/custom.go\ - Deprecated subgroup
  • \internal/cmd/custom_create.go\ - Weight type, typed error handling, empty base-model fix
  • \internal/cmd/custom_update.go\ - New update command
  • \internal/cmd/custom_list.go\ - Source job ID filter
  • \internal/cmd/custom_show.go\ - Enhanced output, robust version parsing
  • \internal/client/foundry_client.go\ - APIError type, scope fix, update method
  • \�xtension.yaml\ - Version bump, updated examples
  • \docs/\ and \design/\ - Updated to top-level commands
  • Unit tests added for URI utilities and APIError

achauhan-scc and others added 11 commits March 12, 2026 15:33
- Add top-level azd ai models create/list/show/delete commands
- Deprecate 'custom' subgroup with warning message
- Add --weight-type flag to create command (default: FullWeight)
- Add --source-job-id filter to list command for training job lineage
- Make --publisher optional (only sent when explicitly provided)
- Send pendingUploadType in startPendingUpload request body
- Add new response fields: weightType, baseModel, source, artifactProfile, provisioningState
- Display new fields in show command output
- Update extension.yaml to 0.0.6-preview with updated examples
- Update CHANGELOG.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates the azure.ai.models azd extension to make custom model CRUD commands available directly under azd ai models (with the existing custom subgroup deprecated) and expands model payload/outputs to support newer service fields like weight type and source lineage.

Changes:

  • Added top-level create/list/show/delete commands (aliases of the existing custom subcommands) and marked custom as deprecated.
  • Added --weight-type to create and --source-job-id filtering to list; enhanced show output with additional model metadata.
  • Updated the Foundry client to support list filtering and to send an explicit pendingUploadType in startPendingUpload.
Show a summary per file
File Description
cli/azd/extensions/azure.ai.models/pkg/models/register_model.go Adds weightType to the register model request payload.
cli/azd/extensions/azure.ai.models/pkg/models/custom_model.go Expands the model response schema (weight type, base model, source, artifact profile, provisioning state).
cli/azd/extensions/azure.ai.models/internal/cmd/root.go Registers top-level CRUD commands and wires up endpoint resolution in PreRunE.
cli/azd/extensions/azure.ai.models/internal/cmd/custom.go Deprecates the custom subgroup in favor of top-level commands.
cli/azd/extensions/azure.ai.models/internal/cmd/custom_show.go Displays additional model fields (weight type, status, base model, source, artifact profile).
cli/azd/extensions/azure.ai.models/internal/cmd/custom_list.go Adds --source-job-id and plumbs it to the client as a list option.
cli/azd/extensions/azure.ai.models/internal/cmd/custom_create.go Adds --weight-type; makes --publisher optional and only sends catalog info when provided.
cli/azd/extensions/azure.ai.models/internal/client/foundry_client.go Adds ListModels options + query param; updates startPendingUpload body to include pendingUploadType.
cli/azd/extensions/azure.ai.models/extension.yaml Bumps extension version and updates examples to the new top-level command surface.
cli/azd/extensions/azure.ai.models/CHANGELOG.md Documents new command surface, flags, output improvements, and client request change for 0.0.6-preview.

Copilot's findings

  • Files reviewed: 10/10 changed files
  • Comments generated: 1

Comment thread cli/azd/extensions/azure.ai.models/internal/cmd/root.go
Copy link
Copy Markdown
Member

@jongio jongio left a comment

Choose a reason for hiding this comment

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

Several user-facing error/hint messages still reference the deprecated custom subgroup. Users running the new top-level commands will see recovery hints pointing to the deprecated path:

  • custom.go:123 - the "azd not available" error says azd ai models custom list --project-endpoint ...
  • custom_create.go:155-157 - the "already exists" recovery hints say azd ai models custom show and azd ai models custom create
  • init.go:85-86 - post-init next-steps say azd ai models custom list and azd ai models custom create

These should use azd ai models show, azd ai models create, azd ai models list, etc.

Same issue in installation-guide.md and design-spec.md - those could be a follow-up, but worth tracking so the docs don't contradict the deprecation.

Comment thread cli/azd/extensions/azure.ai.models/internal/cmd/root.go
Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

📋 Code Review — PR #8095 "Byow Command Aliasing"

Findings below supplement existing reviews by jongio and Copilot — their items are not duplicated here.

🔴 P0 — Must Fix Before Merge

1. custom_create.go — Malformed URI when �aseModel is empty
�uildDerivedModelURI("") produces �zureml://registries/azureml-fireworks/models//versions/1 (double slashes). This is silent data corruption — the model registers but can't be retrieved later. Add input validation to reject empty �aseModel.

🟡 P1 — Should Fix Before Merge

2. �ersion.txt vs CHANGELOG.md version mismatch
�ersion.txt shows �.0.5-preview but CHANGELOG documents �.0.6-preview. Must align before release.

3. custom_show.go:96-100 — Silent strconv.Atoi error discarded
�, _ := strconv.Atoi(m.Version) silently treats non-numeric versions (e.g. "1.0.0") as �, breaking "latest version" selection. Should handle the error or use a more robust comparison.

4. custom_create.go:148-170 — Fragile error detection via string matching
Uses strings.Contains(err.Error(), "409") instead of checking HTTP status codes. Will silently break if Azure API changes error message format. Prefer *azcore.ResponseError with .StatusCode.

5. �xtension.yaml — Examples still show deprecated custom subgroup
Usage examples reference �zd ai models custom create/list — should show the new top-level commands since this PR deprecates the custom path.

6. custom_create.go — Publisher default change without deprecation
If the --publisher default changed from "Fireworks" to empty, existing scripts will silently register models with wrong metadata. Needs verification and, if confirmed, a deprecation notice or default restoration.

7. No test files for the extension
Zero *_test.go files exist. Critical paths (version parsing, URI building, flag resolution) have no automated coverage.

🟢 P2 — Nice to Have

8.
oot.go:47-69 — Shared customFlags instance across alias commands

All 4 top-level aliases share one flags struct. Works today but creates hidden coupling for future changes.

9. CHANGELOG deprecation notice lacks removal timeline
No indication of when custom subgroup will be removed. Best practice: give 2–3 preview releases of warning.


Bottom line: 1 data corruption bug (P0), 6 significant issues (P1), 2 minor items (P2). The P0 malformed URI and the version mismatch are the highest-priority blockers.

The ml.azure.com scope fails with AzureDeveloperCLICredential due to
first-party app consent issues. The api.azureml.ms operations endpoint
accepts the same ai.azure.com token used by the rest of the client.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

🔄 Incremental Review — New Commit: "Fix PollOperation auth: use ai.azure.com scope instead of ml.azure.com"

Auth scope fix looks correct ✅ — All API calls now consistently use TokenScope (�i.azure.com). Good change.

New Finding

🟢 P2 — oundry_client.go — MLTokenScope constant is now unused
After switching PollOperation to TokenScope, the MLTokenScope constant (https://ml.azure.com/.default) is dead code. Consider removing it to keep the codebase clean.

Previous Findings

All 9 findings from the prior review remain applicable — this commit doesn't resolve or worsen any of them. The P0 malformed URI in �uildDerivedModelURI is still the top blocker.

Copy link
Copy Markdown
Member

@jongio jongio left a comment

Choose a reason for hiding this comment

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

Incremental review - new commit 92727fc (auth scope fix)

The scope change in PollOperation is correct - switching from MLTokenScope to TokenScope makes auth consistent across all client methods. addAuth() already uses TokenScope, so this removes the last outlier.

One thing wbreza's review didn't catch: ARMTokenScope is also unused now, not just MLTokenScope. Both can be cleaned up together.

Prior findings still open:

  • Error/hint messages in custom.go:122, custom_create.go:153,155, and init.go:85-86 still point users to the deprecated azd ai models custom ... path. Users running the new top-level commands will see recovery hints directing them to the deprecated route.
  • version.txt still reads 0.0.5-preview while extension.yaml and CHANGELOG say 0.0.6-preview.
  • root.go:83 - PreRunE overwrite is still fragile (my earlier inline comment).

achauhan-scc and others added 4 commits May 8, 2026 08:40
Add 'azd ai models update' command that uses PATCH with JSON Merge
Patch (RFC 7396) to update model description and tags:
  - --description: set/update the model description
  - --set-tag key=value: upsert tags (repeatable)
  - --remove-tag key: remove tags (repeatable)

Also adds UpdateModel method to FoundryClient using
Content-Type: application/merge-patch+json.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Update user-facing messages to use top-level commands (azd ai models *)
  instead of deprecated custom subgroup in code and docs
- Fix malformed URI when --base-model is empty (skip DerivedModelInformation)
- Replace fragile string-based error detection with typed client.APIError
  and errors.As status code checking
- Handle non-numeric versions in show command's latest-version selection
- Preserve existing PreRunE hooks in top-level command setup
- Use Flags() instead of PersistentFlags() for leaf commands
- Remove unused ARMTokenScope and MLTokenScope constants
- Add unit tests for URI utilities and APIError type

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

🔄 Re-Review — 4 New Commits (PR #8095)

Great progress! Most previous findings have been addressed.

✅ Resolved (7 of 10 previous findings)

  1. P0 Malformed URI — Fixed. �uildDerivedModelURI is now only called when �aseModel is non-empty.
  2. P1 Silent strconv.Atoi error — Fixed. Error is now handled gracefully.
  3. P1 Fragile strings.Contains error detection — Fixed. Replaced with typed APIError with .StatusCode checks.
  4. P1 Extension.yaml stale examples — Fixed. Examples now show top-level commands.
  5. P1 Publisher default change — Fixed. Documented in CHANGELOG under Deprecations; only included when explicitly provided.
  6. P1 No test files — Partially fixed. Tests added for oundry_client and custom_create helpers.
  7. P2 Unused MLTokenScope constant — Fixed. Removed along with ARMTokenScope.

🟡 Still Open

P1 — �ersion.txt still shows �.0.5-preview
CHANGELOG.md and extension.yaml are updated to �.0.6-preview, but �ersion.txt still has �.0.5-preview. Should be aligned before merge unless there's a separate version bump workflow.

P2 — Shared customFlags instance across alias commands (from prior review)
All top-level alias commands still share one customFlags{} struct. Low risk but noted.

P2 — CHANGELOG deprecation notice lacks removal timeline (from prior review)
No timeline for custom subgroup removal.

Bottom Line

Down from 1 P0 + 6 P1 + 3 P2 to 0 P0 + 1 P1 + 2 P2. The remaining P1 (version.txt) is a quick fix. Nice cleanup! 🎉

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.

azure.ai.models extension: promote commands to top-level, add update command, fix auth

4 participants