Repository navigation
{aimanager} Shorten modeldeployment args and list across namespaces - #10346
Conversation
Shorten the modeldeployment namespace argument from --namespace-name to --namespace (the --ns alias is unchanged), per bug-bash feedback that --namespace-name is too long. Fixes AB#39633340
|
Hi Liqian Luo (@circy9), |
There was a problem hiding this comment.
🟡 Changes recommended
An existing unit test still expects --namespace-name and must be updated.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Renames the AI Manager model deployment option to --namespace while retaining --ns.
Changes:
- Updates argument registration, help examples, and scenario tests.
- Bumps the extension version to
1.5.4b1. - Adds release history.
- An existing unit test still expects
--namespace-name.
File summaries
| File | Description |
|---|---|
src/aimanager/setup.py |
Bumps extension version. |
src/aimanager/HISTORY.rst |
Documents the renamed option. |
src/aimanager/azext_aimanager/tests/latest/test_modeldeployment_scenario.py |
Updates scenario commands. |
src/aimanager/azext_aimanager/_params.py |
Registers --namespace and --ns. |
src/aimanager/azext_aimanager/_help.py |
Updates command examples. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Reflect the --namespace-name -> --namespace rename in the test_modeldeployment options_list assertion.
Local test results ✅Ran the change in an Live CLI commands (sub
|
| Check | Result |
|---|---|
azdev linter aimanager |
✅ No violations |
azdev style aimanager (pylint + flake8) |
✅ PASSED |
azdev test aimanager --series |
✅ 75 passed |
Note: pushed a follow-up commit updating the test_modeldeployment options_list assertion to match the renamed flag.
Shorten the AI Manager name argument from --aimanager-name to --aimanager across modelsource, namespace and modeldeployment command groups. The --manager and -m aliases are unchanged.
Local test results —
|
| Check | Result |
|---|---|
azdev linter aimanager |
✅ No violations |
azdev style aimanager (pylint + flake8) |
✅ PASSED |
azdev test aimanager --series |
✅ 75 passed |
Support listing model deployments across all readable namespaces of an AI Manager. Callers must specify exactly one of --namespace/--ns or --all-namespaces/-A; a validator enforces this. --all-namespaces enumerates namespaces via the namespaces client and aggregates the per-namespace deployment lists. The list table already derives the Namespace column from each resource id, so the cross-namespace view renders correctly.
|
aimanager |
New feature + local test results —
|
| Check | Result |
|---|---|
azdev linter aimanager |
✅ No violations |
azdev style aimanager (pylint + flake8) |
✅ PASSED |
azdev test aimanager --series |
✅ 80 passed (5 new: scope validator x4 + all-namespaces aggregation) |
Clarify that list_by_ai_manager is invoked once (returning a paged iterator) and list_by_ai_manager_namespace is fanned out per namespace, in response to PR review.
--namespace-name to --namespace--namespace-name/--aimanager-name and add --all-namespaces to modeldeployment list
--namespace-name/--aimanager-name and add --all-namespaces to modeldeployment listCI runs `azdev test --discover`, which requires globally unique test method names across the whole azext_aimanager module. Several pre-existing methods collided across test classes/modules, failing the Integration Tests job. Rename the duplicated table-format methods (per resource type), the aimodel validator methods, and the aimanager scenario method (with its recording) so discovery succeeds.
CI fix: Integration Tests failure (duplicate test method names)The Integration Tests / Build Tests jobs failed on
(My local runs used Fix (commit Verified locally with the CI-equivalent command:
|
Per PR review, follow the `az ... list` convention: instead of requiring one of --namespace/--all-namespaces, make --namespace/--ns optional and list across all readable namespaces when it is omitted (mirroring `kubectl get pods --all-namespaces`). Drop --all-namespaces/-A and the exactly-one-of validator. Also handle partial authorization in the cross-namespace path: skip namespaces the caller cannot read (401/403) and aggregate the rest, so a partially-authorized caller still sees what they can read; other errors propagate. If the caller can read no namespace, the namespace enumeration itself raises the normal unauthorized error.
Per PR review, add tests for the authorization edge cases of listing model deployments across namespaces: - namespace enumeration itself unauthorized -> error propagates - deployments unauthorized in every namespace -> surface the unauthorized error instead of returning an empty list Adjust list_modeldeployment to track whether any namespace was readable and re-raise the last auth error when none were, matching the reviewer's "authorized for 0 namespaces shows the normal unauthorized message" rule.
Liqian Luo (circy9)
left a comment
There was a problem hiding this comment.
-
Did you update command help instructions to clearly state that the user must have namespace read permissions upon the specified AI manager resource if --namespace or --ns is unspecified?
-
When --namespace is omitted, if the user is unauthorized to list modeldeployments for a subset of namespaces and we skip those namespaces, did you make sure the cli outputs a warning message for each skipped namespace?
-
When --namespace is omitted, if the user is unauthorized to list namespaces, did you make sure the error message shown to the user clearly state that the user must have namespace read permissions upon the specified AI manager resource. If not, the user can use --namespace or --ns to list modeldeployments for one specific namespace.
Address review feedback on listing model deployments without --namespace: - Document in the command help (long-summary) that omitting --namespace requires namespace read permission on the AI Manager, that unauthorized namespaces are skipped with a warning, and that --namespace/--ns lists a single namespace instead. - Emit a clear per-namespace warning naming each skipped, unauthorized namespace. - When the caller cannot enumerate namespaces, or can read none of them, raise an actionable UnauthorizedError that states the required permission and suggests --namespace/--ns for a single namespace.
|
Addressed all three points in 1. Help text — permission requirement when
2. Per-namespace warning for skipped namespaces. Each unauthorized namespace now logs its own warning naming the namespace:
Covered by unit test 3. Actionable error when namespaces can't be listed (or none are readable). When the caller can't enumerate namespaces — or can enumerate but is denied in every one — the command now raises an
Covered by Validation: |
Correct the permission model in help and error messages. Listing model deployments without --namespace involves two distinct permissions: 1. Listing namespaces (list_by_ai_manager) requires namespace read on the AI Manager resource; without it no namespaces can be listed. 2. Listing deployments per namespace (list_by_ai_manager_namespace) requires model deployment read on each namespace resource, which the caller may hold for some namespaces but not others. The earlier messaging conflated the two. Now the namespace-enumeration failure names the AI-Manager namespace-read requirement, while the all-namespaces-forbidden case names the per-namespace model-deployment- read requirement. Update help long-summary and tests accordingly.
|
You're right — my previous change conflated the two permission layers. Corrected in Two distinct permissions when
Behavior now:
Help |
Address review feedback: - When the caller can list namespaces but lacks model deployment read on every one, do not suggest --namespace/--ns: scoping to a single namespace would fail too. The error now asks for model deployment read access on a namespace instead. - Remove a duplicated return statement in list_modeldeployment. - Tests now assert the full warning and error-recommendation text instead of substrings.
Per review, model deployment read is not "granted per namespace" only: it can be granted on the namespace resource, or inherited from the parent AI Manager resource (covering all its namespaces). Reword the all-forbidden error, the command help long-summary, and HISTORY to reflect both grant scopes.
Live CLI test results (real invocations)Ran against a live preview subscription with the dev extension active (branch HEAD Argument renames
Cross-namespace list (omit
|
|
[Release] Update index.json for extension [ aimanager-1.5.4b1 ] : https://dev.azure.com/msazure/One/_build/results?buildId=181409875&view=results |
🤖 PR Validation — ❌ Action needed
❌Azure CLI Extensions Breaking Change Test
Summary
Preview-usability improvements to the
az aimanagercommand group, driven by bug-bash feedback. Three changes:--namespace-name→--namespace(onaimanager namespace modeldeployment). The--nsshort alias is unchanged. (AB#39633340)--aimanager-name→--aimanager(onaimanager modelsource,aimanager namespace, andaimanager namespace modeldeployment). The--manager/-maliases are unchanged. (AB#39633340)aimanager namespace modeldeployment list:--namespace/--nsis now optional. When omitted, deployments are listed across all readable namespaces of the AI Manager — following theaz ... listconvention (list-by-resource-group vs list-by-subscription) and mirroringkubectl get pods --all-namespaces. Because themodel_deploymentsSDK has no cross-namespace list operation, the command enumerates the AI Manager's namespaces (onelist_by_ai_managercall, paged) and fans out onelist_by_ai_manager_namespacecall per namespace, aggregating the results. Two permissions are involved and the help documents both: listing namespaces requires namespace read on the AI Manager, and listing deployments in each namespace requires model deployment read for that namespace (granted on the namespace, or inherited from the AI Manager). If namespaces can't be listed, anUnauthorizedErrornames the AI-Manager namespace-read requirement. Namespaces the caller can't read deployments in (401/403) are skipped with a per-namespace warning so a partially-authorized caller still sees what they can read; if the caller is denied on every namespace, anUnauthorizedErrornames the per-namespace model-deployment-read requirement (without suggesting--namespace, since scoping to one namespace would fail too). The namespace-enumeration error does suggest--namespace/--nsfor a single namespace. The list table derives theNamespacecolumn from each resource id, so the aggregated view groups correctly. (AB#39633378)Files changed
azext_aimanager/_params.py— renamed option lists; madenamespace_nameoptional in thelistcontext.azext_aimanager/custom.py—list_modeldeploymentlists across all readable namespaces when no namespace is given, skipping forbidden ones.azext_aimanager/_help.py— updated examples; added a cross-namespace example.azext_aimanager/tests/latest/— updated the options_list assertion and scenario tests; added single-namespace, cross-namespace aggregation, skip-forbidden, and reraise-non-auth unit tests. Also made several pre-existing duplicate test method names unique soazdev test --discover(CI) passes.setup.py— version bump to1.5.4b1.HISTORY.rst— changelog entries.Breaking changes
Flagged by the breaking-change validator:
ParaPropUpdate) —--namespace-nameand--aimanager-nameremoved as option strings (the two renames).ParaPropRemove) —namespace_nameon... modeldeployment listis no longerrequired=True.These breaking changes are acceptable: the
aimanagerextension is still in preview and has not been launched — the command group is markedis_preview=Trueand there are no GA'd consumers depending on the old option names or on the namespace being required. Making these changes now, before launch, avoids carrying the overly long names forever and alignslistwith the standardaz ... listscoping convention. The most-used aliases (--ns,--manager/-m) are preserved.Testing
Validated locally in an
azdevvenv (dev extension active) and against a live preview subscription with real resources (two namespaces, one deployment each). See PR comments for full live command output.azdev test azext_aimanager --discover --series— 81 passed (CI-equivalent discovery path)azdev style aimanager— pylint + flake8 PASSEDazdev linter aimanager— no violations--namespace ns2scopes to one namespace; omitting--namespaceaggregates across all namespacesFixes AB#39633340
Fixes AB#39633378