Skip to content

Commit 5182be3

Browse files
laurenyunadiaya
authored andcommitted
doc: add link to parent classes to clarify **kwargs (#1171)
* doc: add link to parent classes to clarify **kwargs This commit also fixes some minor Sphinx syntax issues in the docstrings. * remove files covered by other PRs
1 parent 2922621 commit 5182be3

File tree

6 files changed

+99
-110
lines changed

6 files changed

+99
-110
lines changed

src/sagemaker/algorithm.py

Lines changed: 65 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"). You
44
# may not use this file except in compliance with the License. A copy of
@@ -59,110 +59,72 @@ def __init__(
5959
6060
Args:
6161
algorithm_arn (str): algorithm arn used for training. Can be just the name if your
62-
account owns the algorithm.
63-
64-
role (str): An AWS IAM role (either name or full ARN). The Amazon SageMaker
65-
training jobs and APIsthat create Amazon SageMaker endpoints use this role to
66-
access training data and model artifacts. After the endpoint
67-
is created, the inference code might use the IAM role, if it
68-
needs to access an AWS resource.
69-
70-
train_instance_count (int): Number of Amazon EC2 instances to
62+
account owns the algorithm.
63+
role (str): An AWS IAM role (either name or full ARN). The Amazon SageMaker
64+
training jobs and APIsthat create Amazon SageMaker endpoints use this role to
65+
access training data and model artifacts. After the endpoint
66+
is created, the inference code might use the IAM role, if it
67+
needs to access an AWS resource.
68+
train_instance_count (int): Number of Amazon EC2 instances to
7169
use for training. train_instance_type (str): Type of EC2
7270
instance to use for training, for example, 'ml.c4.xlarge'.
73-
train_volume_size (int): Size in GB of the EBS volume to use for
74-
storing input data
75-
76-
during training (default: 30). Must be large enough to store
77-
training data if File Mode is used (which is the default).
78-
79-
train_volume_kms_key (str): Optional. KMS key ID for encrypting EBS volume attached
80-
to the training instance (default: None).
81-
82-
train_max_run (int): Timeout in seconds for training (default: 24 * 60 * 60).
83-
After this amount of time Amazon SageMaker terminates the
84-
job regardless of its current status.
85-
86-
input_mode (str): The input mode that the algorithm supports
87-
(default: 'File'). Valid modes:
88-
89-
* 'File' - Amazon SageMaker copies the training dataset from
90-
the S3 location to a local directory.
91-
* 'Pipe' - Amazon SageMaker streams data directly from S3 to
92-
the container via a Unix-named pipe.
93-
94-
This argument can be overriden on a per-channel basis using
95-
``sagemaker.session.s3_input.input_mode``.
96-
97-
output_path (str): S3 location for saving the training result (model artifacts and
98-
output files). If not specified, results are stored to a default bucket. If
99-
the bucket with the specific name does not exist, the
100-
estimator creates the bucket during the
101-
:meth:`~sagemaker.estimator.EstimatorBase.fit` method
102-
execution.
103-
104-
output_kms_key (str): Optional. KMS key ID for encrypting the
71+
train_volume_size (int): Size in GB of the EBS volume to use for
72+
storing input data during training (default: 30). Must be large enough to store
73+
training data if File Mode is used (which is the default).
74+
train_volume_kms_key (str): Optional. KMS key ID for encrypting EBS volume attached
75+
to the training instance (default: None).
76+
train_max_run (int): Timeout in seconds for training (default: 24 * 60 * 60).
77+
After this amount of time Amazon SageMaker terminates the
78+
job regardless of its current status.
79+
input_mode (str): The input mode that the algorithm supports
80+
(default: 'File'). Valid modes:
81+
82+
* 'File' - Amazon SageMaker copies the training dataset from
83+
the S3 location to a local directory.
84+
* 'Pipe' - Amazon SageMaker streams data directly from S3 to
85+
the container via a Unix-named pipe.
86+
87+
This argument can be overriden on a per-channel basis using
88+
``sagemaker.session.s3_input.input_mode``.
89+
90+
output_path (str): S3 location for saving the training result (model artifacts and
91+
output files). If not specified, results are stored to a default bucket. If
92+
the bucket with the specific name does not exist, the
93+
estimator creates the bucket during the
94+
:meth:`~sagemaker.estimator.EstimatorBase.fit` method
95+
execution.
96+
output_kms_key (str): Optional. KMS key ID for encrypting the
10597
training output (default: None). base_job_name (str): Prefix for
10698
training job name when the
10799
:meth:`~sagemaker.estimator.EstimatorBase.fit`
108-
109-
method launches. If not specified, the estimator generates a
110-
default job name, based on the training image name and
111-
current timestamp.
112-
113-
sagemaker_session (sagemaker.session.Session): Session object which manages
114-
interactions with Amazon SageMaker APIs and any other AWS services needed. If
115-
not specified, the estimator creates one using the default
116-
AWS configuration chain.
117-
118-
tags (list[dict]): List of tags for labeling a training job. For more, see
119-
https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
120-
121-
subnets (list[str]): List of subnet ids. If not specified
100+
method launches. If not specified, the estimator generates a
101+
default job name, based on the training image name and
102+
current timestamp.
103+
sagemaker_session (sagemaker.session.Session): Session object which manages
104+
interactions with Amazon SageMaker APIs and any other AWS services needed. If
105+
not specified, the estimator creates one using the default
106+
AWS configuration chain.
107+
tags (list[dict]): List of tags for labeling a training job. For more, see
108+
https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
109+
subnets (list[str]): List of subnet ids. If not specified
122110
training job will be created without VPC config.
123111
security_group_ids (list[str]): List of security group ids. If
124-
not specified training job will be created
125-
126-
without VPC config.
127-
128-
model_uri (str): URI where a pre-trained model is stored, either locally or in S3
129-
(default: None). If specified, the estimator will create a channel pointing to
130-
the model so the training job can download it. This model
131-
can be a 'model.tar.gz' from a previous training job, or
132-
other artifacts coming from a different source.
133-
More information:
134-
https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html#td-deserialization
135-
136-
model_channel_name (str): Name of the channel where 'model_uri'
112+
not specified training job will be created without VPC config.
113+
model_uri (str): URI where a pre-trained model is stored, either locally or in S3
114+
(default: None). If specified, the estimator will create a channel pointing to
115+
the model so the training job can download it. This model
116+
can be a 'model.tar.gz' from a previous training job, or
117+
other artifacts coming from a different source.
118+
More information:
119+
https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html#td-deserialization
120+
model_channel_name (str): Name of the channel where 'model_uri'
137121
will be downloaded (default: 'model'). metric_definitions
138122
(list[dict]): A list of dictionaries that defines the metric(s)
139-
used to evaluate the
140-
141-
training jobs. Each dictionary contains two keys: 'Name' for
142-
the name of the metric, and 'Regex' for the regular
143-
expression used to extract the metric from the logs.
144-
145-
encrypt_inter_container_traffic (bool): Specifies whether traffic between training
146-
containers is encrypted for the training job (default: ``False``).
147-
role:
148-
train_instance_count:
149-
train_instance_type:
150-
train_volume_size:
151-
train_volume_kms_key:
152-
train_max_run:
153-
input_mode:
154-
output_path:
155-
output_kms_key:
156-
base_job_name:
157-
sagemaker_session:
158-
hyperparameters:
159-
tags:
160-
subnets:
161-
security_group_ids:
162-
model_uri:
163-
model_channel_name:
164-
metric_definitions:
165-
encrypt_inter_container_traffic:
123+
used to evaluate the training jobs. Each dictionary contains two keys: 'Name' for
124+
the name of the metric, and 'Regex' for the regular
125+
expression used to extract the metric from the logs.
126+
encrypt_inter_container_traffic (bool): Specifies whether traffic between training
127+
containers is encrypted for the training job (default: ``False``).
166128
**kwargs: Additional kwargs. This is unused. It's only added for AlgorithmEstimator
167129
to ignore the irrelevant arguments.
168130
"""
@@ -309,7 +271,13 @@ def create_model(
309271
the model. Default: use subnets and security groups from this Estimator.
310272
* 'Subnets' (list[str]): List of subnet ids.
311273
* 'SecurityGroupIds' (list[str]): List of security group ids.
312-
**kwargs:
274+
**kwargs: Additional arguments for creating a :class:`~sagemaker.model.ModelPackage`.
275+
276+
.. tip::
277+
278+
You can find additional parameters for using this method at
279+
:class:`~sagemaker.model.ModelPackage` and
280+
:class:`~sagemaker.model.Model`.
313281
314282
Returns:
315283
a Model ready for deployment.

src/sagemaker/estimator.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,9 +1336,15 @@ def create_model(
13361336
Default: use subnets and security groups from this Estimator.
13371337
* 'Subnets' (list[str]): List of subnet ids.
13381338
* 'SecurityGroupIds' (list[str]): List of security group ids.
1339-
**kwargs:
1339+
**kwargs: Additional parameters passed to :class:`~sagemaker.model.Model`
1340+
1341+
.. tip::
1342+
1343+
You can find additional parameters for using this method at
1344+
:class:`~sagemaker.model.Model`.
13401345
1341-
Returns: a Model ready for deployment.
1346+
Returns:
1347+
(sagemaker.model.Model) a Model ready for deployment.
13421348
"""
13431349
if predictor_cls is None:
13441350

@@ -1566,6 +1572,11 @@ def __init__(
15661572
(default: ``None``).
15671573
**kwargs: Additional kwargs passed to the ``EstimatorBase``
15681574
constructor.
1575+
1576+
.. tip::
1577+
1578+
You can find additional parameters for initializing this class at
1579+
:class:`~sagemaker.estimator.EstimatorBase`.
15691580
"""
15701581
super(Framework, self).__init__(**kwargs)
15711582
if entry_point.startswith("s3://"):

src/sagemaker/model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,11 @@ def __init__(
734734
try to use either CodeCommit credential helper or local
735735
credential storage for authentication.
736736
**kwargs: Keyword arguments passed to the ``Model`` initializer.
737+
738+
.. tip::
739+
740+
You can find additional parameters for initializing this class at
741+
:class:`~sagemaker.model.Model`.
737742
"""
738743
super(FrameworkModel, self).__init__(
739744
model_data,

src/sagemaker/multidatamodel.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ def __init__(
6666
object, used for SageMaker interactions (default: None). If not
6767
specified, one is created using the default AWS configuration
6868
chain.
69-
**kwargs: Keyword arguments passed to the ``Model`` initializer.
69+
**kwargs: Keyword arguments passed to the
70+
:class:`~sagemaker.model.Model` initializer.
71+
72+
.. tip::
73+
74+
You can find additional parameters for initializing this class at
75+
:class:`~sagemaker.model.Model`.
7076
"""
7177
# Validate path
7278
if not model_data_prefix.startswith("s3://"):

src/sagemaker/sparkml/model.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"). You
44
# may not use this file except in compliance with the License. A copy of
@@ -83,7 +83,13 @@ def __init__(self, model_data, role=None, spark_version=2.2, sagemaker_session=N
8383
AWS services needed. If not specified, the estimator creates one
8484
using the default AWS configuration chain. For local mode,
8585
please do not pass this variable.
86-
**kwargs:
86+
**kwargs: Additional parameters passed to the
87+
:class:`~sagemaker.model.Model` constructor.
88+
89+
.. tip::
90+
91+
You can find additional parameters for initializing this class at
92+
:class:`~sagemaker.model.Model`.
8793
"""
8894
# For local mode, sagemaker_session should be passed as None but we need a session to get
8995
# boto_region_name

src/sagemaker/tuner.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,6 @@ def fit(
401401
* (list[sagemaker.amazon.amazon_estimator.FileSystemRecordSet]) - A list of
402402
:class:~`sagemaker.amazon.amazon_estimator.FileSystemRecordSet` objects,
403403
where each instance is a different channel of training data.
404-
include_cls_metadata (bool): Whether or not the hyperparameter tuning job should include
405-
information about the estimator class (default: False). This information is passed
406-
as a hyperparameter, so if the algorithm you are using cannot handle
407-
unknown hyperparameters (e.g. an Amazon SageMaker built-in algorithm that
408-
does not have a custom estimator in the Python SDK), then set
409-
``include_cls_metadata`` to ``False``.
410-
**kwargs: Other arguments needed for training. Please refer to the ``fit()`` method of
411-
the associated estimator to see what other arguments are needed.
412404
413405
job_name (str): Tuning job name. If not specified, the tuner
414406
generates a default job name, based on the training image name
@@ -426,6 +418,7 @@ def fit(
426418
the estimator_dict argument of the method. The keys would be the same
427419
estimator names as in estimator_dict. If one estimator doesn't need the flag
428420
set, then no need to include it in the dictionary.
421+
429422
estimator_kwargs (dict[str, dict]): Dictionary for other arguments needed for
430423
training. Should be used only for tuners created via the factory method create().
431424
The keys are the estimator names for the estimator_dict argument of create()

0 commit comments

Comments
 (0)