Search code examples
amazon-s3amazon-sagemakeramazon-sagemaker-studio

how to create a model package in sagemaker pipeline?


based on the documentation here , https://github.com/aws/sagemaker-python-sdk/blob/master/doc/amazon_sagemaker_model_building_pipeline.rst#model-step, I can chain sagemaker pipeline step (sample code below) . i want to know , if needed, is it possible to pass the s3 uri , where model is located directly , instead of step_train.properties.ModelArtifacts.S3ModelArtifacts, such that model_data = s3://somebucket/modelfile.tar...

step_train = TrainingStep(...)
model = Model(
    image_uri=pytorch_estimator.training_image_uri(),
    model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
    sagemaker_session=pipeline_session,
    role=role,
)

# we might also want to create a SageMaker Model
step_model_create = ModelStep(
   name="MyModelCreationStep",
   step_args=model.create(instance_type="ml.m5.xlarge"),
)

# in addition, we might also want to register a model to SageMaker Model Registry
register_model_step_args = model.register(
    content_types=["*"],
    response_types=["application/json"],
    inference_instances=["ml.m5.xlarge"],
    transform_instances=["ml.m5.xlarge"],
    description="MyModelPackage",
)

step_model_registration = ModelStep(
   name="MyModelRegistration",
   step_args=register_model_step_args,
)
...

Solution

  • Yes, you can pass the URL directly.