MODELCATALOG

Mental model

Mental model

SageMaker service vs Python SDK

The SDK is the programming interface; SageMaker is the managed AWS service executing the jobs and resources.

Inputs

lifecycle requirement / configuration

Outputs

configured SageMaker object or managed resource

Core explanation

The SDK configures and orchestrates SageMaker resources; the actual training or inference runs on managed AWS infrastructure.

01

Mental model

What this means before worrying about syntax.

Your Python code constructs job/resource configuration. AWS runs the managed training, hosting, processing, registry and monitoring resources.

  • Your local Python process is a control-plane client.
  • Managed SageMaker compute runs training/inference; S3 stores durable data/artifacts.
  • IAM, VPC, KMS and CloudWatch are part of the production architecture.
Lifecycle position
Python SDK -> SageMaker API/resources -> managed AWS compute/storage/networking
02

Implementation anatomy

The sequence you would actually build or configure.

  1. 1

    SDK constructs configuration and calls SageMaker APIs.

  2. 2

    Training jobs receive managed compute and an execution role.

  3. 3

    Endpoints are managed serving resources; batch jobs are finite jobs.

Objects / terms worth remembering
SessionIAM roleS3Training JobEndpoint
03

Concrete example

A real model-development or production flow.

1

PyCharm/notebook submits job

↓
2

S3 holds train/validation data

↓
3

Managed training instance runs container

↓
4

Artifact is uploaded to S3

↓
5

Managed endpoint runs inference container

04

Implementation lab

Concrete code, data manipulation and configuration for this lifecycle step.

01

Control plane: your Python code submits a managed job

python
from sagemaker.core.helper.session_helper import Session
from sagemaker.train import ModelTrainer
from sagemaker.train.configs import SourceCode

session = Session()

trainer = ModelTrainer(
    training_image=TRAINING_IMAGE_URI,
    source_code=SourceCode(
        source_dir="src",
        entry_script="train.py",
    ),
    role=SAGEMAKER_ROLE_ARN,
    sagemaker_session=session,
)

# This call submits work to the SageMaker service.
trainer.train(input_data_config=inputs)
02

Data plane: code running inside the training container

python

This is the practical boundary: the SDK is outside the job; train.py executes inside the job container.

# train.py -- this code runs on the managed training instance.
import os

train_dir = os.environ["SM_CHANNEL_TRAIN"]
model_dir = os.environ["SM_MODEL_DIR"]

print("training data mounted at:", train_dir)
print("model output must be written to:", model_dir)

Design decisions that matter

  • Keep local-development assumptions separate from production execution.
  • Design IAM/networking independently of model logic.

Common failure modes

  • Local files/imports do not automatically exist in managed containers.
  • SDK version on your laptop and framework version inside the image are separate concerns.

Production readiness check

Items to close before treating this step as production-ready.

✓ IAM role✓ S3 access✓ container image✓ network path✓ CloudWatch logs