sagemaker-train 1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sagemaker_train-1.0/LICENSE +201 -0
- sagemaker_train-1.0/MANIFEST.in +1 -0
- sagemaker_train-1.0/PKG-INFO +193 -0
- sagemaker_train-1.0/README.rst +157 -0
- sagemaker_train-1.0/VERSION +1 -0
- sagemaker_train-1.0/pyproject.toml +76 -0
- sagemaker_train-1.0/setup.cfg +4 -0
- sagemaker_train-1.0/src/sagemaker/train/__init__.py +34 -0
- sagemaker_train-1.0/src/sagemaker/train/configs.py +31 -0
- sagemaker_train-1.0/src/sagemaker/train/constants.py +41 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/__init__.py +14 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/common/__init__.py +14 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/common/utils.py +205 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/distributed_drivers/__init__.py +14 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/distributed_drivers/basic_script_driver.py +81 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/distributed_drivers/mpi_driver.py +105 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/distributed_drivers/mpi_utils.py +302 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/distributed_drivers/torchrun_driver.py +129 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/scripts/__init__.py +14 -0
- sagemaker_train-1.0/src/sagemaker/train/container_drivers/scripts/environment.py +305 -0
- sagemaker_train-1.0/src/sagemaker/train/defaults.py +630 -0
- sagemaker_train-1.0/src/sagemaker/train/distributed.py +181 -0
- sagemaker_train-1.0/src/sagemaker/train/local/__init__.py +0 -0
- sagemaker_train-1.0/src/sagemaker/train/local/data.py +405 -0
- sagemaker_train-1.0/src/sagemaker/train/local/entities.py +97 -0
- sagemaker_train-1.0/src/sagemaker/train/local/local_container.py +613 -0
- sagemaker_train-1.0/src/sagemaker/train/model_trainer.py +1471 -0
- sagemaker_train-1.0/src/sagemaker/train/modules/model_trainer.py +1030 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/__init__.py +34 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/checkpoint_location.py +47 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/client.py +30 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/core/__init__.py +27 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/core/_custom_dispatch_table.py +56 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/core/pipeline_variables.py +30 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/core/serialization.py +30 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/core/stored_function.py +30 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/custom_file_filter.py +128 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/errors.py +30 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/invoke_function.py +172 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/job.py +30 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/logging_config.py +38 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/runtime_environment/__init__.py +14 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/runtime_environment/bootstrap_runtime_environment.py +602 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/runtime_environment/mpi_utils_remote.py +252 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/runtime_environment/runtime_environment_manager.py +467 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/runtime_environment/spark_app.py +18 -0
- sagemaker_train-1.0/src/sagemaker/train/remote_function/spark_config.py +30 -0
- sagemaker_train-1.0/src/sagemaker/train/sm_recipes/__init__.py +0 -0
- sagemaker_train-1.0/src/sagemaker/train/sm_recipes/training_recipes.json +17 -0
- sagemaker_train-1.0/src/sagemaker/train/sm_recipes/utils.py +332 -0
- sagemaker_train-1.0/src/sagemaker/train/templates.py +102 -0
- sagemaker_train-1.0/src/sagemaker/train/tuner.py +1418 -0
- sagemaker_train-1.0/src/sagemaker/train/types.py +19 -0
- sagemaker_train-1.0/src/sagemaker/train/utils.py +236 -0
- sagemaker_train-1.0/src/sagemaker_train.egg-info/PKG-INFO +193 -0
- sagemaker_train-1.0/src/sagemaker_train.egg-info/SOURCES.txt +57 -0
- sagemaker_train-1.0/src/sagemaker_train.egg-info/dependency_links.txt +1 -0
- sagemaker_train-1.0/src/sagemaker_train.egg-info/requires.txt +17 -0
- sagemaker_train-1.0/src/sagemaker_train.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include src *.json
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sagemaker-train
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: Open source library for training and deploying models on Amazon SageMaker.
|
|
5
|
+
Author: Amazon Web Services
|
|
6
|
+
Project-URL: Homepage, https://github.com/aws/sagemaker-python-sdk
|
|
7
|
+
Keywords: AI,AWS,Amazon,ML,MXNet,Tensorflow,PyTorch,HuggingFace
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Natural Language :: English
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/x-rst
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: sagemaker-core>=2.0.0
|
|
20
|
+
Requires-Dist: graphene<4,>=3
|
|
21
|
+
Requires-Dist: typing_extensions>=4.9.0
|
|
22
|
+
Requires-Dist: tblib>=1.7.0
|
|
23
|
+
Requires-Dist: PyYAML<7.0,>=6.0
|
|
24
|
+
Requires-Dist: paramiko>=2.11.0
|
|
25
|
+
Provides-Extra: test
|
|
26
|
+
Requires-Dist: pytest; extra == "test"
|
|
27
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
28
|
+
Requires-Dist: pytest-xdist; extra == "test"
|
|
29
|
+
Requires-Dist: mock; extra == "test"
|
|
30
|
+
Requires-Dist: pydantic; extra == "test"
|
|
31
|
+
Requires-Dist: pandas; extra == "test"
|
|
32
|
+
Requires-Dist: scipy; extra == "test"
|
|
33
|
+
Requires-Dist: omegaconf; extra == "test"
|
|
34
|
+
Requires-Dist: graphene; extra == "test"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
.. image:: https://github.com/aws/sagemaker-python-sdk/raw/master/branding/icon/sagemaker-banner.png
|
|
38
|
+
:height: 100px
|
|
39
|
+
:alt: SageMaker
|
|
40
|
+
|
|
41
|
+
====================
|
|
42
|
+
SageMaker Python SDK
|
|
43
|
+
====================
|
|
44
|
+
|
|
45
|
+
.. image:: https://img.shields.io/pypi/v/sagemaker.svg
|
|
46
|
+
:target: https://pypi.python.org/pypi/sagemaker
|
|
47
|
+
:alt: Latest Version
|
|
48
|
+
|
|
49
|
+
.. image:: https://img.shields.io/conda/vn/conda-forge/sagemaker-python-sdk.svg
|
|
50
|
+
:target: https://anaconda.org/conda-forge/sagemaker-python-sdk
|
|
51
|
+
:alt: Conda-Forge Version
|
|
52
|
+
|
|
53
|
+
.. image:: https://img.shields.io/pypi/pyversions/sagemaker.svg
|
|
54
|
+
:target: https://pypi.python.org/pypi/sagemaker
|
|
55
|
+
:alt: Supported Python Versions
|
|
56
|
+
|
|
57
|
+
.. image:: https://img.shields.io/badge/code_style-black-000000.svg
|
|
58
|
+
:target: https://github.com/python/black
|
|
59
|
+
:alt: Code style: black
|
|
60
|
+
|
|
61
|
+
.. image:: https://readthedocs.org/projects/sagemaker/badge/?version=stable
|
|
62
|
+
:target: https://sagemaker.readthedocs.io/en/stable/
|
|
63
|
+
:alt: Documentation Status
|
|
64
|
+
|
|
65
|
+
.. image:: https://github.com/aws/sagemaker-python-sdk/actions/workflows/codebuild-ci-health.yml/badge.svg
|
|
66
|
+
:target: https://github.com/aws/sagemaker-python-sdk/actions/workflows/codebuild-ci-health.yml
|
|
67
|
+
:alt: CI Health
|
|
68
|
+
|
|
69
|
+
SageMaker Python SDK is an open source library for training and deploying machine learning models on Amazon SageMaker.
|
|
70
|
+
|
|
71
|
+
With the SDK, you can train and deploy models using popular deep learning frameworks **Apache MXNet** and **TensorFlow**.
|
|
72
|
+
You can also train and deploy models with **Amazon algorithms**,
|
|
73
|
+
which are scalable implementations of core machine learning algorithms that are optimized for SageMaker and GPU training.
|
|
74
|
+
If you have **your own algorithms** built into SageMaker compatible Docker containers, you can train and host models using these as well.
|
|
75
|
+
|
|
76
|
+
For detailed documentation, including the API reference, see `Read the Docs <https://sagemaker.readthedocs.io>`_.
|
|
77
|
+
|
|
78
|
+
Table of Contents
|
|
79
|
+
-----------------
|
|
80
|
+
|
|
81
|
+
#. `Installing SageMaker Python SDK <#installing-the-sagemaker-python-sdk-train>`__
|
|
82
|
+
#. `Using the SageMaker Python SDK <https://sagemaker.readthedocs.io/en/stable/overview.html>`__
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
Installing the SageMaker Python SDK Train
|
|
86
|
+
------------------------------------------
|
|
87
|
+
|
|
88
|
+
You can install from source by cloning this repository and running a pip install command in the root directory of the repository:
|
|
89
|
+
|
|
90
|
+
::
|
|
91
|
+
|
|
92
|
+
git clone https://github.com/aws/sagemaker-python-sdk-staging.git
|
|
93
|
+
cd sagemaker-python-sdk-staging/sagemaker_train
|
|
94
|
+
pip install .
|
|
95
|
+
|
|
96
|
+
Supported Operating Systems
|
|
97
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
98
|
+
|
|
99
|
+
SageMaker Python SDK supports Unix/Linux and Mac.
|
|
100
|
+
|
|
101
|
+
Supported Python Versions
|
|
102
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
103
|
+
|
|
104
|
+
SageMaker Python SDK is tested on:
|
|
105
|
+
|
|
106
|
+
- Python 3.9
|
|
107
|
+
- Python 3.10
|
|
108
|
+
- Python 3.11
|
|
109
|
+
- Python 3.12
|
|
110
|
+
|
|
111
|
+
Telemetry
|
|
112
|
+
~~~~~~~~~~~~~~~
|
|
113
|
+
|
|
114
|
+
The ``sagemaker`` library has telemetry enabled to help us better understand user needs, diagnose issues, and deliver new features. This telemetry tracks the usage of various SageMaker functions.
|
|
115
|
+
|
|
116
|
+
If you prefer to opt out of telemetry, you can easily do so by setting the ``TelemetryOptOut`` parameter to ``true`` in the SDK defaults configuration. For detailed instructions, please visit `Configuring and using defaults with the SageMaker Python SDK <https://sagemaker.readthedocs.io/en/stable/overview.html#configuring-and-using-defaults-with-the-sagemaker-python-sdk>`__.
|
|
117
|
+
|
|
118
|
+
AWS Permissions
|
|
119
|
+
~~~~~~~~~~~~~~~
|
|
120
|
+
|
|
121
|
+
As a managed service, Amazon SageMaker performs operations on your behalf on the AWS hardware that is managed by Amazon SageMaker.
|
|
122
|
+
Amazon SageMaker can perform only operations that the user permits.
|
|
123
|
+
You can read more about which permissions are necessary in the `AWS Documentation <https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html>`__.
|
|
124
|
+
|
|
125
|
+
The SageMaker Python SDK should not require any additional permissions aside from what is required for using SageMaker.
|
|
126
|
+
However, if you are using an IAM role with a path in it, you should grant permission for ``iam:GetRole``.
|
|
127
|
+
|
|
128
|
+
Licensing
|
|
129
|
+
~~~~~~~~~
|
|
130
|
+
SageMaker Python SDK is licensed under the Apache 2.0 License. It is copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. The license is available at:
|
|
131
|
+
http://aws.amazon.com/apache2.0/
|
|
132
|
+
|
|
133
|
+
Running tests
|
|
134
|
+
~~~~~~~~~~~~~
|
|
135
|
+
|
|
136
|
+
SageMaker Python SDK has unit tests and integration tests.
|
|
137
|
+
|
|
138
|
+
You can install the libraries needed to run the tests by running :code:`pip install --upgrade .[test]` or, for Zsh users: :code:`pip install --upgrade .\[test\]`
|
|
139
|
+
|
|
140
|
+
**Unit tests**
|
|
141
|
+
|
|
142
|
+
We run unit tests with tox, which is a program that lets you run unit tests for multiple Python versions, and also make sure the
|
|
143
|
+
code fits our style guidelines. We run tox with `all of our supported Python versions <#supported-python-versions>`_, so to run unit tests
|
|
144
|
+
with the same configuration we do, you need to have interpreters for those Python versions installed.
|
|
145
|
+
|
|
146
|
+
To run the unit tests with tox, run:
|
|
147
|
+
|
|
148
|
+
::
|
|
149
|
+
|
|
150
|
+
tox tests/unit
|
|
151
|
+
|
|
152
|
+
**Integration tests**
|
|
153
|
+
|
|
154
|
+
To run the integration tests, the following prerequisites must be met
|
|
155
|
+
|
|
156
|
+
1. AWS account credentials are available in the environment for the boto3 client to use.
|
|
157
|
+
2. The AWS account has an IAM role named :code:`SageMakerRole`.
|
|
158
|
+
It should have the AmazonSageMakerFullAccess policy attached as well as a policy with `the necessary permissions to use Elastic Inference <https://docs.aws.amazon.com/sagemaker/latest/dg/ei-setup.html>`__.
|
|
159
|
+
3. To run remote_function tests, dummy ecr repo should be created. It can be created by running -
|
|
160
|
+
:code:`aws ecr create-repository --repository-name remote-function-dummy-container`
|
|
161
|
+
|
|
162
|
+
We recommend selectively running just those integration tests you'd like to run. You can filter by individual test function names with:
|
|
163
|
+
|
|
164
|
+
::
|
|
165
|
+
|
|
166
|
+
tox -- -k 'test_i_care_about'
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
You can also run all of the integration tests by running the following command, which runs them in sequence, which may take a while:
|
|
170
|
+
|
|
171
|
+
::
|
|
172
|
+
|
|
173
|
+
tox -- tests/integ
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
You can also run them in parallel:
|
|
177
|
+
|
|
178
|
+
::
|
|
179
|
+
|
|
180
|
+
tox -- -n auto tests/integ
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
Git Hooks
|
|
184
|
+
~~~~~~~~~
|
|
185
|
+
|
|
186
|
+
to enable all git hooks in the .githooks directory, run these commands in the repository directory:
|
|
187
|
+
|
|
188
|
+
::
|
|
189
|
+
|
|
190
|
+
find .git/hooks -type l -exec rm {} \;
|
|
191
|
+
find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
|
|
192
|
+
|
|
193
|
+
To enable an individual git hook, simply move it from the .githooks/ directory to the .git/hooks/ directory.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
.. image:: https://github.com/aws/sagemaker-python-sdk/raw/master/branding/icon/sagemaker-banner.png
|
|
2
|
+
:height: 100px
|
|
3
|
+
:alt: SageMaker
|
|
4
|
+
|
|
5
|
+
====================
|
|
6
|
+
SageMaker Python SDK
|
|
7
|
+
====================
|
|
8
|
+
|
|
9
|
+
.. image:: https://img.shields.io/pypi/v/sagemaker.svg
|
|
10
|
+
:target: https://pypi.python.org/pypi/sagemaker
|
|
11
|
+
:alt: Latest Version
|
|
12
|
+
|
|
13
|
+
.. image:: https://img.shields.io/conda/vn/conda-forge/sagemaker-python-sdk.svg
|
|
14
|
+
:target: https://anaconda.org/conda-forge/sagemaker-python-sdk
|
|
15
|
+
:alt: Conda-Forge Version
|
|
16
|
+
|
|
17
|
+
.. image:: https://img.shields.io/pypi/pyversions/sagemaker.svg
|
|
18
|
+
:target: https://pypi.python.org/pypi/sagemaker
|
|
19
|
+
:alt: Supported Python Versions
|
|
20
|
+
|
|
21
|
+
.. image:: https://img.shields.io/badge/code_style-black-000000.svg
|
|
22
|
+
:target: https://github.com/python/black
|
|
23
|
+
:alt: Code style: black
|
|
24
|
+
|
|
25
|
+
.. image:: https://readthedocs.org/projects/sagemaker/badge/?version=stable
|
|
26
|
+
:target: https://sagemaker.readthedocs.io/en/stable/
|
|
27
|
+
:alt: Documentation Status
|
|
28
|
+
|
|
29
|
+
.. image:: https://github.com/aws/sagemaker-python-sdk/actions/workflows/codebuild-ci-health.yml/badge.svg
|
|
30
|
+
:target: https://github.com/aws/sagemaker-python-sdk/actions/workflows/codebuild-ci-health.yml
|
|
31
|
+
:alt: CI Health
|
|
32
|
+
|
|
33
|
+
SageMaker Python SDK is an open source library for training and deploying machine learning models on Amazon SageMaker.
|
|
34
|
+
|
|
35
|
+
With the SDK, you can train and deploy models using popular deep learning frameworks **Apache MXNet** and **TensorFlow**.
|
|
36
|
+
You can also train and deploy models with **Amazon algorithms**,
|
|
37
|
+
which are scalable implementations of core machine learning algorithms that are optimized for SageMaker and GPU training.
|
|
38
|
+
If you have **your own algorithms** built into SageMaker compatible Docker containers, you can train and host models using these as well.
|
|
39
|
+
|
|
40
|
+
For detailed documentation, including the API reference, see `Read the Docs <https://sagemaker.readthedocs.io>`_.
|
|
41
|
+
|
|
42
|
+
Table of Contents
|
|
43
|
+
-----------------
|
|
44
|
+
|
|
45
|
+
#. `Installing SageMaker Python SDK <#installing-the-sagemaker-python-sdk-train>`__
|
|
46
|
+
#. `Using the SageMaker Python SDK <https://sagemaker.readthedocs.io/en/stable/overview.html>`__
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Installing the SageMaker Python SDK Train
|
|
50
|
+
------------------------------------------
|
|
51
|
+
|
|
52
|
+
You can install from source by cloning this repository and running a pip install command in the root directory of the repository:
|
|
53
|
+
|
|
54
|
+
::
|
|
55
|
+
|
|
56
|
+
git clone https://github.com/aws/sagemaker-python-sdk-staging.git
|
|
57
|
+
cd sagemaker-python-sdk-staging/sagemaker_train
|
|
58
|
+
pip install .
|
|
59
|
+
|
|
60
|
+
Supported Operating Systems
|
|
61
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
62
|
+
|
|
63
|
+
SageMaker Python SDK supports Unix/Linux and Mac.
|
|
64
|
+
|
|
65
|
+
Supported Python Versions
|
|
66
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
67
|
+
|
|
68
|
+
SageMaker Python SDK is tested on:
|
|
69
|
+
|
|
70
|
+
- Python 3.9
|
|
71
|
+
- Python 3.10
|
|
72
|
+
- Python 3.11
|
|
73
|
+
- Python 3.12
|
|
74
|
+
|
|
75
|
+
Telemetry
|
|
76
|
+
~~~~~~~~~~~~~~~
|
|
77
|
+
|
|
78
|
+
The ``sagemaker`` library has telemetry enabled to help us better understand user needs, diagnose issues, and deliver new features. This telemetry tracks the usage of various SageMaker functions.
|
|
79
|
+
|
|
80
|
+
If you prefer to opt out of telemetry, you can easily do so by setting the ``TelemetryOptOut`` parameter to ``true`` in the SDK defaults configuration. For detailed instructions, please visit `Configuring and using defaults with the SageMaker Python SDK <https://sagemaker.readthedocs.io/en/stable/overview.html#configuring-and-using-defaults-with-the-sagemaker-python-sdk>`__.
|
|
81
|
+
|
|
82
|
+
AWS Permissions
|
|
83
|
+
~~~~~~~~~~~~~~~
|
|
84
|
+
|
|
85
|
+
As a managed service, Amazon SageMaker performs operations on your behalf on the AWS hardware that is managed by Amazon SageMaker.
|
|
86
|
+
Amazon SageMaker can perform only operations that the user permits.
|
|
87
|
+
You can read more about which permissions are necessary in the `AWS Documentation <https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html>`__.
|
|
88
|
+
|
|
89
|
+
The SageMaker Python SDK should not require any additional permissions aside from what is required for using SageMaker.
|
|
90
|
+
However, if you are using an IAM role with a path in it, you should grant permission for ``iam:GetRole``.
|
|
91
|
+
|
|
92
|
+
Licensing
|
|
93
|
+
~~~~~~~~~
|
|
94
|
+
SageMaker Python SDK is licensed under the Apache 2.0 License. It is copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. The license is available at:
|
|
95
|
+
http://aws.amazon.com/apache2.0/
|
|
96
|
+
|
|
97
|
+
Running tests
|
|
98
|
+
~~~~~~~~~~~~~
|
|
99
|
+
|
|
100
|
+
SageMaker Python SDK has unit tests and integration tests.
|
|
101
|
+
|
|
102
|
+
You can install the libraries needed to run the tests by running :code:`pip install --upgrade .[test]` or, for Zsh users: :code:`pip install --upgrade .\[test\]`
|
|
103
|
+
|
|
104
|
+
**Unit tests**
|
|
105
|
+
|
|
106
|
+
We run unit tests with tox, which is a program that lets you run unit tests for multiple Python versions, and also make sure the
|
|
107
|
+
code fits our style guidelines. We run tox with `all of our supported Python versions <#supported-python-versions>`_, so to run unit tests
|
|
108
|
+
with the same configuration we do, you need to have interpreters for those Python versions installed.
|
|
109
|
+
|
|
110
|
+
To run the unit tests with tox, run:
|
|
111
|
+
|
|
112
|
+
::
|
|
113
|
+
|
|
114
|
+
tox tests/unit
|
|
115
|
+
|
|
116
|
+
**Integration tests**
|
|
117
|
+
|
|
118
|
+
To run the integration tests, the following prerequisites must be met
|
|
119
|
+
|
|
120
|
+
1. AWS account credentials are available in the environment for the boto3 client to use.
|
|
121
|
+
2. The AWS account has an IAM role named :code:`SageMakerRole`.
|
|
122
|
+
It should have the AmazonSageMakerFullAccess policy attached as well as a policy with `the necessary permissions to use Elastic Inference <https://docs.aws.amazon.com/sagemaker/latest/dg/ei-setup.html>`__.
|
|
123
|
+
3. To run remote_function tests, dummy ecr repo should be created. It can be created by running -
|
|
124
|
+
:code:`aws ecr create-repository --repository-name remote-function-dummy-container`
|
|
125
|
+
|
|
126
|
+
We recommend selectively running just those integration tests you'd like to run. You can filter by individual test function names with:
|
|
127
|
+
|
|
128
|
+
::
|
|
129
|
+
|
|
130
|
+
tox -- -k 'test_i_care_about'
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
You can also run all of the integration tests by running the following command, which runs them in sequence, which may take a while:
|
|
134
|
+
|
|
135
|
+
::
|
|
136
|
+
|
|
137
|
+
tox -- tests/integ
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
You can also run them in parallel:
|
|
141
|
+
|
|
142
|
+
::
|
|
143
|
+
|
|
144
|
+
tox -- -n auto tests/integ
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
Git Hooks
|
|
148
|
+
~~~~~~~~~
|
|
149
|
+
|
|
150
|
+
to enable all git hooks in the .githooks directory, run these commands in the repository directory:
|
|
151
|
+
|
|
152
|
+
::
|
|
153
|
+
|
|
154
|
+
find .git/hooks -type l -exec rm {} \;
|
|
155
|
+
find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
|
|
156
|
+
|
|
157
|
+
To enable an individual git hook, simply move it from the .githooks/ directory to the .git/hooks/ directory.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sagemaker-train"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Open source library for training and deploying models on Amazon SageMaker."
|
|
9
|
+
readme = "README.rst"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Amazon Web Services" },
|
|
13
|
+
]
|
|
14
|
+
keywords = [
|
|
15
|
+
"AI",
|
|
16
|
+
"AWS",
|
|
17
|
+
"Amazon",
|
|
18
|
+
"ML",
|
|
19
|
+
"MXNet",
|
|
20
|
+
"Tensorflow",
|
|
21
|
+
"PyTorch",
|
|
22
|
+
"HuggingFace"
|
|
23
|
+
]
|
|
24
|
+
classifiers = [
|
|
25
|
+
"Development Status :: 3 - Alpha",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
#"License :: OSI Approved :: Apache Software License",
|
|
28
|
+
"Natural Language :: English",
|
|
29
|
+
"Programming Language :: Python",
|
|
30
|
+
"Programming Language :: Python :: 3.9",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
]
|
|
35
|
+
dependencies = [
|
|
36
|
+
"sagemaker-core>=2.0.0",
|
|
37
|
+
"graphene>=3,<4",
|
|
38
|
+
"typing_extensions>=4.9.0",
|
|
39
|
+
"tblib>=1.7.0",
|
|
40
|
+
"PyYAML>=6.0,<7.0",
|
|
41
|
+
"paramiko>=2.11.0"
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://github.com/aws/sagemaker-python-sdk"
|
|
46
|
+
|
|
47
|
+
[project.optional-dependencies]
|
|
48
|
+
test = [
|
|
49
|
+
"pytest",
|
|
50
|
+
"pytest-cov",
|
|
51
|
+
"pytest-xdist",
|
|
52
|
+
"mock",
|
|
53
|
+
"pydantic",
|
|
54
|
+
"pandas",
|
|
55
|
+
"scipy",
|
|
56
|
+
"omegaconf",
|
|
57
|
+
"graphene"
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[tool.setuptools.packages.find]
|
|
61
|
+
where = ["src/"]
|
|
62
|
+
include = ["sagemaker*"]
|
|
63
|
+
namespaces = true
|
|
64
|
+
|
|
65
|
+
[tool.setuptools.dynamic]
|
|
66
|
+
version = { file = "VERSION"}
|
|
67
|
+
|
|
68
|
+
[tool.pytest.ini_options]
|
|
69
|
+
addopts = ["-vv"]
|
|
70
|
+
testpaths = ["tests"]
|
|
71
|
+
|
|
72
|
+
[tool.black]
|
|
73
|
+
line-length = 100
|
|
74
|
+
|
|
75
|
+
[tool.setuptools]
|
|
76
|
+
include-package-data = true
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
|
5
|
+
# the License is located at
|
|
6
|
+
#
|
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
|
8
|
+
#
|
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
|
12
|
+
# language governing permissions and limitations under the License.
|
|
13
|
+
"""SageMaker Python SDK Train Module."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
# Lazy imports to avoid circular dependencies
|
|
17
|
+
# Session and get_execution_role are available from sagemaker.core.helper.session_helper
|
|
18
|
+
# Import them directly from there if needed, or use lazy import pattern
|
|
19
|
+
|
|
20
|
+
def __getattr__(name):
|
|
21
|
+
"""Lazy import to avoid circular dependencies."""
|
|
22
|
+
if name == "Session":
|
|
23
|
+
from sagemaker.core.helper.session_helper import Session
|
|
24
|
+
return Session
|
|
25
|
+
elif name == "get_execution_role":
|
|
26
|
+
from sagemaker.core.helper.session_helper import get_execution_role
|
|
27
|
+
return get_execution_role
|
|
28
|
+
elif name == "ModelTrainer":
|
|
29
|
+
from sagemaker.train.model_trainer import ModelTrainer
|
|
30
|
+
return ModelTrainer
|
|
31
|
+
elif name == "logger":
|
|
32
|
+
from sagemaker.core.utils.utils import logger
|
|
33
|
+
return logger
|
|
34
|
+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|