From 6cb845cbc04658faf83313645cdb6e81de797188 Mon Sep 17 00:00:00 2001 From: Zhankui Lu Date: Wed, 25 May 2022 12:43:04 -0700 Subject: [PATCH] doc: improvements on the docstring of ModelStep --- src/sagemaker/model.py | 21 +++++++++++++++------ src/sagemaker/workflow/README.rst | 13 ------------- src/sagemaker/workflow/model_step.py | 15 +++++++++++---- src/sagemaker/workflow/step_collections.py | 7 +------ 4 files changed, 27 insertions(+), 29 deletions(-) delete mode 100644 src/sagemaker/workflow/README.rst diff --git a/src/sagemaker/model.py b/src/sagemaker/model.py index b456b452f8..f617c53f39 100644 --- a/src/sagemaker/model.py +++ b/src/sagemaker/model.py @@ -341,7 +341,9 @@ def register( "MACHINE_LEARNING" (default: None). Returns: - A `sagemaker.model.ModelPackage` instance. + A `sagemaker.model.ModelPackage` instance or pipeline step arguments + in case the Model instance is built with + :class:`~sagemaker.workflow.pipeline_context.PipelineSession` """ if self.model_data is None: raise ValueError("SageMaker Model Package cannot be created without model data.") @@ -399,15 +401,22 @@ def create( attach to an endpoint for model loading and inference, for example, 'ml.eia1.medium'. If not specified, no Elastic Inference accelerator will be attached to the endpoint (default: None). - serverless_inference_config (sagemaker.serverless.ServerlessInferenceConfig): + serverless_inference_config (ServerlessInferenceConfig): Specifies configuration related to serverless endpoint. Instance type is not provided in serverless inference. So this is used to find image URIs (default: None). tags (List[Dict[str, str]]): The list of tags to add to - the model (default: None). Example: >>> tags = [{'Key': 'tagname', 'Value': - 'tagvalue'}] For more information about tags, see - https://boto3.amazonaws.com/v1/documentation - /api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags + the model (default: None). Example:: + + tags = [{'Key': 'tagname', 'Value':'tagvalue'}] + + For more information about tags, see + `boto3 documentation `_ + + Returns: + None or pipeline step arguments in case the Model instance is built with + :class:`~sagemaker.workflow.pipeline_context.PipelineSession` """ # TODO: we should replace _create_sagemaker_model() with create() self._create_sagemaker_model( diff --git a/src/sagemaker/workflow/README.rst b/src/sagemaker/workflow/README.rst deleted file mode 100644 index 84a8077a7d..0000000000 --- a/src/sagemaker/workflow/README.rst +++ /dev/null @@ -1,13 +0,0 @@ -==================================== -SageMaker Workflow in Apache Airflow -==================================== - -Apache Airflow -~~~~~~~~~~~~~~ - -`Apache Airflow `_ -is a platform that enables you to programmatically author, schedule, and monitor workflows. Using Airflow, -you can build a workflow for SageMaker training, hyperparameter tuning, batch transform and endpoint deployment. -You can use any SageMaker deep learning framework or Amazon algorithms to perform above operations in Airflow. - -For information about using SageMaker Workflow, see https://sagemaker.readthedocs.io/en/stable/using_workflow.html. diff --git a/src/sagemaker/workflow/model_step.py b/src/sagemaker/workflow/model_step.py index e88216b0bb..e46fd71a84 100644 --- a/src/sagemaker/workflow/model_step.py +++ b/src/sagemaker/workflow/model_step.py @@ -50,10 +50,17 @@ def __init__( Args: name (str): The name of the `ModelStep`. A name is required and must be unique within a pipeline. - step_args (_ModelStepArguments): The arguments for the `ModelStep` definition. - depends_on (List[Union[str, Step, StepCollection]]): A list of `Step`/`StepCollection` - names or `Step` instances or `StepCollection` instances that the first step, - in this `ModelStep` collection, depends on. + step_args (_ModelStepArguments): The arguments for the `ModelStep` definition, + generated by invoking the :func:`~sagemaker.model.Model.register` or + :func:`~sagemaker.model.Model.create` + under the :class:`~sagemaker.workflow.pipeline_context.PipelineSession`. Example:: + + model = Model(sagemaker_session=PipelineSession()) + model_step = ModelStep(step_args=model.register()) + + depends_on (List[Union[str, Step, StepCollection]]): + A list of `Step` or `StepCollection` + names or `Step` instances or `StepCollection` instances that it depends on. If a listed `Step` name does not exist, an error is returned (default: None). retry_policies (List[RetryPolicy] or Dict[str, List[RetryPolicy]]): The list of retry policies for the `ModelStep` (default: None). diff --git a/src/sagemaker/workflow/step_collections.py b/src/sagemaker/workflow/step_collections.py index 8a88b7d39e..3ba7e276ca 100644 --- a/src/sagemaker/workflow/step_collections.py +++ b/src/sagemaker/workflow/step_collections.py @@ -18,7 +18,6 @@ import attr -from sagemaker.deprecations import deprecated_class from sagemaker.estimator import EstimatorBase from sagemaker.model import Model from sagemaker import PipelineModel @@ -256,8 +255,7 @@ def __init__( warnings.warn( ( "We are deprecating the use of RegisterModel. " - "Instead, please use the ModelStep, which simply takes in the step arguments " - "generated by model.register(). For more, see: " + "Please use the ModelStep instead. For more, see: " "https://sagemaker.readthedocs.io/en/stable/" "amazon_sagemaker_model_building_pipeline.html#model-step" ), @@ -265,9 +263,6 @@ def __init__( ) -RegisterModel = deprecated_class(RegisterModel, "RegisterModel") - - class EstimatorTransformer(StepCollection): """Creates a Transformer step collection for workflow."""