Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions docs/inference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,7 @@ Key Benefits of V3 Inference
Quick Start Example
-------------------

Here's how inference has evolved from V2 to V3:

**SageMaker Python SDK V2:**

.. code-block:: python

from sagemaker.model import Model
from sagemaker.predictor import Predictor

model = Model(
image_uri="my-inference-image",
model_data="s3://my-bucket/model.tar.gz",
role="arn:aws:iam::123456789012:role/SageMakerRole"
)
predictor = model.deploy(
initial_instance_count=1,
instance_type="ml.m5.xlarge"
)
result = predictor.predict(data)

**SageMaker Python SDK V3:**
Build, deploy, and invoke a model with ``ModelBuilder``:

.. code-block:: python

Expand Down
26 changes: 1 addition & 25 deletions docs/ml_ops/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,7 @@ Key Benefits of V3 ML Operations
Quick Start Example
-------------------

Here's how ML Operations workflows are simplified in V3:

**Traditional Pipeline Approach:**

.. code-block:: python

from sagemaker.workflow.pipeline import Pipeline
from sagemaker.workflow.steps import TrainingStep, ProcessingStep
from sagemaker.sklearn.processing import SKLearnProcessor

# Complex setup with multiple framework-specific classes
processor = SKLearnProcessor(
framework_version="0.23-1",
role=role,
instance_type="ml.m5.xlarge",
instance_count=1
)

processing_step = ProcessingStep(
name="PreprocessData",
processor=processor,
# ... many configuration parameters
)

**SageMaker V3 MLOps Approach:**
Define a pipeline and add a processing step:

.. code-block:: python

Expand Down
187 changes: 0 additions & 187 deletions docs/ml_ops/lineage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ Use Case 1: Session Setup

Initialize a SageMaker session and set up common variables.

**V2 (Legacy):**

.. code-block:: python

import boto3
import sagemaker

region = boto3.Session().region_name
sagemaker_session = sagemaker.session.Session()
default_bucket = sagemaker_session.default_bucket()

**V3:**

.. code-block:: python

import boto3
Expand All @@ -87,25 +74,6 @@ Use Case 2: Creating a Lineage Context

Contexts provide a method to logically group other lineage entities. Each context name must be unique across all other contexts.

**V2 (Legacy):**

.. code-block:: python

from datetime import datetime
from sagemaker.lineage.context import Context

unique_id = str(int(datetime.now().replace(microsecond=0).timestamp()))
context_name = f"machine-learning-workflow-{unique_id}"

ml_workflow_context = Context.create(
context_name=context_name,
context_type="MLWorkflow",
source_uri=unique_id,
properties={"example": "true"},
)

**V3:**

.. code-block:: python

from datetime import datetime
Expand All @@ -127,18 +95,6 @@ Use Case 3: Listing Contexts

Enumerate existing contexts sorted by creation time.

**V2 (Legacy):**

.. code-block:: python

from sagemaker.lineage.context import Context

contexts = Context.list(sort_by="CreationTime", sort_order="Descending")
for ctx in contexts:
print(ctx.context_name)

**V3:**

.. code-block:: python

from sagemaker.core.lineage.context import Context
Expand All @@ -153,21 +109,6 @@ Use Case 4: Creating an Action

Actions represent computational steps such as model builds, transformations, or training jobs.

**V2 (Legacy):**

.. code-block:: python

from sagemaker.lineage.action import Action

model_build_action = Action.create(
action_name=f"model-build-step-{unique_id}",
action_type="ModelBuild",
source_uri=unique_id,
properties={"Example": "Metadata"},
)

**V3:**

.. code-block:: python

from sagemaker.core.lineage.action import Action
Expand All @@ -185,20 +126,6 @@ Use Case 5: Creating Associations

Associations are directed edges in the lineage graph. The ``association_type`` can be ``Produced``, ``DerivedFrom``, ``AssociatedWith``, or ``ContributedTo``.

**V2 (Legacy):**

.. code-block:: python

from sagemaker.lineage.association import Association

context_action_association = Association.create(
source_arn=ml_workflow_context.context_arn,
destination_arn=model_build_action.action_arn,
association_type="AssociatedWith",
)

**V3:**

.. code-block:: python

from sagemaker.core.lineage.association import Association
Expand All @@ -216,24 +143,6 @@ Use Case 6: Traversing Associations

Query incoming and outgoing associations to understand how entities are related in the lineage graph.

**V2 (Legacy):**

.. code-block:: python

from sagemaker.lineage.association import Association

# List incoming associations to an action
incoming = Association.list(destination_arn=model_build_action.action_arn)
for association in incoming:
print(f"{model_build_action.action_name} has incoming association from {association.source_name}")

