Repository navigation
fix(telemetry): resolve SDK version dynamically in user agent - #6546
rsareddy0329 wants to merge 2 commits into
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.
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.