Skip to content

fix(ml): preserve extension identity with modern wheel metadata - #10412

Open
nlydick wants to merge 1 commit into
Azure:mainfrom
nlydick:fix/ml-wheel-metadata-compatibility
Open

nlydick wants to merge 1 commit into
Azure:mainfrom
nlydick:fix/ml-wheel-metadata-compatibility

Conversation

@nlydick

@nlydick nlydick commented Sep 30, 2026

Copy link
Copy Markdown

Background and defect

Modern setuptools emits wheel Metadata-Version 2.4. Older Azure CLI installations, including the pkginfo 1.8.2 reader shipped with CLI 2.75.0, cannot parse that format and report an installed ML extension version as null. This also removes the installed-version information used by dynamic installation to avoid reinstalling the same extension after a command-resolution failure.

Change and compatibility

  • Add a standard setuptools build_py hook that writes the distribution name and version into the built azext_mlv2/azext_metadata.json, which older CLI readers already consume.
  • Derive both values from the build's distribution, including incremental/tagged builds; do not duplicate a version constant or modify the source metadata file.
  • Retain modern packaging tools, the declared minimum CLI version, runtime dependencies, and the current release version.
  • Add five packaging regression cases covering wheel identity, an unsupported-metadata reader, az extension show JSON output, az version JSON output, and incremental builds. Run them in the Python 3.12 CI leg.
  • Document the compatibility behavior in the extension README and unreleased change notes.

This change does not alter Azure CLI's retry/prompt implementation or promise complete SDK runtime compatibility with every older CLI bundle. A separately observed SDK/Azure Core import conflict is outside this PR's scope. Publishing a corrected release still requires the normal extension release/versioning process; this PR does not overwrite a published wheel.

Dependencies and merge order

None. This is an independent fix targeting main, based on 4e0b4f3. It does not require the pending ML release-version PR.

Validation

Validation pending for repository CI.

  • Local command: python -m pytest tests/e2e/packaging/test_packaging_lifecycle.py -k ml_metadata -q
  • Five tests passed, zero failed or skipped, using Python 3.12, the exact azure-cli-2.75.0 source tag, pkginfo 1.8.2, and setuptools 80.9.0.
  • The isolated test environment uses azure-core 1.41.0 to satisfy the current SDK's runtime imports. This is deliberately a version-detection test, not proof that the stock CLI 2.75 bundle (azure-core 1.31.0) can run all current ML commands.
  • Before the fix, the wheel identity, legacy-reader and incremental-build assertions failed because the generated extension identity was absent and the old reader returned None.
  • git diff --check passed.
  • Modern-parser/toolchain cross-check and style validation will be updated before handoff.

Write the package identity into the built Azure CLI metadata so older
metadata parsers can identify ML wheels built with modern setuptools.
Keep source metadata, runtime dependencies, and minimum CLI unchanged.

Add regression coverage for wheel identity, legacy readers, CLI JSON
output, and incremental builds, with a Python 3.12 CI gate.

Authored-by: GitHub Copilot SDK (version not exposed)
Model: GPT-6 Astra (gpt-6-astra)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: da39d407-596a-4078-a372-19ac7fb8699e
Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:49
@azure-pipelines

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

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

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.

Copilot review overview

🟡 Changes recommended

The legacy-reader test’s mock target is incompatible with the Azure CLI dev version installed in CI.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds build-time ML extension identity metadata for compatibility with older Azure CLI metadata readers.

Changes:

  • Generates name/version metadata during wheel builds.
  • Adds five packaging regression cases and Python 3.12 CI coverage.
  • Documents compatibility behavior and release notes.
File Description
src/​machinelearningservices/​setup.py Adds the metadata build hook.
tests/​e2e/​packaging/​test_packaging_lifecycle.py Adds compatibility tests.
tests/​e2e/​packaging/​fixtures/​manifest.json Registers the ML fixture.
azure-pipelines.yml Runs ML packaging tests on Python 3.12.
src/​machinelearningservices/​README.rst Documents packaging compatibility.
src/​machinelearningservices/​HISTORY.rst Adds release history.
src/​machinelearningservices/​CHANGELOG.rst Adds changelog entry.

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

installed_dir, _ = ml_metadata_install
# pkginfo 1.8.2 leaves name/version unset for Metadata-Version: 2.4.
unreadable_metadata = SimpleNamespace(name=None, version=None)
with patch("azure.cli.core.extension.pkginfo.Wheel", return_value=unreadable_metadata):
@yonzhan Yong Zhang (yonzhan) added this to the Backlog milestone Sep 30, 2026
@yonzhan

Copy link
Copy Markdown
Collaborator

Please fix CI issues

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.

5 participants