Repository navigation
fix(telemetry): resolve SDK version dynamically in user agent - #6546
Conversation
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.
There was a problem hiding this comment.
🤖 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.
There was a problem hiding this comment.
🤖 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.
There was a problem hiding this comment.
🤖 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.
There was a problem hiding this comment.
🤖 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.
There was a problem hiding this comment.
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
Issue:
x-sdkVersionin telemetry is always3.0, so the "Users by SDK Version" dashboard shows no data for newer releases.Root cause:
sagemaker-core/src/sagemaker/core/user_agent.pyhardcodesSDK_VERSION = "3.0". This constant feeds the user-agent suffix and thex-sdkVersiontelemetry 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
sagemakermeta-package, fall back tosagemaker-corefor standalone installs, with a static"3.0"fallback so telemetry never raises.importlib-metadatais already a declared dependency.Testing: new
tests/unit/test_user_agent.pycovers the resolution order, fallback, and a regression guard against re-hardcoding; existing telemetry tests unaffected. black/flake8 clean.