Skip to content

fix(telemetry): resolve SDK version dynamically in user agent - #6546

Merged
rsareddy0329 merged 4 commits into
aws:masterfrom
rsareddy0329:fix/telemetry-sdk-version-user-agent
Nov 25, 2026
Merged

rsareddy0329 merged 4 commits into
aws:masterfrom
rsareddy0329:fix/telemetry-sdk-version-user-agent

Conversation

@rsareddy0329

Copy link
Copy Markdown
Contributor

Issue: x-sdkVersion in telemetry is always 3.0, so the "Users by SDK Version" dashboard shows no data for newer releases.

Root cause: sagemaker-core/src/sagemaker/core/user_agent.py hardcodes SDK_VERSION = "3.0". This constant feeds the user-agent suffix and the x-sdkVersion telemetry field used by core, serve, and train. The dynamic lookup V2 had (importlib_metadata.version("sagemaker")) was lost in the V3 port and later pinned to a constant.

Fix: resolve the version at runtime — prefer the sagemaker meta-package, fall back to sagemaker-core for standalone installs, with a static "3.0" fallback so telemetry never raises. importlib-metadata is already a declared dependency.

Testing: new tests/unit/test_user_agent.py covers the resolution order, fallback, and a regression guard against re-hardcoding; existing telemetry tests unaffected. black/flake8 clean.

SDK_VERSION in sagemaker-core/src/sagemaker/core/user_agent.py was
hardcoded to "3.0", so every V3 install reported x-sdkVersion=3.0
regardless of the installed release. This blanked out the
"Users by SDK Version" telemetry dashboard for all newer versions
(core, serve, and train telemetry all import this one constant).

Restore the dynamic resolution V2 used (importlib_metadata.version):
prefer the "sagemaker" meta-package version, fall back to
"sagemaker-core" for standalone installs, and keep a static "3.0"
fallback so user-agent/telemetry construction never raises.

Add tests/unit/test_user_agent.py, which the module previously lacked,
including a regression guard against re-hardcoding the version.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI code review

This PR replaces the hardcoded SDK_VERSION = "3.0" in sagemaker-core/src/sagemaker/core/user_agent.py with a runtime lookup via importlib_metadata.version(...), preferring the sagemaker meta-package and falling back to sagemaker-core, then to a static "3.0". The importlib-metadata dependency is already declared in pyproject.toml, and the approach mirrors the existing pattern in utils/user_agent.py. The change is correct, consistent with established practice for SDK version reporting (Source: #4414), and comes with adequate unit tests. No blocking issues found.

Reviewed commit 8f94256. Automated review; verify before acting.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI code review

This PR replaces the hardcoded SDK_VERSION = "3.0" in sagemaker-core/src/sagemaker/core/user_agent.py with a runtime lookup via importlib_metadata, preferring the sagemaker meta-package and falling back to sagemaker-core then a static "3.0". The change is correctly targeted — this module feeds x-sdkVersion telemetry for core, serve, and train — and follows existing conventions (core/utils/user_agent.py already uses importlib_metadata.version, and importlib-metadata is a declared dependency). Tests cover resolution order, fallback, and a regression guard, and existing telemetry tests are unaffected. The PR looks clean; no blocking issues found.

Reviewed commit dd9ef3a. Automated review; verify before acting.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI code review

This PR replaces the hardcoded SDK_VERSION = "3.0" in sagemaker-core/src/sagemaker/core/user_agent.py with a runtime resolution that tries importlib_metadata.version("sagemaker"), then "sagemaker-core", then falls back to a static "3.0". The change mirrors the existing pattern in utils/user_agent.py, the importlib-metadata dependency is already declared, and the new tests/unit/test_user_agent.py covers resolution order, fallback, and a regression guard. The change is correct and well-tested; no blocking issues found.

Reviewed commit 8e17ddb. Automated review; verify before acting.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI code review

This PR replaces the hardcoded SDK_VERSION = "3.0" in sagemaker-core/.../user_agent.py with a runtime _resolve_sdk_version() that tries the sagemaker meta-package, then sagemaker-core, then a static "3.0" fallback. This mirrors the established pattern in utils/user_agent.py, uses the already-declared importlib-metadata dependency, and adds focused unit tests covering resolution order, fallback, and a regression guard. The change is correct and well-tested; I found no issues worth blocking on.

Reviewed commit 9044546. Automated review; verify before acting.

@rsareddy0329 rsareddy0329 left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The failed integ-tests (sagemaker-core) check isn't caused by this PR. Only tests/integ/jumpstart/test_model.py::test_all_hub_content_documents fails. It hits a
pydantic extra_forbidden error on QualityBenchmarks in InferenceConfigs, because a SageMakerPublicHub model now returns a field that HubContentDocument doesn't allow.

To confirm, I ran the sagemaker-core integ build on mainline and on this PR. Both fail on the same test with the same error.

  • Mainline (5fe6647, no change from this PR):
    arn:aws:codebuild:us-west-2::build/sagemaker-python-sdk-ci-sagemaker-core-integ-tests:d92345fa-6fe2-4fbd-a19e-b07418083564
  • This PR (9044546): arn:aws:codebuild:us-west-2::build/sagemaker-python-sdk-ci-sagemaker-core-integ-tests:b2c64de3-7975-4547-9a07-ce6225fd0d8f

@rsareddy0329
rsareddy0329 merged commit 2ec54f9 into aws:master Nov 25, 2026
43 of 47 checks passed

This branch was previously deployed

2 inactive (1 outdated) deployments
manual-approval — 90445463 Deployed Nov 25, 2026 by rsareddy0329 via wait-for-approval #2006
auto-approve — 8e17ddbe Deployed Nov 3, 2026 by rsareddy0329 via wait-for-approval #792
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