Registry / aws / sagemaker-core

sagemaker-core

JSON →
library2.21.0pypypi✓ verified 25d ago

SageMaker Core (`sagemaker-core`) is a foundational Python package providing core functionalities and utilities for interacting with AWS SageMaker services. It serves as a key dependency for the higher-level `sagemaker` Python SDK, abstracting away low-level AWS interactions and offering base classes for SageMaker components. It is currently at version 2.7.1 and typically updates alongside the main `sagemaker` SDK, though its versioning is distinct from the `sagemaker` SDK's major version. The project is actively maintained on GitHub within the larger `aws/sagemaker-python-sdk` monorepo.

pip install sagemaker-core
INSTALL
IMPORT
SIG · SAGEMAKER-CORE
S
sagemaker-core
awspythonv2.21.0
Install
50ms avg
Import
Disk
426MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.21.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ 0.05s
1/2 runs
py 3.11
✓ —
1/2 runs
py 3.12
✓ —
1/2 runs
py 3.13
✓ —
1/2 runs
py 3.9
✓ —
1/2 runs
426MB installed
● package 426MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Session
from sagemaker import Session
from sagemaker.session import Session

Demonstrates initializing a `Session` directly from `sagemaker_core.session`, retrieving basic AWS configuration details like region, account ID, default S3 bucket, and the execution role. This illustrates direct interaction with core SageMaker components.

import sagemaker_core.session import os # Initialize a SageMaker Session directly from sagemaker_core. # This session can then be used to interact with AWS SageMaker services. # For full functionality, you would typically use `sagemaker.session.Session` # which provides more high-level abstractions. try: sagemaker_session = sagemaker_core.session.Session() region = sagemaker_session.boto_region_name account_id = sagemaker_session.account_id() print(f"Successfully initialized sagemaker_core.session.Session.") print(f"AWS Region: {region}") print(f"AWS Account ID: {account_id}") # Example: Get default S3 bucket for SageMaker artifacts default_bucket = sagemaker_session.default_bucket() print(f"Default S3 bucket: {default_bucket}") # Example: Attempt to get the IAM execution role. # This often works automatically in SageMaker Studio/Notebooks. try: role = sagemaker_session.get_execution_role() print(f"Execution Role: {role}") except Exception as e: print(f"Could not get execution role (expected if not in SM Studio/notebook or roles not configured): {e}") except Exception as e: print(f"Error initializing sagemaker_core.session.Session: {e}") print("Ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials, or IAM roles).")
Debug
Known issues
gotchaPrefer the high-level `sagemaker` SDK for most use cases. `sagemaker-core` is a low-level dependency; direct imports are generally only needed for advanced customizations or when explicitly building on its base components.
fix
For general SageMaker interaction, `pip install sagemaker` and import from `sagemaker` (e.g., `from sagemaker.session import Session`, `from sagemaker.estimator import Estimator`). Only use `sagemaker_core` when absolutely necessary for specific low-level utilities.
affects: All versions
gotchaThe `sagemaker-core` package has its own versioning (e.g., 2.x.x) which does not directly align with the major version of the main `sagemaker` Python SDK (which also has 2.x.x and 3.x.x lines). Manually pinning `sagemaker-core` can lead to unexpected compatibility issues.
fix
Always install the main `sagemaker` package and let it manage its `sagemaker-core` dependency. Avoid manually pinning `sagemaker-core` unless you are explicitly building a custom SageMaker extension and have thoroughly tested compatibility.
affects: All versions
gotchaOlder versions of `sagemaker-core` (and thus older `sagemaker` SDK versions) have strict `protobuf` version constraints (e.g., `<4.0.0` for `sagemaker-core==2.7.1`). This can cause dependency conflicts when used in environments with other libraries requiring newer `protobuf` versions.
fix
If encountering `protobuf` conflicts, try upgrading your `sagemaker` SDK to a very recent version (e.g., `pip install 'sagemaker>=2.257.1,<3'`) which may have relaxed its own `protobuf` requirements. If that fails, consider using a dedicated virtual environment or carefully managing `protobuf` versions globally.
affects: `sagemaker-core<3.0.0` (including 2.7.1)
Upgrade
Version history
2.21.0latest on PyPI · released Aug 25, 2026
Audit
Dependencies
boto3requiredRequired for AWS API interactions.
protobufrequiredRequired for data serialization, often for model artifacts or inter-process communication.
sagemaker-clientrequiredA minimal client for SageMaker API interactions.
Agent activity
17 hits · last 30 days
node
16
Resources
sagemaker-core — pip install sagemaker-core · libregistry