From ecd73497a1fa647805a514c93eb4c96a9ad2f5b0 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 24 Nov 2022 23:25:02 -0500 Subject: [PATCH 01/11] change: Update package metadata --- MANIFEST.in | 15 -- hatch_build.py | 25 ++++ pyproject.toml | 96 ++++++++++++ requirements/tox/twine_requirements.txt | 1 + setup.cfg | 12 -- setup.py | 141 ------------------ tests/integ/sagemaker/experiments/conftest.py | 2 +- tox.ini | 9 +- 8 files changed, 128 insertions(+), 173 deletions(-) delete mode 100644 MANIFEST.in create mode 100644 hatch_build.py delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index c5eeeed043..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,15 +0,0 @@ -recursive-include src/sagemaker *.py - -include src/sagemaker/image_uri_config/*.json -include src/sagemaker/serve/schema/*.json -include src/sagemaker/serve/requirements.txt -recursive-include requirements * - -include VERSION -include LICENSE.txt -include README.rst - -prune tests - -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 0000000000..780b6820da --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,25 @@ +import sys + +from hatchling.metadata.plugin.interface import MetadataHookInterface + + +class CustomMetadataHook(MetadataHookInterface): + def update(self, metadata): + optional_dependencies = metadata["optional-dependencies"] + optional_dependencies["all"] = [ + dependency + for optional_dependencies in optional_dependencies.values() + for dependency in optional_dependencies + ] + optional_dependencies["test"].extend(optional_dependencies["all"]) + + # remove torch and torchvision if python version is not 3.10/3.11 + if sys.version_info.minor not in (10, 11): + optional_dependencies["test"] = list( + filter( + lambda d: not d.startswith( + ("sentencepiece", "transformers", "torch", "torchvision") + ), + optional_dependencies["test"], + ) + ) diff --git a/pyproject.toml b/pyproject.toml index aa4949aa1c..fa287c10e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,98 @@ +[build-system] +requires = ["hatchling", "hatch-requirements-txt>=0.3.0"] +build-backend = "hatchling.build" + +[project] +name = "sagemaker" +dynamic = ["version", "optional-dependencies"] +description = "Open source library for training and deploying models on Amazon SageMaker." +readme = "README.rst" +license = "Apache-2.0" +requires-python = ">=3.8" +authors = [ + { name = "Amazon Web Services" }, +] +keywords = [ + "AI", + "AWS", + "Amazon", + "ML", + "MXNet", + "Tensorflow", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dependencies = [ + "attrs>=23.1.0,<24", + "boto3>=1.33.3,<2.0", + "cloudpickle==2.2.1", + "docker", + "google-pasta", + "importlib-metadata>=1.4.0,<7.0", + "jsonschema", + "numpy>=1.9.0,<2.0", + "packaging>=20.0", + "pandas", + "pathos", + "platformdirs", + "protobuf>=3.12,<5.0", + "psutil", + "PyYAML~=6.0", + "requests", + "schema", + "smdebug_rulesconfig==1.0.1", + "tblib>=1.7.0,<4", + "tqdm", + "urllib3>=1.26.8,<3.0.0", +] + +[project.scripts] +sagemaker-upgrade-v2 = "sagemaker.cli.compatibility.v2.sagemaker_upgrade_v2:main" + +[project.urls] +Homepage = "https://github.com/aws/sagemaker-python-sdk" + +[tool.hatch.version] +path = "VERSION" +pattern = "(?P.+)" + +# Keep format of *_requirements.txt to be tracked by dependabot +[tool.hatch.metadata.hooks.requirements_txt.optional-dependencies] +feature-processor = ["requirements/extras/feature-processor_requirements.txt"] +huggingface = ["requirements/extras/huggingface_requirements.txt"] +local = ["requirements/extras/local_requirements.txt"] +scipy = ["requirements/extras/scipy_requirements.txt"] +test = ["requirements/extras/test_requirements.txt"] + +# Then do some postprocessing of optional dependencies +[tool.hatch.metadata.hooks.custom] + +[tool.hatch.build.targets.wheel] +packages = ["src/sagemaker"] +exclude = ["src/sagemaker/serve/model_server/triton/pack_conda_env.sh"] + +[tool.hatch.build.targets.wheel.shared-scripts] +"src/sagemaker/serve/model_server/triton/pack_conda_env.sh" = "pack_conda_env.sh" + +[tool.hatch.build.targets.sdist] +only-include = [ + "/requirements/extras", + "/src", + "/VERSION", +] + +[tool.pytest.ini_options] +addopts = ["-vv"] +testpaths = ["tests"] + [tool.black] line-length = 100 diff --git a/requirements/tox/twine_requirements.txt b/requirements/tox/twine_requirements.txt index 489eeb83e0..9c0a7cab5e 100644 --- a/requirements/tox/twine_requirements.txt +++ b/requirements/tox/twine_requirements.txt @@ -1 +1,2 @@ +build==1.2.1 twine==5.0.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 80eaced105..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Test args for pytest; disable stdout capturing by default. -[tool:pytest] -addopts = - -vv -testpaths = tests - -[aliases] -test=pytest - -[metadata] -description_file = README.rst -license_files = LICENSE.txt diff --git a/setup.py b/setup.py deleted file mode 100644 index 9242e69cfd..0000000000 --- a/setup.py +++ /dev/null @@ -1,141 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"). You -# may not use this file except in compliance with the License. A copy of -# the License is located at -# -# http://aws.amazon.com/apache2.0/ -# -# or in the "license" file accompanying this file. This file is -# 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. -"""Placeholder docstring""" -from __future__ import absolute_import - -import os -from glob import glob -import sys - -from setuptools import find_packages, setup - - -def read(fname): - """ - Args: - fname: - """ - return open(os.path.join(os.path.dirname(__file__), fname)).read() - - -def read_version(): - return read("VERSION").strip() - - -def read_requirements(filename): - """Reads requirements file which lists package dependencies. - - Args: - filename: type(str) Relative file path of requirements.txt file - - Returns: - list of dependencies extracted from file - """ - with open(os.path.abspath(filename)) as fp: - deps = [line.strip() for line in fp.readlines()] - return deps - - -# Declare minimal set for installation -required_packages = [ - "attrs>=23.1.0,<24", - "boto3>=1.33.3,<2.0", - "cloudpickle==2.2.1", - "google-pasta", - "numpy>=1.9.0,<2.0", - "protobuf>=3.12,<5.0", - "smdebug_rulesconfig==1.0.1", - "importlib-metadata>=1.4.0,<7.0", - "packaging>=20.0", - "pandas", - "pathos", - "schema", - "PyYAML~=6.0", - "jsonschema", - "platformdirs", - "tblib>=1.7.0,<4", - "urllib3>=1.26.8,<3.0.0", - "requests", - "docker", - "tqdm", - "psutil", -] - -# Specific use case dependencies -# Keep format of *_requirements.txt to be tracked by dependabot -extras = { - "local": read_requirements("requirements/extras/local_requirements.txt"), - "scipy": read_requirements("requirements/extras/scipy_requirements.txt"), - "feature-processor": read_requirements( - "requirements/extras/feature-processor_requirements.txt" - ), - "huggingface": read_requirements("requirements/extras/huggingface_requirements.txt"), -} -# Meta dependency groups -extras["all"] = [item for group in extras.values() for item in group] -# Tests specific dependencies (do not need to be included in 'all') -test_dependencies = read_requirements("requirements/extras/test_requirements.txt") -# test dependencies are a superset of testing and extra dependencies -test_dependencies.extend(extras["all"]) -# remove torch and torchvision if python version is not 3.10/3.11 -if sys.version_info.minor != 10 or sys.version_info.minor != 11: - test_dependencies = [ - module - for module in test_dependencies - if not ( - module.startswith("transformers") - or module.startswith("sentencepiece") - or module.startswith("torch") - or module.startswith("torchvision") - ) - ] - -extras["test"] = (test_dependencies,) - -setup( - name="sagemaker", - version=read_version(), - description="Open source library for training and deploying models on Amazon SageMaker.", - packages=find_packages("src"), - package_dir={"": "src"}, - package_data={"": ["*.whl"]}, - py_modules=[os.path.splitext(os.path.basename(path))[0] for path in glob("src/*.py")], - include_package_data=True, - long_description=read("README.rst"), - author="Amazon Web Services", - url="https://github.com/aws/sagemaker-python-sdk/", - license="Apache License 2.0", - keywords="ML Amazon AWS AI Tensorflow MXNet", - python_requires=">= 3.8", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Natural Language :: English", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - ], - install_requires=required_packages, - extras_require=extras, - entry_points={ - "console_scripts": [ - "sagemaker-upgrade-v2=sagemaker.cli.compatibility.v2.sagemaker_upgrade_v2:main", - ] - }, - scripts=[ - "src/sagemaker/serve/model_server/triton/pack_conda_env.sh", - ], -) diff --git a/tests/integ/sagemaker/experiments/conftest.py b/tests/integ/sagemaker/experiments/conftest.py index 693e147392..1f4ae26247 100644 --- a/tests/integ/sagemaker/experiments/conftest.py +++ b/tests/integ/sagemaker/experiments/conftest.py @@ -155,7 +155,7 @@ def tempdir(): @pytest.fixture(scope="module") def dev_sdk_tar(): resource_dir = os.path.join(DATA_DIR, "experiment") - os.system("python setup.py sdist -k") + os.system("python -m build --sdist") sdist_path = max(glob.glob("dist/sagemaker-*"), key=os.path.getctime) sdk_file = os.path.join(resource_dir, _EXP_PLUS_SDK_TAR) shutil.copy(sdist_path, sdk_file) diff --git a/tox.ini b/tox.ini index 718e968013..965f5d739e 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ # and then run "tox" from this directory. [tox] +isolated_build = true envlist = black-format,flake8,pylint,docstyle,sphinx,doc8,twine,py38,py39,py310,py311 skip_missing_interpreters = False @@ -49,7 +50,7 @@ ignore = require-code = True [doc8] -ignore-path=.tox,src/sagemaker.egg-info +ignore-path=.tox # TODO: fix files before enabling max-line-length (D001) ignore=D001 @@ -92,9 +93,9 @@ depends = {py38,py39,py310,p311}: clean [testenv:runcoverage] -description = run unit tests with coverage +description = run unit tests with coverage commands = - pytest --cov=sagemaker --cov-append {posargs} + pytest --cov=sagemaker --cov-append {posargs} {env:IGNORE_COVERAGE:} coverage report -i --fail-under=86 [testenv:flake8] @@ -127,7 +128,7 @@ skip_install = true deps = -r requirements/tox/twine_requirements.txt commands = - python setup.py sdist + python -m build --sdist twine check dist/*.tar.gz [testenv:sphinx] From 9fb6c68015b942386d24aac38f6360685e76bf7f Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 20 Jun 2024 15:23:48 -0400 Subject: [PATCH 02/11] address feedback --- tests/integ/sagemaker/conftest.py | 2 +- .../feature_store/feature_processor/test_feature_processor.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integ/sagemaker/conftest.py b/tests/integ/sagemaker/conftest.py index 46539e6de3..a5ba724339 100644 --- a/tests/integ/sagemaker/conftest.py +++ b/tests/integ/sagemaker/conftest.py @@ -280,7 +280,7 @@ def _generate_sagemaker_sdk_tar(destination_folder): """ Run setup.py sdist to generate the PySDK tar file """ - command = f"python3 setup.py egg_info --egg-base {destination_folder} sdist -d {destination_folder} -k --verbose" + command = f"python -m build --sdist -o {destination_folder}" print(f"Running command: {command}") result = subprocess.run(command, shell=True, check=True, capture_output=True) if result.returncode != 0: diff --git a/tests/integ/sagemaker/feature_store/feature_processor/test_feature_processor.py b/tests/integ/sagemaker/feature_store/feature_processor/test_feature_processor.py index 0d1ada759d..fb69bb1b3f 100644 --- a/tests/integ/sagemaker/feature_store/feature_processor/test_feature_processor.py +++ b/tests/integ/sagemaker/feature_store/feature_processor/test_feature_processor.py @@ -1272,7 +1272,7 @@ def _generate_and_move_sagemaker_sdk_tar(): """ Run setup.py sdist to generate the PySDK whl file """ - subprocess.run("python3 setup.py bdist_wheel", shell=True) + subprocess.run("python -m build --wheel", shell=True) dist_dir = "dist" source_archive = os.listdir(dist_dir)[0] source_path = os.path.join(dist_dir, source_archive) From 8a3ccf404c86a93beecc416a79f40d1efd8f5b03 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 20 Jun 2024 22:07:52 -0400 Subject: [PATCH 03/11] support and deprecate legacy installations --- MANIFEST.in | 15 ++++++++++ hatch_build.py | 50 ++++++++++++++++++++++------------ pyproject.toml | 13 ++------- setup.py | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 27 deletions(-) create mode 100644 MANIFEST.in create mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000..c5eeeed043 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,15 @@ +recursive-include src/sagemaker *.py + +include src/sagemaker/image_uri_config/*.json +include src/sagemaker/serve/schema/*.json +include src/sagemaker/serve/requirements.txt +recursive-include requirements * + +include VERSION +include LICENSE.txt +include README.rst + +prune tests + +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/hatch_build.py b/hatch_build.py index 780b6820da..39ae4e7efb 100644 --- a/hatch_build.py +++ b/hatch_build.py @@ -1,3 +1,4 @@ +import os import sys from hatchling.metadata.plugin.interface import MetadataHookInterface @@ -5,21 +6,36 @@ class CustomMetadataHook(MetadataHookInterface): def update(self, metadata): - optional_dependencies = metadata["optional-dependencies"] - optional_dependencies["all"] = [ - dependency - for optional_dependencies in optional_dependencies.values() - for dependency in optional_dependencies - ] - optional_dependencies["test"].extend(optional_dependencies["all"]) - - # remove torch and torchvision if python version is not 3.10/3.11 - if sys.version_info.minor not in (10, 11): - optional_dependencies["test"] = list( - filter( - lambda d: not d.startswith( - ("sentencepiece", "transformers", "torch", "torchvision") - ), - optional_dependencies["test"], - ) + metadata["optional-dependencies"] = get_optional_dependencies(self.root) + + +def get_optional_dependencies(root): + + def read_feature_deps(feature): + req_file = os.path.join(root, "requirements", "extras", f"{feature}_requirements.txt") + with open(req_file, encoding="utf-8") as f: + return list(filter(lambda d: not d.startswith("#"), f.read().splitlines())) + + optional_dependencies = {"all": []} + + for feature in ("feature-processor", "huggingface", "local", "scipy"): + dependencies = read_feature_deps(feature) + optional_dependencies[feature] = dependencies + optional_dependencies["all"].extend(dependencies) + + # Test dependencies come last because we don't want them in `all` + optional_dependencies["test"] = read_feature_deps("test") + optional_dependencies["test"].extend(optional_dependencies["all"]) + + # remove torch and torchvision if python version is not 3.10/3.11 + if sys.version_info.minor not in (10, 11): + optional_dependencies["test"] = list( + filter( + lambda d: not d.startswith( + ("sentencepiece", "transformers", "torch", "torchvision") + ), + optional_dependencies["test"], ) + ) + + return optional_dependencies diff --git a/pyproject.toml b/pyproject.toml index fa287c10e9..98aa9ff38c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling", "hatch-requirements-txt>=0.3.0"] +requires = ["hatchling"] build-backend = "hatchling.build" [project] @@ -65,15 +65,8 @@ Homepage = "https://github.com/aws/sagemaker-python-sdk" path = "VERSION" pattern = "(?P.+)" -# Keep format of *_requirements.txt to be tracked by dependabot -[tool.hatch.metadata.hooks.requirements_txt.optional-dependencies] -feature-processor = ["requirements/extras/feature-processor_requirements.txt"] -huggingface = ["requirements/extras/huggingface_requirements.txt"] -local = ["requirements/extras/local_requirements.txt"] -scipy = ["requirements/extras/scipy_requirements.txt"] -test = ["requirements/extras/test_requirements.txt"] - -# Then do some postprocessing of optional dependencies +# Dynamically define optional dependencies from requirements.txt files so +# they can be be tracked by Dependabot [tool.hatch.metadata.hooks.custom] [tool.hatch.build.targets.wheel] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000..3deaed54e0 --- /dev/null +++ b/setup.py @@ -0,0 +1,74 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# 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. +"""Placeholder docstring""" +from __future__ import absolute_import + +import os +import re +import sys +from ast import literal_eval +from glob import glob +from pathlib import Path + +from setuptools import find_packages, setup + +sys.stderr.write( + """ +=============================== +Unsupported installation method +=============================== + +This version of sagemaker no longer supports installation with `python setup.py install`. + +Please use `python -m pip install .` instead. +""" +) + +HERE = Path(__file__).parent.absolute() +PYPROJECT = HERE.joinpath("pyproject.toml").read_text(encoding="utf-8") +BUILD_SCRIPT = HERE.joinpath("hatch_build.py").read_text(encoding="utf-8") + + +def get_dependencies(): + pattern = r"^dependencies = (\[.*?\])$" + array = re.search(pattern, PYPROJECT, flags=re.MULTILINE | re.DOTALL).group(1) + return literal_eval(array) + + +def get_optional_dependencies(): + pattern = r"^def get_optional_dependencies.+" + function = re.search(pattern, BUILD_SCRIPT, flags=re.MULTILINE | re.DOTALL).group(0) + identifiers = {} + exec(function, None, identifiers) + return identifiers["get_optional_dependencies"](str(HERE)) + + +setup( + name="sagemaker", + version=HERE.joinpath("VERSION").read_text().strip(), + packages=find_packages("src"), + package_dir={"": "src"}, + package_data={"": ["*.whl"]}, + py_modules=[os.path.splitext(os.path.basename(path))[0] for path in glob("src/*.py")], + include_package_data=True, + install_requires=get_dependencies(), + extras_require=get_optional_dependencies(), + entry_points={ + "console_scripts": [ + "sagemaker-upgrade-v2=sagemaker.cli.compatibility.v2.sagemaker_upgrade_v2:main", + ] + }, + scripts=[ + "src/sagemaker/serve/model_server/triton/pack_conda_env.sh", + ], +) From e46e5f9d060ae1ea4404af5745ec4e4aeedfac5f Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Fri, 21 Jun 2024 08:58:10 -0400 Subject: [PATCH 04/11] Update MANIFEST.in --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index c5eeeed043..ab053b00aa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,6 +8,7 @@ recursive-include requirements * include VERSION include LICENSE.txt include README.rst +include hatch_build.py prune tests From 8b01037e0336543aee05e3ac80d552a643fdb1cd Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Fri, 21 Jun 2024 14:29:00 -0400 Subject: [PATCH 05/11] Update test_requirements.txt --- requirements/extras/test_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/extras/test_requirements.txt b/requirements/extras/test_requirements.txt index 60904c51b0..f5f439f80e 100644 --- a/requirements/extras/test_requirements.txt +++ b/requirements/extras/test_requirements.txt @@ -1,4 +1,5 @@ tox==3.24.5 +build==1.2.1 flake8==4.0.1 pytest==6.2.5 pytest-cov==3.0.0 From 105da7b835ee49a50ff8921471379a205f991330 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Fri, 21 Jun 2024 21:46:59 -0400 Subject: [PATCH 06/11] make tests faster --- requirements/extras/test_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/extras/test_requirements.txt b/requirements/extras/test_requirements.txt index f5f439f80e..a8a4e624b9 100644 --- a/requirements/extras/test_requirements.txt +++ b/requirements/extras/test_requirements.txt @@ -1,5 +1,5 @@ tox==3.24.5 -build==1.2.1 +build[virtualenv]==1.2.1 flake8==4.0.1 pytest==6.2.5 pytest-cov==3.0.0 From 45807380f77dc2b527b405e6522758ac1ad9e4d7 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Mon, 24 Jun 2024 16:09:04 -0400 Subject: [PATCH 07/11] apply correct formatting --- src/sagemaker/algorithm.py | 6 +++--- src/sagemaker/amazon/amazon_estimator.py | 4 ++-- src/sagemaker/amazon/factorization_machines.py | 8 ++++---- src/sagemaker/amazon/ipinsights.py | 8 ++++---- src/sagemaker/amazon/kmeans.py | 8 ++++---- src/sagemaker/amazon/knn.py | 8 ++++---- src/sagemaker/amazon/lda.py | 8 ++++---- src/sagemaker/amazon/linear_learner.py | 8 ++++---- src/sagemaker/amazon/ntm.py | 8 ++++---- src/sagemaker/amazon/object2vec.py | 8 ++++---- src/sagemaker/amazon/pca.py | 8 ++++---- src/sagemaker/amazon/randomcutforest.py | 8 ++++---- src/sagemaker/apiutils/_base_types.py | 4 ++-- src/sagemaker/chainer/estimator.py | 6 +++--- src/sagemaker/chainer/model.py | 2 +- src/sagemaker/lineage/_api_types.py | 2 +- src/sagemaker/logs.py | 2 +- src/sagemaker/mxnet/estimator.py | 6 +++--- src/sagemaker/mxnet/model.py | 2 +- src/sagemaker/pytorch/model.py | 2 +- src/sagemaker/rl/estimator.py | 6 +++--- src/sagemaker/sklearn/estimator.py | 8 ++++---- src/sagemaker/sklearn/model.py | 2 +- src/sagemaker/utilities/search_expression.py | 2 +- src/sagemaker/workflow/airflow.py | 2 +- src/sagemaker/workflow/model_step.py | 2 +- src/sagemaker/xgboost/estimator.py | 6 +++--- src/sagemaker/xgboost/model.py | 2 +- tests/data/pipeline/model_step/pytorch_mnist/mnist.py | 4 ++-- tests/data/pytorch_mnist/mnist.py | 4 ++-- tests/unit/sagemaker/serve/builder/test_djl_builder.py | 8 ++++---- tests/unit/sagemaker/serve/builder/test_js_builder.py | 10 +++++----- tests/unit/test_rl.py | 4 ++-- 33 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/sagemaker/algorithm.py b/src/sagemaker/algorithm.py index a177b93f03..51c93c4986 100644 --- a/src/sagemaker/algorithm.py +++ b/src/sagemaker/algorithm.py @@ -68,7 +68,7 @@ def __init__( encrypt_inter_container_traffic: Union[bool, PipelineVariable] = False, use_spot_instances: Union[bool, PipelineVariable] = False, max_wait: Optional[Union[int, PipelineVariable]] = None, - **kwargs # pylint: disable=W0613 + **kwargs, # pylint: disable=W0613 ): """Initialize an ``AlgorithmEstimator`` instance. @@ -271,7 +271,7 @@ def create_model( serializer=IdentitySerializer(), deserializer=BytesDeserializer(), vpc_config_override=vpc_utils.VPC_CONFIG_DEFAULT, - **kwargs + **kwargs, ): """Create a model to deploy. @@ -325,7 +325,7 @@ def predict_wrapper(endpoint, session): vpc_config=self.get_vpc_config(vpc_config_override), sagemaker_session=self.sagemaker_session, predictor_cls=predictor_cls, - **kwargs + **kwargs, ) def transformer( diff --git a/src/sagemaker/amazon/amazon_estimator.py b/src/sagemaker/amazon/amazon_estimator.py index bf4e44df25..9f7bc3bda6 100644 --- a/src/sagemaker/amazon/amazon_estimator.py +++ b/src/sagemaker/amazon/amazon_estimator.py @@ -55,7 +55,7 @@ def __init__( instance_type: Optional[Union[str, PipelineVariable]] = None, data_location: Optional[str] = None, enable_network_isolation: Union[bool, PipelineVariable] = False, - **kwargs + **kwargs, ): """Initialize an AmazonAlgorithmEstimatorBase. @@ -91,7 +91,7 @@ def __init__( instance_count, instance_type, enable_network_isolation=enable_network_isolation, - **kwargs + **kwargs, ) data_location = data_location or ( diff --git a/src/sagemaker/amazon/factorization_machines.py b/src/sagemaker/amazon/factorization_machines.py index e651ee1460..2b24356ee9 100644 --- a/src/sagemaker/amazon/factorization_machines.py +++ b/src/sagemaker/amazon/factorization_machines.py @@ -114,7 +114,7 @@ def __init__( factors_init_scale: Optional[float] = None, factors_init_sigma: Optional[float] = None, factors_init_value: Optional[float] = None, - **kwargs + **kwargs, ): """Factorization Machines is :class:`Estimator` for general-purpose supervised learning. @@ -266,7 +266,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) @@ -332,7 +332,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Initialization for FactorizationMachinesModel class. @@ -365,5 +365,5 @@ def __init__( role, predictor_cls=FactorizationMachinesPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/ipinsights.py b/src/sagemaker/amazon/ipinsights.py index 6306c38069..737d13dd44 100644 --- a/src/sagemaker/amazon/ipinsights.py +++ b/src/sagemaker/amazon/ipinsights.py @@ -75,7 +75,7 @@ def __init__( random_negative_sampling_rate: Optional[int] = None, shuffled_negative_sampling_rate: Optional[int] = None, weight_decay: Optional[float] = None, - **kwargs + **kwargs, ): """This estimator is for IP Insights. @@ -168,7 +168,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): @@ -235,7 +235,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Creates object to get insights on S3 model data. @@ -268,5 +268,5 @@ def __init__( role, predictor_cls=IPInsightsPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/kmeans.py b/src/sagemaker/amazon/kmeans.py index b52a042766..144cdc934a 100644 --- a/src/sagemaker/amazon/kmeans.py +++ b/src/sagemaker/amazon/kmeans.py @@ -75,7 +75,7 @@ def __init__( epochs: Optional[int] = None, center_factor: Optional[int] = None, eval_metrics: Optional[List[Union[str, PipelineVariable]]] = None, - **kwargs + **kwargs, ): """A k-means clustering class :class:`~sagemaker.amazon.AmazonAlgorithmEstimatorBase`. @@ -184,7 +184,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training(self, records, mini_batch_size=5000, job_name=None): @@ -261,7 +261,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Initialization for KMeansModel class. @@ -294,5 +294,5 @@ def __init__( role, predictor_cls=KMeansPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/knn.py b/src/sagemaker/amazon/knn.py index a57070dfd0..f9c73381b4 100644 --- a/src/sagemaker/amazon/knn.py +++ b/src/sagemaker/amazon/knn.py @@ -85,7 +85,7 @@ def __init__( index_metric: Optional[str] = None, faiss_index_ivf_nlists: Optional[str] = None, faiss_index_pq_m: Optional[int] = None, - **kwargs + **kwargs, ): """k-nearest neighbors (KNN) is :class:`Estimator` used for classification and regression. @@ -181,7 +181,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): @@ -252,7 +252,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Function to initialize KNNModel. @@ -285,5 +285,5 @@ def __init__( role, predictor_cls=KNNPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/lda.py b/src/sagemaker/amazon/lda.py index d47b6ecad8..bd64d3ae2e 100644 --- a/src/sagemaker/amazon/lda.py +++ b/src/sagemaker/amazon/lda.py @@ -59,7 +59,7 @@ def __init__( max_restarts: Optional[int] = None, max_iterations: Optional[int] = None, tol: Optional[float] = None, - **kwargs + **kwargs, ): """Latent Dirichlet Allocation (LDA) is :class:`Estimator` used for unsupervised learning. @@ -159,7 +159,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training( # pylint: disable=signature-differs @@ -236,7 +236,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Initialization for LDAModel class. @@ -269,5 +269,5 @@ def __init__( role, predictor_cls=LDAPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/linear_learner.py b/src/sagemaker/amazon/linear_learner.py index 231f0ba344..695eb31dc1 100644 --- a/src/sagemaker/amazon/linear_learner.py +++ b/src/sagemaker/amazon/linear_learner.py @@ -190,7 +190,7 @@ def __init__( accuracy_top_k: Optional[int] = None, f_beta: Optional[float] = None, balance_multiclass_weights: Optional[bool] = None, - **kwargs + **kwargs, ): """An :class:`Estimator` for binary classification and regression. @@ -420,7 +420,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): @@ -505,7 +505,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Initialization for LinearLearnerModel. @@ -538,5 +538,5 @@ def __init__( role, predictor_cls=LinearLearnerPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/ntm.py b/src/sagemaker/amazon/ntm.py index ddc5b95eb2..4267ac8969 100644 --- a/src/sagemaker/amazon/ntm.py +++ b/src/sagemaker/amazon/ntm.py @@ -89,7 +89,7 @@ def __init__( clip_gradient: Optional[float] = None, weight_decay: Optional[float] = None, learning_rate: Optional[float] = None, - **kwargs + **kwargs, ): """Neural Topic Model (NTM) is :class:`Estimator` used for unsupervised learning. @@ -194,7 +194,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training( # pylint: disable=signature-differs @@ -269,7 +269,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Initialization for NTMModel class. @@ -302,5 +302,5 @@ def __init__( role, predictor_cls=NTMPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/object2vec.py b/src/sagemaker/amazon/object2vec.py index 8a967484ec..536fda0229 100644 --- a/src/sagemaker/amazon/object2vec.py +++ b/src/sagemaker/amazon/object2vec.py @@ -189,7 +189,7 @@ def __init__( enc1_layers: Optional[int] = None, enc0_freeze_pretrained_embedding: Optional[bool] = None, enc1_freeze_pretrained_embedding: Optional[bool] = None, - **kwargs + **kwargs, ): """Object2Vec is :class:`Estimator` used for anomaly detection. @@ -338,7 +338,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): @@ -363,7 +363,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Initialization for Object2VecModel class. @@ -396,5 +396,5 @@ def __init__( role, predictor_cls=Predictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/pca.py b/src/sagemaker/amazon/pca.py index 6e694211dd..953fff9d0b 100644 --- a/src/sagemaker/amazon/pca.py +++ b/src/sagemaker/amazon/pca.py @@ -67,7 +67,7 @@ def __init__( algorithm_mode: Optional[str] = None, subtract_mean: Optional[bool] = None, extra_components: Optional[int] = None, - **kwargs + **kwargs, ): """A Principal Components Analysis (PCA) @@ -155,7 +155,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): @@ -249,7 +249,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Initialization for PCAModel. @@ -282,5 +282,5 @@ def __init__( role, predictor_cls=PCAPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/amazon/randomcutforest.py b/src/sagemaker/amazon/randomcutforest.py index d1b3a4b9f7..21d98741b0 100644 --- a/src/sagemaker/amazon/randomcutforest.py +++ b/src/sagemaker/amazon/randomcutforest.py @@ -60,7 +60,7 @@ def __init__( num_samples_per_tree: Optional[int] = None, num_trees: Optional[int] = None, eval_metrics: Optional[List] = None, - **kwargs + **kwargs, ): """An `Estimator` class implementing a Random Cut Forest. @@ -144,7 +144,7 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs): self.role, sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), - **kwargs + **kwargs, ) def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): @@ -222,7 +222,7 @@ def __init__( model_data: Union[str, PipelineVariable], role: Optional[str] = None, sagemaker_session: Optional[Session] = None, - **kwargs + **kwargs, ): """Initialization for RandomCutForestModel class. @@ -255,5 +255,5 @@ def __init__( role, predictor_cls=RandomCutForestPredictor, sagemaker_session=sagemaker_session, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/apiutils/_base_types.py b/src/sagemaker/apiutils/_base_types.py index acee3d4d67..eb1555f109 100644 --- a/src/sagemaker/apiutils/_base_types.py +++ b/src/sagemaker/apiutils/_base_types.py @@ -123,7 +123,7 @@ def _list( boto_list_items_name, boto_next_token_name="NextToken", sagemaker_session=None, - **kwargs + **kwargs, ): """List objects from the SageMaker API.""" sagemaker_session = sagemaker_session or _utils.default_session() @@ -154,7 +154,7 @@ def _search( search_item_factory, boto_next_token_name="NextToken", sagemaker_session=None, - **kwargs + **kwargs, ): """Search for objects with the SageMaker API.""" sagemaker_session = sagemaker_session or _utils.default_session() diff --git a/src/sagemaker/chainer/estimator.py b/src/sagemaker/chainer/estimator.py index 09addf9910..f493c10846 100644 --- a/src/sagemaker/chainer/estimator.py +++ b/src/sagemaker/chainer/estimator.py @@ -54,7 +54,7 @@ def __init__( framework_version: Optional[str] = None, py_version: Optional[str] = None, image_uri: Optional[Union[str, PipelineVariable]] = None, - **kwargs + **kwargs, ): """This ``Estimator`` executes an Chainer script in a managed execution environment. @@ -173,7 +173,7 @@ def create_model( entry_point=None, source_dir=None, dependencies=None, - **kwargs + **kwargs, ): """Create a SageMaker ``ChainerModel`` object that can be deployed to an ``Endpoint``. @@ -225,7 +225,7 @@ def create_model( sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), dependencies=(dependencies or self.dependencies), - **kwargs + **kwargs, ) @classmethod diff --git a/src/sagemaker/chainer/model.py b/src/sagemaker/chainer/model.py index 963eaaa474..a99350f477 100644 --- a/src/sagemaker/chainer/model.py +++ b/src/sagemaker/chainer/model.py @@ -97,7 +97,7 @@ def __init__( py_version: Optional[str] = None, predictor_cls: callable = ChainerPredictor, model_server_workers: Optional[Union[int, PipelineVariable]] = None, - **kwargs + **kwargs, ): """Initialize an ChainerModel. diff --git a/src/sagemaker/lineage/_api_types.py b/src/sagemaker/lineage/_api_types.py index eb73a1bb39..20baedf383 100644 --- a/src/sagemaker/lineage/_api_types.py +++ b/src/sagemaker/lineage/_api_types.py @@ -207,7 +207,7 @@ def __init__(self, user_profile_arn=None, user_profile_name=None, domain_id=None user_profile_arn=user_profile_arn, user_profile_name=user_profile_name, domain_id=domain_id, - **kwargs + **kwargs, ) diff --git a/src/sagemaker/logs.py b/src/sagemaker/logs.py index 7e80d796e7..56c532021d 100644 --- a/src/sagemaker/logs.py +++ b/src/sagemaker/logs.py @@ -166,7 +166,7 @@ def log_stream(client, log_group, stream_name, start_time=0, skip=0): logStreamName=stream_name, startTime=start_time, startFromHead=True, - **token_arg + **token_arg, ) next_token = response["nextForwardToken"] events = response["events"] diff --git a/src/sagemaker/mxnet/estimator.py b/src/sagemaker/mxnet/estimator.py index 7d0ce2d494..104b93e00a 100644 --- a/src/sagemaker/mxnet/estimator.py +++ b/src/sagemaker/mxnet/estimator.py @@ -50,7 +50,7 @@ def __init__( hyperparameters: Optional[Dict[str, Union[str, PipelineVariable]]] = None, image_uri: Optional[Union[str, PipelineVariable]] = None, distribution: Optional[Dict[str, str]] = None, - **kwargs + **kwargs, ): """This ``Estimator`` executes an MXNet script in a managed MXNet execution environment. @@ -222,7 +222,7 @@ def create_model( source_dir=None, dependencies=None, image_uri=None, - **kwargs + **kwargs, ): """Create a SageMaker ``MXNetModel`` object that can be deployed to an ``Endpoint``. @@ -283,7 +283,7 @@ def create_model( sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), dependencies=(dependencies or self.dependencies), - **kwargs + **kwargs, ) if entry_point is None: diff --git a/src/sagemaker/mxnet/model.py b/src/sagemaker/mxnet/model.py index 487d336497..c220a022d6 100644 --- a/src/sagemaker/mxnet/model.py +++ b/src/sagemaker/mxnet/model.py @@ -99,7 +99,7 @@ def __init__( image_uri: Optional[Union[str, PipelineVariable]] = None, predictor_cls: callable = MXNetPredictor, model_server_workers: Optional[Union[int, PipelineVariable]] = None, - **kwargs + **kwargs, ): """Initialize an MXNetModel. diff --git a/src/sagemaker/pytorch/model.py b/src/sagemaker/pytorch/model.py index 92b96bd8c8..491402e789 100644 --- a/src/sagemaker/pytorch/model.py +++ b/src/sagemaker/pytorch/model.py @@ -100,7 +100,7 @@ def __init__( image_uri: Optional[Union[str, PipelineVariable]] = None, predictor_cls: callable = PyTorchPredictor, model_server_workers: Optional[Union[int, PipelineVariable]] = None, - **kwargs + **kwargs, ): """Initialize a PyTorchModel. diff --git a/src/sagemaker/rl/estimator.py b/src/sagemaker/rl/estimator.py index 3ed539fa2e..e262604ac3 100644 --- a/src/sagemaker/rl/estimator.py +++ b/src/sagemaker/rl/estimator.py @@ -84,7 +84,7 @@ def __init__( hyperparameters: Optional[Dict[str, Union[str, PipelineVariable]]] = None, image_uri: Optional[Union[str, PipelineVariable]] = None, metric_definitions: Optional[List[Dict[str, Union[str, PipelineVariable]]]] = None, - **kwargs + **kwargs, ): """Creates an RLEstimator for managed Reinforcement Learning (RL). @@ -168,7 +168,7 @@ def __init__( hyperparameters, image_uri=image_uri, metric_definitions=metric_definitions, - **kwargs + **kwargs, ) def create_model( @@ -178,7 +178,7 @@ def create_model( entry_point=None, source_dir=None, dependencies=None, - **kwargs + **kwargs, ): """Create a SageMaker ``RLEstimatorModel`` object that can be deployed to an Endpoint. diff --git a/src/sagemaker/sklearn/estimator.py b/src/sagemaker/sklearn/estimator.py index 9f4b25f214..ae66bc8338 100644 --- a/src/sagemaker/sklearn/estimator.py +++ b/src/sagemaker/sklearn/estimator.py @@ -47,7 +47,7 @@ def __init__( hyperparameters: Optional[Dict[str, Union[str, PipelineVariable]]] = None, image_uri: Optional[Union[str, PipelineVariable]] = None, image_uri_region: Optional[str] = None, - **kwargs + **kwargs, ): """Creates a SKLearn Estimator for Scikit-learn environment. @@ -154,7 +154,7 @@ def __init__( source_dir, hyperparameters, image_uri=image_uri, - **dict(kwargs, instance_count=1) + **dict(kwargs, instance_count=1), ) if image_uri is None: @@ -174,7 +174,7 @@ def create_model( entry_point=None, source_dir=None, dependencies=None, - **kwargs + **kwargs, ): """Create a SageMaker ``SKLearnModel`` object that can be deployed to an ``Endpoint``. @@ -229,7 +229,7 @@ def create_model( sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), dependencies=(dependencies or self.dependencies), - **kwargs + **kwargs, ) @classmethod diff --git a/src/sagemaker/sklearn/model.py b/src/sagemaker/sklearn/model.py index 1ab28eac37..a9252706c3 100644 --- a/src/sagemaker/sklearn/model.py +++ b/src/sagemaker/sklearn/model.py @@ -93,7 +93,7 @@ def __init__( image_uri: Optional[Union[str, PipelineVariable]] = None, predictor_cls: callable = SKLearnPredictor, model_server_workers: Optional[Union[int, PipelineVariable]] = None, - **kwargs + **kwargs, ): """Initialize an SKLearnModel. diff --git a/src/sagemaker/utilities/search_expression.py b/src/sagemaker/utilities/search_expression.py index 5b2aaf3226..d59ee76277 100644 --- a/src/sagemaker/utilities/search_expression.py +++ b/src/sagemaker/utilities/search_expression.py @@ -108,7 +108,7 @@ def __init__( nested_filters=None, sub_expressions=None, boolean_operator=BooleanOperator.AND, - **kwargs + **kwargs, ): """Construct a Search Expression object diff --git a/src/sagemaker/workflow/airflow.py b/src/sagemaker/workflow/airflow.py index 3678c3d97e..82f76304f5 100644 --- a/src/sagemaker/workflow/airflow.py +++ b/src/sagemaker/workflow/airflow.py @@ -1066,7 +1066,7 @@ def deploy_config_from_estimator( model_name=None, endpoint_name=None, tags=None, - **kwargs + **kwargs, ): """Export Airflow deploy config from a SageMaker estimator diff --git a/src/sagemaker/workflow/model_step.py b/src/sagemaker/workflow/model_step.py index 0ef77a5cd0..2b86f3726b 100644 --- a/src/sagemaker/workflow/model_step.py +++ b/src/sagemaker/workflow/model_step.py @@ -302,7 +302,7 @@ def _append_repack_model_step(self): self._repack_model_step_settings.pop("output_kms_key", None) or model.model_kms_key ), - **self._repack_model_step_settings + **self._repack_model_step_settings, ) self.steps.append(repack_model_step) diff --git a/src/sagemaker/xgboost/estimator.py b/src/sagemaker/xgboost/estimator.py index dfd7145e93..2921dbc2db 100644 --- a/src/sagemaker/xgboost/estimator.py +++ b/src/sagemaker/xgboost/estimator.py @@ -51,7 +51,7 @@ def __init__( py_version: str = "py3", image_uri: Optional[Union[str, PipelineVariable]] = None, image_uri_region: Optional[str] = None, - **kwargs + **kwargs, ): """An estimator that executes an XGBoost-based SageMaker Training Job. @@ -137,7 +137,7 @@ def create_model( entry_point=None, source_dir=None, dependencies=None, - **kwargs + **kwargs, ): """Create a SageMaker ``XGBoostModel`` object that can be deployed to an ``Endpoint``. @@ -188,7 +188,7 @@ def create_model( sagemaker_session=self.sagemaker_session, vpc_config=self.get_vpc_config(vpc_config_override), dependencies=(dependencies or self.dependencies), - **kwargs + **kwargs, ) @classmethod diff --git a/src/sagemaker/xgboost/model.py b/src/sagemaker/xgboost/model.py index 6d69801847..cf6bd2826c 100644 --- a/src/sagemaker/xgboost/model.py +++ b/src/sagemaker/xgboost/model.py @@ -92,7 +92,7 @@ def __init__( py_version: str = "py3", predictor_cls: callable = XGBoostPredictor, model_server_workers: Optional[Union[int, PipelineVariable]] = None, - **kwargs + **kwargs, ): """Initialize an XGBoostModel. diff --git a/tests/data/pipeline/model_step/pytorch_mnist/mnist.py b/tests/data/pipeline/model_step/pytorch_mnist/mnist.py index ef1c15ae60..d29e80b399 100644 --- a/tests/data/pipeline/model_step/pytorch_mnist/mnist.py +++ b/tests/data/pipeline/model_step/pytorch_mnist/mnist.py @@ -57,7 +57,7 @@ def _get_train_data_loader(training_dir, is_distributed, batch_size, **kwargs): batch_size=batch_size, shuffle=train_sampler is None, sampler=train_sampler, - **kwargs + **kwargs, ) return train_sampler, train_loader @@ -75,7 +75,7 @@ def _get_test_data_loader(training_dir, **kwargs): ), batch_size=1000, shuffle=True, - **kwargs + **kwargs, ) diff --git a/tests/data/pytorch_mnist/mnist.py b/tests/data/pytorch_mnist/mnist.py index ef1c15ae60..d29e80b399 100644 --- a/tests/data/pytorch_mnist/mnist.py +++ b/tests/data/pytorch_mnist/mnist.py @@ -57,7 +57,7 @@ def _get_train_data_loader(training_dir, is_distributed, batch_size, **kwargs): batch_size=batch_size, shuffle=train_sampler is None, sampler=train_sampler, - **kwargs + **kwargs, ) return train_sampler, train_loader @@ -75,7 +75,7 @@ def _get_test_data_loader(training_dir, **kwargs): ), batch_size=1000, shuffle=True, - **kwargs + **kwargs, ) diff --git a/tests/unit/sagemaker/serve/builder/test_djl_builder.py b/tests/unit/sagemaker/serve/builder/test_djl_builder.py index ccabdb86b3..531d84e8fc 100644 --- a/tests/unit/sagemaker/serve/builder/test_djl_builder.py +++ b/tests/unit/sagemaker/serve/builder/test_djl_builder.py @@ -307,7 +307,7 @@ def test_tune_for_djl_local_container( @patch("sagemaker.serve.builder.djl_builder._get_nb_instance", return_value="ml.g5.24xlarge") @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalDeepPingException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalDeepPingException("mock_exception")}, ) @patch( "sagemaker.serve.builder.djl_builder._get_admissible_tensor_parallel_degrees", @@ -360,7 +360,7 @@ def test_tune_for_djl_local_container_deep_ping_ex( @patch("sagemaker.serve.builder.djl_builder._get_nb_instance", return_value="ml.g5.24xlarge") @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalModelLoadException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalModelLoadException("mock_exception")}, ) @patch( "sagemaker.serve.builder.djl_builder._get_admissible_tensor_parallel_degrees", @@ -413,7 +413,7 @@ def test_tune_for_djl_local_container_load_ex( @patch("sagemaker.serve.builder.djl_builder._get_nb_instance", return_value="ml.g5.24xlarge") @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalModelOutOfMemoryException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalModelOutOfMemoryException("mock_exception")}, ) @patch( "sagemaker.serve.builder.djl_builder._get_admissible_tensor_parallel_degrees", @@ -466,7 +466,7 @@ def test_tune_for_djl_local_container_oom_ex( @patch("sagemaker.serve.builder.djl_builder._get_nb_instance", return_value="ml.g5.24xlarge") @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalModelInvocationException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalModelInvocationException("mock_exception")}, ) @patch( "sagemaker.serve.builder.djl_builder._get_admissible_tensor_parallel_degrees", diff --git a/tests/unit/sagemaker/serve/builder/test_js_builder.py b/tests/unit/sagemaker/serve/builder/test_js_builder.py index 2065e86818..a047053317 100644 --- a/tests/unit/sagemaker/serve/builder/test_js_builder.py +++ b/tests/unit/sagemaker/serve/builder/test_js_builder.py @@ -303,7 +303,7 @@ def test_tune_for_tgi_js_local_container_sharding_not_supported( ) @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalDeepPingException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalDeepPingException("mock_exception")}, ) def test_tune_for_tgi_js_local_container_deep_ping_ex( self, @@ -353,7 +353,7 @@ def test_tune_for_tgi_js_local_container_deep_ping_ex( ) @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalModelLoadException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalModelLoadException("mock_exception")}, ) def test_tune_for_tgi_js_local_container_load_ex( self, @@ -403,7 +403,7 @@ def test_tune_for_tgi_js_local_container_load_ex( ) @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalModelOutOfMemoryException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalModelOutOfMemoryException("mock_exception")}, ) def test_tune_for_tgi_js_local_container_oom_ex( self, @@ -453,7 +453,7 @@ def test_tune_for_tgi_js_local_container_oom_ex( ) @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalModelInvocationException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalModelInvocationException("mock_exception")}, ) def test_tune_for_tgi_js_local_container_invoke_ex( self, @@ -568,7 +568,7 @@ def test_tune_for_djl_js_local_container( ) @patch( "sagemaker.serve.builder.djl_builder._serial_benchmark", - **{"return_value.raiseError.side_effect": LocalModelInvocationException("mock_exception")} + **{"return_value.raiseError.side_effect": LocalModelInvocationException("mock_exception")}, ) def test_tune_for_djl_js_local_container_invoke_ex( self, diff --git a/tests/unit/test_rl.py b/tests/unit/test_rl.py index d9c4129cf6..49b145afca 100644 --- a/tests/unit/test_rl.py +++ b/tests/unit/test_rl.py @@ -95,7 +95,7 @@ def _rl_estimator( framework=RLFramework.MXNET, instance_type=None, base_job_name=None, - **kwargs + **kwargs, ): return RLEstimator( entry_point=SCRIPT_PATH, @@ -107,7 +107,7 @@ def _rl_estimator( instance_count=INSTANCE_COUNT, instance_type=instance_type or INSTANCE_TYPE, base_job_name=base_job_name, - **kwargs + **kwargs, ) From 06448c874d33ea860177d73c53547280017992fe Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Mon, 24 Jun 2024 23:19:27 -0400 Subject: [PATCH 08/11] add required __future__ import --- hatch_build.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hatch_build.py b/hatch_build.py index 39ae4e7efb..fd428aa1d8 100644 --- a/hatch_build.py +++ b/hatch_build.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import os import sys From 223387e29b5344752d6e421ad3cf6d48f07a7910 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Wed, 26 Jun 2024 15:56:17 -0400 Subject: [PATCH 09/11] Update tox.ini --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 89af7774bf..8a2e66116e 100644 --- a/tox.ini +++ b/tox.ini @@ -50,7 +50,7 @@ ignore = require-code = True [doc8] -ignore-path=.tox +ignore-path=.tox,src/sagemaker.egg-info # TODO: fix files before enabling max-line-length (D001) ignore=D001 @@ -195,4 +195,4 @@ commands = # this needs to succeed for tests to display in some IDEs deps = .[test] commands = - pytest --collect-only \ No newline at end of file + pytest --collect-only From d2a651531bfbb388505f3c2f7ba9a32b7886fdc3 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Tue, 16 Jul 2024 17:26:04 -0400 Subject: [PATCH 10/11] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 98aa9ff38c..c728c0a7c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ classifiers = [ ] dependencies = [ "attrs>=23.1.0,<24", - "boto3>=1.33.3,<2.0", + "boto3>=1.34.142,<2.0", "cloudpickle==2.2.1", "docker", "google-pasta", From d73a2f733373fc07ba82dae7420a62c7feb444b8 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Sat, 27 Jul 2024 16:22:14 -0400 Subject: [PATCH 11/11] address feedback --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c728c0a7c0..d1c634f86d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,6 @@ name = "sagemaker" dynamic = ["version", "optional-dependencies"] description = "Open source library for training and deploying models on Amazon SageMaker." readme = "README.rst" -license = "Apache-2.0" requires-python = ">=3.8" authors = [ { name = "Amazon Web Services" },