# List outgoing associations from a context
outgoing = Association.list(source_arn=ml_workflow_context.context_arn)
for association in outgoing:
print(f"{ml_workflow_context.context_name} has outgoing association to {association.destination_name}")

**V3:**

.. code-block:: python

from sagemaker.core.lineage.association import Association
Expand All @@ -254,35 +163,6 @@ Use Case 7: Creating Artifacts

Artifacts represent URI-addressable objects or data, such as datasets, labels, or trained models.

**V2 (Legacy):**

.. code-block:: python

from sagemaker.lineage.artifact import Artifact

input_test_images = Artifact.create(
artifact_name="mnist-test-images",
artifact_type="TestData",
source_types=[{"SourceIdType": "Custom", "Value": unique_id}],
source_uri=f"https://sagemaker-example-files-prod-{region}.s3.amazonaws.com/datasets/image/MNIST/t10k-images-idx3-ubyte.gz",
)

input_test_labels = Artifact.create(
artifact_name="mnist-test-labels",
artifact_type="TestLabels",
source_types=[{"SourceIdType": "Custom", "Value": unique_id}],
source_uri=f"https://sagemaker-example-files-prod-{region}.s3.amazonaws.com/datasets/image/MNIST/t10k-labels-idx1-ubyte.gz",
)

output_model = Artifact.create(
artifact_name="mnist-model",
artifact_type="Model",
source_types=[{"SourceIdType": "Custom", "Value": unique_id}],
source_uri=f"https://sagemaker-example-files-prod-{region}.s3.amazonaws.com/datasets/image/MNIST/model/tensorflow-training-2020-11-20-23-57-13-077/model.tar.gz",
)

**V3:**

.. code-block:: python

from sagemaker.core.lineage.artifact import Artifact
Expand Down Expand Up @@ -314,30 +194,6 @@ Use Case 8: Linking Artifacts to Actions

Associate data artifacts as inputs to an action, and the action's output to a model artifact, forming a complete lineage chain.

**V2 (Legacy):**

.. code-block:: python

from sagemaker.lineage.association import Association

# Link input data to the model build action
Association.create(
source_arn=input_test_images.artifact_arn,
destination_arn=model_build_action.action_arn,
)
Association.create(
source_arn=input_test_labels.artifact_arn,
destination_arn=model_build_action.action_arn,
)

# Link the action output to the model artifact
Association.create(
source_arn=model_build_action.action_arn,
destination_arn=output_model.artifact_arn,
)

**V3:**

.. code-block:: python

from sagemaker.core.lineage.association import Association
Expand All @@ -364,49 +220,6 @@ Use Case 9: Cleaning Up Lineage Data

Delete associations first, then delete the entities themselves. Associations must be removed before their source or destination entities can be deleted.

**V2 (Legacy):**

.. code-block:: python

import sagemaker
from sagemaker.lineage.association import Association
from sagemaker.lineage.context import Context
from sagemaker.lineage.action import Action
from sagemaker.lineage.artifact import Artifact

sagemaker_session = sagemaker.session.Session()

def delete_associations(arn):
for summary in Association.list(destination_arn=arn):
assct = Association(
source_arn=summary.source_arn,
destination_arn=summary.destination_arn,
sagemaker_session=sagemaker_session,
)
assct.delete()
for summary in Association.list(source_arn=arn):
assct = Association(
source_arn=summary.source_arn,
destination_arn=summary.destination_arn,
sagemaker_session=sagemaker_session,
)
assct.delete()

# Delete context
delete_associations(ml_workflow_context.context_arn)
Context(context_name=ml_workflow_context.context_name, sagemaker_session=sagemaker_session).delete()

# Delete action
delete_associations(model_build_action.action_arn)
Action(action_name=model_build_action.action_name, sagemaker_session=sagemaker_session).delete()

# Delete artifacts
for artifact in [input_test_images, input_test_labels, output_model]:
delete_associations(artifact.artifact_arn)
Artifact(artifact_arn=artifact.artifact_arn, sagemaker_session=sagemaker_session).delete()

**V3:**

.. code-block:: python

from sagemaker.core.helper.session_helper import Session
Expand Down
17 changes: 0 additions & 17 deletions docs/training/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ Key Benefits of V3 Training
Quick Start Example
-------------------

**SageMaker Python SDK V2:**

.. code-block:: python

from sagemaker.estimator import Estimator

estimator = Estimator(
image_uri="my-training-image",
role="arn:aws:iam::123456789012:role/SageMakerRole",
instance_count=1,
instance_type="ml.m5.xlarge",
output_path="s3://my-bucket/output"
)
estimator.fit({"training": "s3://my-bucket/train"})

**SageMaker Python SDK V3:**

.. code-block:: python

from sagemaker.train import ModelTrainer
Expand Down
Loading