{"id":1701,"library":"sagemaker-core","title":"SageMaker Core","description":"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.","status":"active","version":"2.7.1","language":"python","source_language":"en","source_url":"https://github.com/aws/sagemaker-python-sdk","tags":["aws","sagemaker","ml","core","utility","machine-learning","cloud"],"install":[{"cmd":"pip install sagemaker-core","lang":"bash","label":"Install `sagemaker-core` directly"},{"cmd":"pip install sagemaker","lang":"bash","label":"Recommended: Install `sagemaker` which includes `sagemaker-core`"}],"dependencies":[{"reason":"Required for AWS API interactions.","package":"boto3","optional":false},{"reason":"Required for data serialization, often for model artifacts or inter-process communication.","package":"protobuf","optional":false},{"reason":"A minimal client for SageMaker API interactions.","package":"sagemaker-client","optional":false}],"imports":[{"wrong":"from sagemaker.session import Session","symbol":"Session","correct":"from sagemaker import Session"}],"quickstart":{"code":"import sagemaker_core.session\nimport os\n\n# Initialize a SageMaker Session directly from sagemaker_core.\n# This session can then be used to interact with AWS SageMaker services.\n# For full functionality, you would typically use `sagemaker.session.Session`\n# which provides more high-level abstractions.\n\ntry:\n    sagemaker_session = sagemaker_core.session.Session()\n    region = sagemaker_session.boto_region_name\n    account_id = sagemaker_session.account_id()\n    print(f\"Successfully initialized sagemaker_core.session.Session.\")\n    print(f\"AWS Region: {region}\")\n    print(f\"AWS Account ID: {account_id}\")\n\n    # Example: Get default S3 bucket for SageMaker artifacts\n    default_bucket = sagemaker_session.default_bucket()\n    print(f\"Default S3 bucket: {default_bucket}\")\n\n    # Example: Attempt to get the IAM execution role.\n    # This often works automatically in SageMaker Studio/Notebooks.\n    try:\n        role = sagemaker_session.get_execution_role()\n        print(f\"Execution Role: {role}\")\n    except Exception as e:\n        print(f\"Could not get execution role (expected if not in SM Studio/notebook or roles not configured): {e}\")\n\nexcept Exception as e:\n    print(f\"Error initializing sagemaker_core.session.Session: {e}\")\n    print(\"Ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials, or IAM roles).\")","lang":"python","description":"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."},"warnings":[{"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.","message":"Prefer 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":"All 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.","message":"Older 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.","severity":"gotcha","affected_versions":"`sagemaker-core<3.0.0` (including 2.7.1)"}],"env_vars":null,"search_vec":"'2.7.1':57 'abstract':38 'activ':81 'alongsid':61 'aw':21,43,90 'away':39 'aws/sagemaker-python-sdk':88 'base':47 'class':48 'cloud':98 'compon':51 'core':2,4,7,14,93 'current':54 'depend':29 'distinct':70 'foundat':10 'function':15 'github':84 'higher':33 'higher-level':32 'interact':19,44 'key':28 'larger':87 'learn':97 'level':34,42 'low':41 'low-level':40 'machin':96 'machine-learn':95 'main':63 'maintain':82 'major':76 'ml':92 'monorepo':89 'offer':46 'packag':12 'project':79 'provid':13 'python':11,36 'sagemak':1,3,6,22,35,50,64,73,91 'sagemaker-cor':5 'sdk':37,65,74 'serv':25 'servic':23 'though':66 'typic':59 'updat':60 'util':17,94 'version':56,68,77 'within':85","created_at":"2026-04-09T03:59:25.416996+00:00","updated_at":"2026-04-16T21:17:39.943680+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'Session' from 'sagemaker' (/tmp/tmpnbkrlowc/venv/lib/python3.12/site-packages/sagemaker/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.21.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://aws.amazon.com/sagemaker/","github":"https://github.com/aws/sagemaker-python-sdk","docs":null,"changelog":null,"pypi":"https://pypi.org/project/sagemaker-core/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-08-27","next_check":"2026-07-10","install_tag":null}}