Skip to content

Commit d8aa976

Browse files
evakravimufaddal-rohawalaBasil BeiroutiPayton Staubahsan-z-khan
committed
documentation: Jumpstart doc strings and added new sections (#2893)
Co-authored-by: Mufaddal Rohawala <[email protected]> Co-authored-by: Basil Beirouti <[email protected]> Co-authored-by: Payton Staub <[email protected]> Co-authored-by: Ahsan Khan <[email protected]> Co-authored-by: Shreya Pandit <[email protected]> Co-authored-by: Mufaddal Rohawala <[email protected]> Co-authored-by: Basil Beirouti <[email protected]> Co-authored-by: Payton Staub <[email protected]> Co-authored-by: Mohamed Ali Jamaoui <[email protected]> Co-authored-by: ci <ci> Co-authored-by: Jeniya Tabassum <[email protected]> Co-authored-by: sreedes <[email protected]> Co-authored-by: Navin Soni <[email protected]> Co-authored-by: Miyoung <[email protected]> Co-authored-by: Ameen Khan <[email protected]> Co-authored-by: Zhankui Lu <[email protected]> Co-authored-by: Xiaoguang Chen <[email protected]> Co-authored-by: Jonathan Guinegagne <[email protected]> Co-authored-by: Zhankui Lu <[email protected]> Co-authored-by: Yifei Zhu <[email protected]> Co-authored-by: Qingzi-Lan <[email protected]> Co-authored-by: Navin Soni <[email protected]> Co-authored-by: Xinghan Chen <[email protected]> Co-authored-by: Ivy Bazan <[email protected]> Co-authored-by: IvyBazan <[email protected]>
1 parent 7a27142 commit d8aa976

11 files changed

+230
-196
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Environment Variables
2+
---------------------
3+
4+
.. automodule:: sagemaker.environment_variables
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

doc/api/utility/hyperparameters.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Hyperparameters
2+
---------------
3+
4+
.. automodule:: sagemaker.hyperparameters
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

doc/api/utility/model_uris.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Model URIs
2+
----------
3+
4+
.. automodule:: sagemaker.model_uris
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

doc/api/utility/script_uris.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Script URIs
2+
-----------
3+
4+
.. automodule:: sagemaker.script_uris
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

src/sagemaker/environment_variables.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def retrieve_default(
3131
"""Retrieves the default container environment variables for the model matching the arguments.
3232
3333
Args:
34-
region (str): Optional. Region for which to retrieve default environment variables.
35-
(Default: None).
36-
model_id (str): Optional. Model ID of the model for which to
34+
region (str): Optional. The AWS Region for which to retrieve the default environment
35+
variables. (Default: None).
36+
model_id (str): Optional. The model ID of the model for which to
3737
retrieve the default environment variables. (Default: None).
38-
model_version (str): Optional. Version of the model for which to retrieve the
38+
model_version (str): Optional. The version of the model for which to retrieve the
3939
default environment variables. (Default: None).
4040
Returns:
41-
dict: the variables to use for the model.
41+
dict: The variables to use for the model.
4242
4343
Raises:
4444
ValueError: If the combination of arguments specified is not supported.

src/sagemaker/estimator.py

+108-106
Large diffs are not rendered by default.

src/sagemaker/hyperparameters.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,21 @@ def retrieve_default(
3434
"""Retrieves the default training hyperparameters for the model matching the given arguments.
3535
3636
Args:
37-
region (str): Region for which to retrieve default hyperparameters. (Default: None).
38-
model_id (str): Model ID of the model for which to
37+
region (str): The AWS Region for which to retrieve the default hyperparameters.
38+
Defaults to ``None``.
39+
model_id (str): The model ID of the model for which to
3940
retrieve the default hyperparameters. (Default: None).
40-
model_version (str): Version of the model for which to retrieve the
41+
model_version (str): The version of the model for which to retrieve the
4142
default hyperparameters. (Default: None).
42-
include_container_hyperparameters (bool): True if container hyperparameters
43-
should be returned as well. Container hyperparameters are not used to tune
44-
the specific algorithm, but rather by SageMaker Training to setup
43+
include_container_hyperparameters (bool): ``True`` if the container hyperparameters
44+
should be returned. Container hyperparameters are not used to tune
45+
the specific algorithm. They are used by SageMaker Training jobs to set up
4546
the training container environment. For example, there is a container hyperparameter
4647
that indicates the entrypoint script to use. These hyperparameters may be required
4748
when creating a training job with boto3, however the ``Estimator`` classes
48-
should take care of adding container hyperparameters to the job. (Default: False).
49+
add required container hyperparameters to the job. (Default: False).
4950
Returns:
50-
dict: the hyperparameters to use for the model.
51+
dict: The hyperparameters to use for the model.
5152
5253
Raises:
5354
ValueError: If the combination of arguments specified is not supported.
@@ -69,22 +70,22 @@ def validate(
6970
hyperparameters: Optional[dict] = None,
7071
validation_mode: Optional[HyperparameterValidationMode] = None,
7172
) -> None:
72-
"""Validate hyperparameters for models.
73+
"""Validates hyperparameters for models.
7374
7475
Args:
75-
region (str): Region for which to validate hyperparameters. (Default: None).
76-
model_id (str): Model ID of the model for which to validate hyperparameters.
77-
(Default: None)
78-
model_version (str): Version of the model for which to validate hyperparameters.
79-
(Default: None)
76+
region (str): The AWS Region for which to validate hyperparameters. (Default: None).
77+
model_id (str): The model ID of the model for which to validate hyperparameters.
78+
(Default: None).
79+
model_version (str): The version of the model for which to validate hyperparameters.
80+
(Default: None).
8081
hyperparameters (dict): Hyperparameters to validate.
81-
(Default: None)
82+
(Default: None).
8283
validation_mode (HyperparameterValidationMode): Method of validation to use with
8384
hyperparameters. If set to ``VALIDATE_PROVIDED``, only hyperparameters provided
8485
to this function will be validated, the missing hyperparameters will be ignored.
8586
If set to``VALIDATE_ALGORITHM``, all algorithm hyperparameters will be validated.
8687
If set to ``VALIDATE_ALL``, all hyperparameters for the model will be validated.
87-
(Default: None)
88+
(Default: None).
8889
8990
Raises:
9091
JumpStartHyperparametersError: If the hyperparameter is not formatted correctly,

src/sagemaker/image_uris.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,20 @@ def retrieve(
7777
training_compiler_config (:class:`~sagemaker.training_compiler.TrainingCompilerConfig`):
7878
A configuration class for the SageMaker Training Compiler
7979
(default: None).
80-
model_id (str): JumpStart model ID for which to retrieve image URI
80+
model_id (str): The JumpStart model ID for which to retrieve the image URI
8181
(default: None).
82-
model_version (str): Version of the JumpStart model for which to retrieve the
82+
model_version (str): The version of the JumpStart model for which to retrieve the
8383
image URI (default: None).
84-
tolerate_vulnerable_model (bool): True if vulnerable versions of model specifications
85-
should be tolerated (exception not raised). If False, raises an exception if
84+
tolerate_vulnerable_model (bool): ``True`` if vulnerable versions of model specifications
85+
should be tolerated without an exception raised. If ``False``, raises an exception if
8686
the script used by this version of the model has dependencies with known security
8787
vulnerabilities. (Default: False).
8888
tolerate_deprecated_model (bool): True if deprecated versions of model specifications
89-
should be tolerated (exception not raised). If False, raises an exception
89+
should be tolerated without an exception raised. If False, raises an exception
9090
if the version of the model is deprecated. (Default: False).
9191
9292
Returns:
93-
str: the ECR URI for the corresponding SageMaker Docker image.
93+
str: The ECR URI for the corresponding SageMaker Docker image.
9494
9595
Raises:
9696
NotImplementedError: If the scope is not supported.
@@ -404,26 +404,26 @@ def get_training_image_uri(
404404
pytorch_version=None,
405405
instance_type=None,
406406
) -> str:
407-
"""Retrieve image uri for training.
407+
"""Retrieves the image URI for training.
408408
409409
Args:
410-
region (str): AWS region to use for image URI.
410+
region (str): The AWS region to use for image URI.
411411
framework (str): The framework for which to retrieve an image URI.
412412
framework_version (str): The framework version for which to retrieve an
413413
image URI (default: None).
414414
py_version (str): The python version to use for the image (default: None).
415-
image_uri (str): If an image URI is supplied, it will be returned (default: None).
415+
image_uri (str): If an image URI is supplied, it is returned (default: None).
416416
distribution (dict): A dictionary with information on how to run distributed
417417
training (default: None).
418418
compiler_config (:class:`~sagemaker.training_compiler.TrainingCompilerConfig`):
419419
A configuration class for the SageMaker Training Compiler
420420
(default: None).
421-
tensorflow_version (str): Version of tensorflow to use. (default: None)
422-
pytorch_version (str): Version of pytorch to use. (default: None)
423-
instance_type (str): Instance type fo use. (default: None)
421+
tensorflow_version (str): The version of TensorFlow to use. (default: None)
422+
pytorch_version (str): The version of PyTorch to use. (default: None)
423+
instance_type (str): The instance type to use. (default: None)
424424
425425
Returns:
426-
str: the image URI string.
426+
str: The image URI string.
427427
"""
428428

429429
if image_uri:

src/sagemaker/model.py

+38-35
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ def __init__(
135135
model container is pulled from ECR, or private registry in your
136136
VPC. By default it is set to pull model container image from
137137
ECR. (default: None).
138-
source_dir (str): Path (absolute, relative or an S3 URI) to a directory
138+
source_dir (str): The absolute, relative, or S3 URI Path to a directory
139139
with any other training source code dependencies aside from the entry
140140
point file (default: None). If ``source_dir`` is an S3 URI, it must
141-
point to a tar.gz file. Structure within this directory are preserved
141+
point to a tar.gz file. Structure within this directory is preserved
142142
when training on Amazon SageMaker. If 'git_config' is provided,
143143
'source_dir' should be a relative location to a directory in the Git repo.
144-
If the directory points to S3, no code will be uploaded and the S3 location
145-
will be used instead.
144+
If the directory points to S3, no code is uploaded and the S3 location
145+
is used instead.
146146
147147
.. admonition:: Example
148148
@@ -155,14 +155,14 @@ def __init__(
155155
156156
You can assign entry_point='inference.py', source_dir='src'.
157157
code_location (str): Name of the S3 bucket where custom code is
158-
uploaded (default: None). If not specified, default bucket
158+
uploaded (default: None). If not specified, the default bucket
159159
created by ``sagemaker.session.Session`` is used.
160-
entry_point (str): Path (absolute or relative) to the Python source
161-
file which should be executed as the entry point to model
162-
hosting (default: None). If ``source_dir`` is specified,
163-
then ``entry_point`` must point to a file located at the root of
164-
``source_dir``. If 'git_config' is provided, 'entry_point' should
165-
be a relative location to the Python source file in the Git repo.
160+
entry_point (str): The absolute or relative path to the local Python
161+
source file that should be executed as the entry point to
162+
model hosting. (Default: None). If ``source_dir`` is specified, then ``entry_point``
163+
must point to a file located at the root of ``source_dir``.
164+
If 'git_config' is provided, 'entry_point' should be
165+
a relative location to the Python source file in the Git repo.
166166
167167
Example:
168168
With the following GitHub repo directory structure:
@@ -176,9 +176,9 @@ def __init__(
176176
container_log_level (int): Log level to use within the container
177177
(default: logging.INFO). Valid values are defined in the Python
178178
logging module.
179-
dependencies (list[str]): A list of paths to directories (absolute
180-
or relative) with any additional libraries that will be exported
181-
to the container (default: []). The library folders will be
179+
dependencies (list[str]): A list of absolute or relative paths to directories
180+
with any additional libraries that should be exported
181+
to the container (default: []). The library folders are
182182
copied to SageMaker in the same folder where the entrypoint is
183183
copied. If 'git_config' is provided, 'dependencies' should be a
184184
list of relative locations to directories with any additional
@@ -193,7 +193,7 @@ def __init__(
193193
>>> Model(entry_point='inference.py',
194194
... dependencies=['my/libs/common', 'virtual-env'])
195195
196-
results in the following inside the container:
196+
results in the following structure inside the container:
197197
198198
>>> $ ls
199199
@@ -210,7 +210,9 @@ def __init__(
210210
``repo`` specifies the Git repository where your training script
211211
is stored. If you don't provide ``branch``, the default value
212212
'master' is used. If you don't provide ``commit``, the latest
213-
commit in the specified branch is used. .. admonition:: Example
213+
commit in the specified branch is used.
214+
215+
.. admonition:: Example
214216
215217
The following config:
216218
@@ -219,7 +221,7 @@ def __init__(
219221
>>> 'commit': '329bfcf884482002c05ff7f44f62599ebc9f445a'}
220222
221223
results in cloning the repo specified in 'repo', then
222-
checkout the 'master' branch, and checkout the specified
224+
checking out the 'master' branch, and checking out the specified
223225
commit.
224226
225227
``2FA_enabled``, ``username``, ``password`` and ``token`` are
@@ -232,26 +234,25 @@ def __init__(
232234
repositories.
233235
234236
For GitHub and other Git repos, when SSH URLs are provided, it
235-
doesn't matter whether 2FA is enabled or disabled; you should
236-
either have no passphrase for the SSH key pairs, or have the
237-
ssh-agent configured so that you will not be prompted for SSH
238-
passphrase when you do 'git clone' command with SSH URLs. When
239-
HTTPS URLs are provided: if 2FA is disabled, then either token
240-
or username+password will be used for authentication if provided
241-
(token prioritized); if 2FA is enabled, only token will be used
237+
doesn't matter whether 2FA is enabled or disabled. You should
238+
either have no passphrase for the SSH key pairs or have the
239+
ssh-agent configured so that you will not be prompted for the SSH
240+
passphrase when you run the 'git clone' command with SSH URLs. When
241+
HTTPS URLs are provided, if 2FA is disabled, then either ``token``
242+
or ``username`` and ``password`` are be used for authentication if provided.
243+
``Token`` is prioritized. If 2FA is enabled, only ``token`` is used
242244
for authentication if provided. If required authentication info
243-
is not provided, python SDK will try to use local credentials
244-
storage to authenticate. If that fails either, an error message
245-
will be thrown.
245+
is not provided, the SageMaker Python SDK attempts to use local credentials
246+
to authenticate. If that fails, an error message is thrown.
246247
247-
For CodeCommit repos, 2FA is not supported, so '2FA_enabled'
248+
For CodeCommit repos, 2FA is not supported, so ``2FA_enabled``
248249
should not be provided. There is no token in CodeCommit, so
249-
'token' should not be provided too. When 'repo' is an SSH URL,
250-
the requirements are the same as GitHub-like repos. When 'repo'
251-
is an HTTPS URL, username+password will be used for
252-
authentication if they are provided; otherwise, python SDK will
253-
try to use either CodeCommit credential helper or local
254-
credential storage for authentication.
250+
``token`` should also not be provided. When ``repo`` is an SSH URL,
251+
the requirements are the same as GitHub repos. When ``repo``
252+
is an HTTPS URL, ``username`` and ``password`` are used for
253+
authentication if they are provided. If they are not provided,
254+
the SageMaker Python SDK attempts to use either the CodeCommit
255+
credential helper or local credential storage for authentication.
255256
256257
"""
257258
self.model_data = model_data
@@ -1313,7 +1314,9 @@ def __init__(
13131314
``repo`` specifies the Git repository where your training script
13141315
is stored. If you don't provide ``branch``, the default value
13151316
'master' is used. If you don't provide ``commit``, the latest
1316-
commit in the specified branch is used. .. admonition:: Example
1317+
commit in the specified branch is used.
1318+
1319+
.. admonition:: Example
13171320
13181321
The following config:
13191322

src/sagemaker/model_uris.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
13-
"""Accessors to retrieve the model artifact S3 URI of pretrained ML models."""
13+
"""Accessors to retrieve the model artifact S3 URI of pretrained machine learning models."""
1414
from __future__ import absolute_import
1515

1616
import logging
@@ -31,25 +31,25 @@ def retrieve(
3131
tolerate_vulnerable_model: bool = False,
3232
tolerate_deprecated_model: bool = False,
3333
) -> str:
34-
"""Retrieves the model artifact S3 URI for the model matching the given arguments.
34+
"""Retrieves the model artifact Amazon S3 URI for the model matching the given arguments.
3535
3636
Args:
37-
region (str): Region for which to retrieve model S3 URI.
38-
model_id (str): JumpStart model ID of the JumpStart model for which to retrieve
37+
region (str): The AWS Region for which to retrieve the Jumpstart model S3 URI.
38+
model_id (str): The model ID of the JumpStart model for which to retrieve
3939
the model artifact S3 URI.
40-
model_version (str): Version of the JumpStart model for which to retrieve
40+
model_version (str): The version of the JumpStart model for which to retrieve
4141
the model artifact S3 URI.
42-
model_scope (str): The model type, i.e. what it is used for.
42+
model_scope (str): The model type.
4343
Valid values: "training" and "inference".
44-
tolerate_vulnerable_model (bool): True if vulnerable versions of model
45-
specifications should be tolerated (exception not raised). If False, raises an
44+
tolerate_vulnerable_model (bool): ``True`` if vulnerable versions of model
45+
specifications should be tolerated without raising an exception. If ``False``, raises an
4646
exception if the script used by this version of the model has dependencies with known
4747
security vulnerabilities. (Default: False).
48-
tolerate_deprecated_model (bool): True if deprecated versions of model
49-
specifications should be tolerated (exception not raised). If False, raises
48+
tolerate_deprecated_model (bool): ``True`` if deprecated versions of model
49+
specifications should be tolerated without raising an exception. If ``False``, raises
5050
an exception if the version of the model is deprecated. (Default: False).
5151
Returns:
52-
str: the model artifact S3 URI for the corresponding model.
52+
str: The model artifact S3 URI for the corresponding model.
5353
5454
Raises:
5555
NotImplementedError: If the scope is not supported.

0 commit comments

Comments
 (0)