Skip to content

Commit b2d4744

Browse files
navaj0Zhankuil
andauthored
doc: improvements on the docstring of ModelStep (#3137)
Co-authored-by: Zhankui Lu <[email protected]>
1 parent dc7f4d5 commit b2d4744

File tree

4 files changed

+27
-29
lines changed

4 files changed

+27
-29
lines changed

src/sagemaker/model.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ def register(
341341
"MACHINE_LEARNING" (default: None).
342342
343343
Returns:
344-
A `sagemaker.model.ModelPackage` instance.
344+
A `sagemaker.model.ModelPackage` instance or pipeline step arguments
345+
in case the Model instance is built with
346+
:class:`~sagemaker.workflow.pipeline_context.PipelineSession`
345347
"""
346348
if self.model_data is None:
347349
raise ValueError("SageMaker Model Package cannot be created without model data.")
@@ -398,15 +400,22 @@ def create(
398400
attach to an endpoint for model loading and inference, for
399401
example, 'ml.eia1.medium'. If not specified, no Elastic
400402
Inference accelerator will be attached to the endpoint (default: None).
401-
serverless_inference_config (sagemaker.serverless.ServerlessInferenceConfig):
403+
serverless_inference_config (ServerlessInferenceConfig):
402404
Specifies configuration related to serverless endpoint. Instance type is
403405
not provided in serverless inference. So this is used to find image URIs
404406
(default: None).
405407
tags (List[Dict[str, str]]): The list of tags to add to
406-
the model (default: None). Example: >>> tags = [{'Key': 'tagname', 'Value':
407-
'tagvalue'}] For more information about tags, see
408-
https://boto3.amazonaws.com/v1/documentation
409-
/api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags
408+
the model (default: None). Example::
409+
410+
tags = [{'Key': 'tagname', 'Value':'tagvalue'}]
411+
412+
For more information about tags, see
413+
`boto3 documentation <https://boto3.amazonaws.com/v1/documentation/\
414+
api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags>`_
415+
416+
Returns:
417+
None or pipeline step arguments in case the Model instance is built with
418+
:class:`~sagemaker.workflow.pipeline_context.PipelineSession`
410419
"""
411420
# TODO: we should replace _create_sagemaker_model() with create()
412421
self._create_sagemaker_model(

src/sagemaker/workflow/README.rst

-13
This file was deleted.

src/sagemaker/workflow/model_step.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,17 @@ def __init__(
5050
Args:
5151
name (str): The name of the `ModelStep`. A name is required and must be
5252
unique within a pipeline.
53-
step_args (_ModelStepArguments): The arguments for the `ModelStep` definition.
54-
depends_on (List[Union[str, Step, StepCollection]]): A list of `Step`/`StepCollection`
55-
names or `Step` instances or `StepCollection` instances that the first step,
56-
in this `ModelStep` collection, depends on.
53+
step_args (_ModelStepArguments): The arguments for the `ModelStep` definition,
54+
generated by invoking the :func:`~sagemaker.model.Model.register` or
55+
:func:`~sagemaker.model.Model.create`
56+
under the :class:`~sagemaker.workflow.pipeline_context.PipelineSession`. Example::
57+
58+
model = Model(sagemaker_session=PipelineSession())
59+
model_step = ModelStep(step_args=model.register())
60+
61+
depends_on (List[Union[str, Step, StepCollection]]):
62+
A list of `Step` or `StepCollection`
63+
names or `Step` instances or `StepCollection` instances that it depends on.
5764
If a listed `Step` name does not exist, an error is returned (default: None).
5865
retry_policies (List[RetryPolicy] or Dict[str, List[RetryPolicy]]): The list of retry
5966
policies for the `ModelStep` (default: None).

src/sagemaker/workflow/step_collections.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import attr
2020

21-
from sagemaker.deprecations import deprecated_class
2221
from sagemaker.estimator import EstimatorBase
2322
from sagemaker.model import Model
2423
from sagemaker import PipelineModel
@@ -262,18 +261,14 @@ def __init__(
262261
warnings.warn(
263262
(
264263
"We are deprecating the use of RegisterModel. "
265-
"Instead, please use the ModelStep, which simply takes in the step arguments "
266-
"generated by model.register(). For more, see: "
264+
"Please use the ModelStep instead. For more, see: "
267265
"https://sagemaker.readthedocs.io/en/stable/"
268266
"amazon_sagemaker_model_building_pipeline.html#model-step"
269267
),
270268
DeprecationWarning,
271269
)
272270

273271

274-
RegisterModel = deprecated_class(RegisterModel, "RegisterModel")
275-
276-
277272
class EstimatorTransformer(StepCollection):
278273
"""Creates a Transformer step collection for workflow."""
279274

0 commit comments

Comments
 (0)