Skip to content

doc: improvements on the docstring of ModelStep #3137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2022
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
21 changes: 15 additions & 6 deletions src/sagemaker/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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 <https://boto3.amazonaws.com/v1/documentation/\
api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags>`_

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have checked this in the pages built by sphinx right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

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(
Expand Down
13 changes: 0 additions & 13 deletions src/sagemaker/workflow/README.rst

This file was deleted.

15 changes: 11 additions & 4 deletions src/sagemaker/workflow/model_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model = Model(sagemaker_session=PipelineSession()) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated it.


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).
Expand Down
7 changes: 1 addition & 6 deletions src/sagemaker/workflow/step_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -256,18 +255,14 @@ 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"
),
DeprecationWarning,
)


RegisterModel = deprecated_class(RegisterModel, "RegisterModel")


class EstimatorTransformer(StepCollection):
"""Creates a Transformer step collection for workflow."""

Expand Down