From 785a89c7a10644292e3da533f6c72f0d40a60703 Mon Sep 17 00:00:00 2001 From: Lucas Jia Date: Mon, 14 Sep 2026 14:26:37 -0700 Subject: [PATCH] docs: Remove V2 code examples from V3 documentation The V3 documentation site showed side-by-side V2/V3 code blocks on the Training, Inference, MLOps, and Lineage Tracking pages. The V2 blocks are complete, runnable examples using removed APIs (Estimator, Model, Predictor, sagemaker.workflow, SKLearnProcessor, sagemaker.lineage), so readers and crawlers could copy code that does not run on V3. Remove the V2 blocks and keep only the V3 examples: - training/index.rst: drop the Estimator/estimator.fit() quick start - inference/index.rst: drop the Model/Predictor/predictor.predict() block - ml_ops/index.rst: drop the "Traditional Pipeline Approach" block - ml_ops/lineage.rst: drop all 9 "V2 (Legacy)" blocks in Use Cases 1-9 On the Lineage page the V2 and V3 blocks were identical apart from the import path, so no information is lost. Where a lead-in sentence framed a V2-to-V3 comparison, it is rewritten to describe the V3 example directly. The V2-to-V3 API mapping tables are intentionally left in place; they are tracked separately for a possible move into migration.md. --- docs/inference/index.rst | 22 +---- docs/ml_ops/index.rst | 26 +----- docs/ml_ops/lineage.rst | 187 --------------------------------------- docs/training/index.rst | 17 ---- 4 files changed, 2 insertions(+), 250 deletions(-) diff --git a/docs/inference/index.rst b/docs/inference/index.rst index 90c9f80057..e1b20c90f5 100644 --- a/docs/inference/index.rst +++ b/docs/inference/index.rst @@ -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 diff --git a/docs/ml_ops/index.rst b/docs/ml_ops/index.rst index a2d4e584bb..81a7b96dd8 100644 --- a/docs/ml_ops/index.rst +++ b/docs/ml_ops/index.rst @@ -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 diff --git a/docs/ml_ops/lineage.rst b/docs/ml_ops/lineage.rst index cc770d6587..f5311430bb 100644 --- a/docs/ml_ops/lineage.rst +++ b/docs/ml_ops/lineage.rst @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/docs/training/index.rst b/docs/training/index.rst index 56995d8200..e2eabfae54 100644 --- a/docs/training/index.rst +++ b/docs/training/index.rst @@ -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