Skip to content

Fix shared-cache option naming consistency - #2651

Open
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 4 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/shared-cache-option-aliases
Open

Fix shared-cache option naming consistency#2651
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 4 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/shared-cache-option-aliases

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Describe your changes

The standalone olive shared-cache command uses --account and --container, while Olive's shared-cache options elsewhere use --account_name and --container_name. Equivalent shared-cache configuration therefore uses different CLI names depending on the command.

This change makes --account_name and --container_name the canonical option names for shared-cache while retaining --account and --container as backward-compatible aliases, so existing scripts continue to work.

This addresses the shared-cache CLI consistency finding in #2516.

Tests

Adds parser coverage for both the consistent option names and the legacy aliases.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary. No documentation change required.

Copilot AI lite review requested due to automatic review settings September 3, 2026 20:17
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🔵 Needs a closer look

The shared-cache delete path can unintentionally delete the entire container when --delete is used without --all and --model_hash is omitted, because delete_blob(None) can enumerate all blobs.

Pull request overview

This PR improves CLI consistency in Olive by making the olive shared-cache command use the same shared-cache option names (--account_name, --container_name) that are used elsewhere in the CLI, while preserving the legacy flags (--account, --container) as aliases for backward compatibility.

Changes:

  • Make --account_name / --container_name the canonical flags for olive shared-cache, retaining --account / --container as aliases.
  • Update the shared-cache command implementation to read the canonical parsed argument names.
  • Add a unit test to validate that both canonical and legacy option names parse into the same resulting namespace fields.
File summaries
File Description
olive/cli/shared_cache.py Adds canonical shared-cache option names and switches runtime usage to args.account_name / args.container_name.
test/cli/test_shared_cache.py Adds parser coverage ensuring both canonical and legacy flags populate the canonical argument destinations.
Review details

Suppressed comments (1)

olive/cli/shared_cache.py:62

  • When --delete is used without --all, delete_blob(self.args.model_hash) is called even if --model_hash was not provided. In AzureContainerClientFactory.delete_blob, a None blob_name results in list_blobs(None) which can enumerate all blobs, so olive shared-cache --delete ... could unintentionally delete the entire container.
        container_client_factory = AzureContainerClientFactory(self.args.account_name, self.args.container_name)
        if self.args.delete:
            if self.args.all:
                if self.args.yes:
                    container_client_factory.delete_all()
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sylvesterkaczmarek

Copy link
Copy Markdown
Author

Addressed the delete-safety finding. --delete without --all now fails closed unless --model_hash is provided, so the targeted path can no longer call delete_blob(None) and enumerate the whole container. Added regression coverage for the missing-model-hash case; both changed Python files pass py_compile and git diff --check locally.

Comment thread test/cli/test_shared_cache.py Outdated
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.

3 participants