Skip to content

doc: change "v2" to "version 2.0 or later" #1557

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 2 commits into from
Jun 9, 2020
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
22 changes: 11 additions & 11 deletions doc/frameworks/tensorflow/upgrade_from_legacy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Upgrade from Legacy TensorFlow Support
######################################

With v2 of the SageMaker Python SDK, support for legacy SageMaker TensorFlow images has been deprecated.
With version 2.0 and later of the SageMaker Python SDK, support for legacy SageMaker TensorFlow images has been deprecated.
This guide explains how to upgrade your SageMaker Python SDK usage.

For more information about using TensorFlow with the SageMaker Python SDK, see `Use TensorFlow with the SageMaker Python SDK <using_tf.html>`_.
Expand Down Expand Up @@ -67,13 +67,13 @@ For more information about implementing your own handlers, see `How to implement
Continue with Legacy Versions
*****************************

While not recommended, you can still use a legacy TensorFlow version with v2 of the SageMaker Python SDK.
While not recommended, you can still use a legacy TensorFlow version with version 2.0 and later of the SageMaker Python SDK.
In order to do so, you need to change how a few parameters are defined.

Training
========

When creating an estimator, v2 requires the following changes:
When creating an estimator, the Python SDK version 2.0 and later requires the following changes:

#. Explicitly specify the ECR image URI via ``image_name``.
To determine the URI, you can use :func:`sagemaker.fw_utils.create_image_uri`.
Expand All @@ -87,7 +87,7 @@ the difference in code would be as follows:

from sagemaker.tensorflow import TensorFlow

# v1
# v1.x
estimator = TensorFlow(
...
source_dir="code",
Expand All @@ -99,7 +99,7 @@ the difference in code would be as follows:
requirements_file="requirements.txt",
)

# v2
# v2.0 and later
estimator = TensorFlow(
...
source_dir="code",
Expand All @@ -123,7 +123,7 @@ To provide a requirements file, define a hyperparameter named "sagemaker_require
Inference
=========

Using a legacy TensorFlow version for endpoints and batch transform can be achieved with v2 of the SageMaker Python SDK with some minor changes to your code.
Using a legacy TensorFlow version for endpoints and batch transform can be achieved with version 2.0 and later of the SageMaker Python SDK with some minor changes to your code.

From an Estimator
-----------------
Expand All @@ -134,16 +134,16 @@ To specify the number of model server workers, you need to set it through an env

.. code:: python

# v1
# v1.x
estimator.deploy(..., model_server_workers=4)

# v2
# v2.0 and later
estimator.deploy(..., env={"MODEL_SERVER_WORKERS": 4})

From a Trained Model
--------------------

If you are starting with a trained model, v2 requires the following changes:
If you are starting with a trained model, the Python SDK version 2.0 and later requires the following changes:

#. Use the the :class:`sagemaker.model.FrameworkModel` class.
#. Explicitly specify the ECR image URI via ``image``.
Expand All @@ -155,7 +155,7 @@ the difference in code would be as follows:

.. code:: python

# v1
# v1.x
from sagemaker.tensorflow import TensorFlowModel

model = TensorFlowModel(
Expand All @@ -165,7 +165,7 @@ the difference in code would be as follows:
model_server_workers=4,
)

# v2
# v2.0 and later
from sagemaker.model import FrameworkModel

model = FrameworkModel(
Expand Down
2 changes: 1 addition & 1 deletion src/sagemaker/cli/compatibility/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Tools to assist with upgrading to v2 of the SageMaker Python SDK."""
"""Tools to assist with upgrading to version 2.0 and later of the SageMaker Python SDK."""
from __future__ import absolute_import
21 changes: 11 additions & 10 deletions src/sagemaker/cli/compatibility/v2/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FileUpdater(object):

def __init__(self, input_path, output_path):
"""Creates a ``FileUpdater`` for updating a file so that
it is compatible with v2 of the SageMaker Python SDK.
it is compatible with version 2.0 and later of the SageMaker Python SDK.

Args:
input_path (str): Location of the input file.
Expand All @@ -44,8 +44,8 @@ def __init__(self, input_path, output_path):
@abstractmethod
def update(self):
"""Reads the input file, updates the code so that it is
compatible with v2 of the SageMaker Python SDK, and writes the
updated code to an output file.
compatible with version 2.0 and later of the SageMaker Python SDK,
and writes the updated code to an output file.
"""

def _make_output_dirs_if_needed(self):
Expand All @@ -66,21 +66,22 @@ class PyFileUpdater(FileUpdater):

def update(self):
"""Reads the input Python file, updates the code so that it is
compatible with v2 of the SageMaker Python SDK, and writes the
updated code to an output file.
compatible with version 2.0 and later of the SageMaker Python SDK,
and writes the updated code to an output file.
"""
output = self._update_ast(self._read_input_file())
self._write_output_file(output)

def _update_ast(self, input_ast):
"""Updates an abstract syntax tree (AST) so that it is compatible
with v2 of the SageMaker Python SDK.
with version 2.0 and later of the SageMaker Python SDK.

Args:
input_ast (ast.Module): AST to be updated for use with Python SDK v2.
input_ast (ast.Module): AST to be updated for use with
the Python SDK version 2.0 and later.

Returns:
ast.Module: Updated AST that is compatible with Python SDK v2.
ast.Module: Updated AST that is compatible with the Python SDK version 2.0 and later.
"""
return ASTTransformer().visit(input_ast)

Expand Down Expand Up @@ -115,7 +116,7 @@ class JupyterNotebookFileUpdater(FileUpdater):

def update(self):
"""Reads the input Jupyter notebook file, updates the code so that it is
compatible with v2 of the SageMaker Python SDK, and writes the
compatible with version 2.0 and later of the SageMaker Python SDK, and writes the
updated code to an output file.
"""
nb_json = self._read_input_file()
Expand All @@ -128,7 +129,7 @@ def update(self):

def _update_code_from_cell(self, cell):
"""Updates the code from a code cell so that it is
compatible with v2 of the SageMaker Python SDK.
compatible with version 2.0 and later of the SageMaker Python SDK.

Args:
cell (dict): A dictionary representation of a code cell from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Classes to modify TensorFlow legacy mode code to be compatible with SageMaker Python SDK v2."""
"""Classes to modify TensorFlow legacy mode code to be compatible
with version 2.0 and later of the SageMaker Python SDK.
"""
from __future__ import absolute_import

import ast
Expand Down
9 changes: 6 additions & 3 deletions src/sagemaker/cli/compatibility/v2/modifiers/tfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Classes to modify TensorFlow Serving code to be compatible with SageMaker Python SDK v2."""
"""Classes to modify TensorFlow Serving code to be compatible
with version 2.0 and later of the SageMaker Python SDK.
"""
from __future__ import absolute_import

import ast
Expand Down Expand Up @@ -57,7 +59,8 @@ def node_should_be_modified(self, node):
)

def modify_node(self, node):
"""Modifies the ``ast.Call`` node to use the v2 classes for TensorFlow Serving:
"""Modifies the ``ast.Call`` node to use the classes for TensorFlow Serving available in
version 2.0 and later of the Python SDK:

- ``sagemaker.tensorflow.TensorFlowModel``
- ``sagemaker.tensorflow.TensorFlowPredictor``
Expand All @@ -72,7 +75,7 @@ def modify_node(self, node):
node.func.value = node.func.value.value

def _new_cls_name(self, cls_name):
"""Returns the v2 class name."""
"""Returns the updated class name."""
return "TensorFlow{}".format(cls_name)


Expand Down
7 changes: 4 additions & 3 deletions src/sagemaker/cli/compatibility/v2/sagemaker_upgrade_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""A tool to upgrade SageMaker Python SDK code to be compatible with v2."""
"""A tool to upgrade SageMaker Python SDK code to be compatible with version 2.0 and later."""
from __future__ import absolute_import

import argparse
Expand All @@ -22,7 +22,7 @@


def _update_file(input_file, output_file):
"""Updates a file to be compatible with v2 of the SageMaker Python SDK,
"""Updates a file to be compatible with version 2.0 and later of the SageMaker Python SDK,
and write the updated source to the output file.

Args:
Expand Down Expand Up @@ -53,7 +53,8 @@ def _update_file(input_file, output_file):
def _parse_args():
"""Parses CLI arguments."""
parser = argparse.ArgumentParser(
description="A tool to convert files to be compatible with v2 of the SageMaker Python SDK. "
description="A tool to convert files to be compatible with "
"version 2.0 and later of the SageMaker Python SDK. "
"Simple usage: sagemaker-upgrade-v2 --in-file foo.py --out-file bar.py"
)
parser.add_argument(
Expand Down