diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000..1a9403a949 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +application_import_names = sagemaker, tests +import-order-style = google diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e483159b23..88b25beafb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ CHANGELOG ======== * bug-fix: Change module names to string type in __all__ +* bug-fix: tensorflow-serving-api: SageMaker does not conflict with tensorflow-serving-api module version * feature: Local Mode: add support for local training data using file:// 1.2.4 diff --git a/doc/conf.py b/doc/conf.py index 8e0ef9c924..dee71df4f8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,4 +1,17 @@ -# -*- coding: utf-8 -*- +# Copyright 2017-2018 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. +from __future__ import absolute_import + import os import sys from datetime import datetime diff --git a/setup.py b/setup.py index 745bd3edc8..7a0fba7373 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,19 @@ -import os +# Copyright 2017-2018 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. +from __future__ import absolute_import + from glob import glob -from os.path import basename -from os.path import splitext +import os from setuptools import setup, find_packages @@ -15,7 +27,7 @@ def read(fname): description="Open source library for training and deploying models on Amazon SageMaker.", packages=find_packages('src'), package_dir={'': 'src'}, - py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], + py_modules=[os.splitext(os.basename(path))[0] for path in glob('src/*.py')], long_description=read('README.rst'), author="Amazon Web Services", url='https://github.com/aws/sagemaker-python-sdk/', diff --git a/src/sagemaker/__init__.py b/src/sagemaker/__init__.py index 1d58b5cdd8..c37c6d836f 100644 --- a/src/sagemaker/__init__.py +++ b/src/sagemaker/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 diff --git a/src/sagemaker/amazon/__init__.py b/src/sagemaker/amazon/__init__.py index 4d78ed0e5c..0f80bcae4c 100644 --- a/src/sagemaker/amazon/__init__.py +++ b/src/sagemaker/amazon/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 diff --git a/src/sagemaker/amazon/amazon_estimator.py b/src/sagemaker/amazon/amazon_estimator.py index 2d752cf24e..fe80f59c39 100644 --- a/src/sagemaker/amazon/amazon_estimator.py +++ b/src/sagemaker/amazon/amazon_estimator.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import json import logging import tempfile diff --git a/src/sagemaker/amazon/common.py b/src/sagemaker/amazon/common.py index 6b5dc0c68a..df4aa9e3b6 100644 --- a/src/sagemaker/amazon/common.py +++ b/src/sagemaker/amazon/common.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import io import struct import sys diff --git a/src/sagemaker/amazon/factorization_machines.py b/src/sagemaker/amazon/factorization_machines.py index 5297367947..a6d3bd0497 100644 --- a/src/sagemaker/amazon/factorization_machines.py +++ b/src/sagemaker/amazon/factorization_machines.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa diff --git a/src/sagemaker/amazon/hyperparameter.py b/src/sagemaker/amazon/hyperparameter.py index a3ac76367c..31014b7f2b 100644 --- a/src/sagemaker/amazon/hyperparameter.py +++ b/src/sagemaker/amazon/hyperparameter.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +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. +from __future__ import absolute_import class Hyperparameter(object): diff --git a/src/sagemaker/amazon/kmeans.py b/src/sagemaker/amazon/kmeans.py index 60300c01b7..b4657bce42 100644 --- a/src/sagemaker/amazon/kmeans.py +++ b/src/sagemaker/amazon/kmeans.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa diff --git a/src/sagemaker/amazon/lda.py b/src/sagemaker/amazon/lda.py index 30367b2b0f..934c0b3a48 100644 --- a/src/sagemaker/amazon/lda.py +++ b/src/sagemaker/amazon/lda.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa diff --git a/src/sagemaker/amazon/linear_learner.py b/src/sagemaker/amazon/linear_learner.py index 752d02d214..21063b6dc0 100644 --- a/src/sagemaker/amazon/linear_learner.py +++ b/src/sagemaker/amazon/linear_learner.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa diff --git a/src/sagemaker/amazon/ntm.py b/src/sagemaker/amazon/ntm.py index 21f0c8f1aa..3fa8b9fecb 100644 --- a/src/sagemaker/amazon/ntm.py +++ b/src/sagemaker/amazon/ntm.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa diff --git a/src/sagemaker/amazon/pca.py b/src/sagemaker/amazon/pca.py index a82f818d6a..1afe50752e 100644 --- a/src/sagemaker/amazon/pca.py +++ b/src/sagemaker/amazon/pca.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa diff --git a/src/sagemaker/amazon/randomcutforest.py b/src/sagemaker/amazon/randomcutforest.py index c310f6af48..64730756ce 100644 --- a/src/sagemaker/amazon/randomcutforest.py +++ b/src/sagemaker/amazon/randomcutforest.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa diff --git a/src/sagemaker/amazon/validation.py b/src/sagemaker/amazon/validation.py index 7c7fa4f2a0..baaae4ad36 100644 --- a/src/sagemaker/amazon/validation.py +++ b/src/sagemaker/amazon/validation.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +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. +from __future__ import absolute_import def gt(minimum): diff --git a/src/sagemaker/cli/__init__.py b/src/sagemaker/cli/__init__.py index 4d78ed0e5c..0f80bcae4c 100644 --- a/src/sagemaker/cli/__init__.py +++ b/src/sagemaker/cli/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 diff --git a/src/sagemaker/cli/common.py b/src/sagemaker/cli/common.py index 80f6fe07ca..346ed5b570 100644 --- a/src/sagemaker/cli/common.py +++ b/src/sagemaker/cli/common.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 diff --git a/src/sagemaker/cli/main.py b/src/sagemaker/cli/main.py index 5306757a0f..a466482bf8 100644 --- a/src/sagemaker/cli/main.py +++ b/src/sagemaker/cli/main.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 diff --git a/src/sagemaker/cli/mxnet.py b/src/sagemaker/cli/mxnet.py index fa7f2c2a7f..ae363a03ce 100644 --- a/src/sagemaker/cli/mxnet.py +++ b/src/sagemaker/cli/mxnet.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.cli.common import HostCommand, TrainCommand diff --git a/src/sagemaker/cli/tensorflow.py b/src/sagemaker/cli/tensorflow.py index 231fa96e83..c04716eca8 100644 --- a/src/sagemaker/cli/tensorflow.py +++ b/src/sagemaker/cli/tensorflow.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.cli.common import HostCommand, TrainCommand diff --git a/src/sagemaker/content_types.py b/src/sagemaker/content_types.py index 2ec9669c20..e6e1ee6bfb 100644 --- a/src/sagemaker/content_types.py +++ b/src/sagemaker/content_types.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + CONTENT_TYPE_JSON = 'application/json' CONTENT_TYPE_CSV = 'text/csv' CONTENT_TYPE_OCTET_STREAM = 'application/octet-stream' diff --git a/src/sagemaker/estimator.py b/src/sagemaker/estimator.py index 61a403de4d..5beded395b 100644 --- a/src/sagemaker/estimator.py +++ b/src/sagemaker/estimator.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 diff --git a/src/sagemaker/fw_utils.py b/src/sagemaker/fw_utils.py index 7ffbc043d1..420be7f5ee 100644 --- a/src/sagemaker/fw_utils.py +++ b/src/sagemaker/fw_utils.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import os import re import tarfile diff --git a/src/sagemaker/local/__init__.py b/src/sagemaker/local/__init__.py index b48743e351..3aa8c44267 100644 --- a/src/sagemaker/local/__init__.py +++ b/src/sagemaker/local/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from .local_session import (file_input, LocalSession, LocalSagemakerRuntimeClient, LocalSagemakerClient) diff --git a/src/sagemaker/local/image.py b/src/sagemaker/local/image.py index fad5cc0680..06333990e5 100644 --- a/src/sagemaker/local/image.py +++ b/src/sagemaker/local/image.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import base64 import errno import json diff --git a/src/sagemaker/local/local_session.py b/src/sagemaker/local/local_session.py index f218f899f0..ff0586a4d7 100644 --- a/src/sagemaker/local/local_session.py +++ b/src/sagemaker/local/local_session.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import datetime import logging import platform diff --git a/src/sagemaker/logs.py b/src/sagemaker/logs.py index ea5d9482f0..f94f6366f5 100644 --- a/src/sagemaker/logs.py +++ b/src/sagemaker/logs.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import collections import functools import os diff --git a/src/sagemaker/model.py b/src/sagemaker/model.py index 6b7d7d1e8e..183b101153 100644 --- a/src/sagemaker/model.py +++ b/src/sagemaker/model.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import logging import sagemaker diff --git a/src/sagemaker/mxnet/__init__.py b/src/sagemaker/mxnet/__init__.py index b6f4e7ef93..90981aa7bd 100644 --- a/src/sagemaker/mxnet/__init__.py +++ b/src/sagemaker/mxnet/__init__.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.mxnet.estimator import MXNet from sagemaker.mxnet.model import MXNetModel, MXNetPredictor diff --git a/src/sagemaker/mxnet/defaults.py b/src/sagemaker/mxnet/defaults.py index 3034b7b7c8..99819a9bfc 100644 --- a/src/sagemaker/mxnet/defaults.py +++ b/src/sagemaker/mxnet/defaults.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,4 +10,6 @@ # 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. +from __future__ import absolute_import + MXNET_VERSION = '1.1' diff --git a/src/sagemaker/mxnet/estimator.py b/src/sagemaker/mxnet/estimator.py index 5ff2308b75..71e72e06a1 100644 --- a/src/sagemaker/mxnet/estimator.py +++ b/src/sagemaker/mxnet/estimator.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.estimator import Framework from sagemaker.fw_utils import create_image_uri, framework_name_from_image, framework_version_from_tag from sagemaker.mxnet.defaults import MXNET_VERSION diff --git a/src/sagemaker/mxnet/model.py b/src/sagemaker/mxnet/model.py index f0bd7b94f5..7cbdf8eb43 100644 --- a/src/sagemaker/mxnet/model.py +++ b/src/sagemaker/mxnet/model.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import sagemaker from sagemaker.fw_utils import create_image_uri from sagemaker.model import FrameworkModel, MODEL_SERVER_WORKERS_PARAM_NAME diff --git a/src/sagemaker/predictor.py b/src/sagemaker/predictor.py index 2e3ed0101b..5fb2421b70 100644 --- a/src/sagemaker/predictor.py +++ b/src/sagemaker/predictor.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 diff --git a/src/sagemaker/session.py b/src/sagemaker/session.py index 957104071b..7949308a3a 100644 --- a/src/sagemaker/session.py +++ b/src/sagemaker/session.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 diff --git a/src/sagemaker/tensorflow/__init__.py b/src/sagemaker/tensorflow/__init__.py index f53b6f5f3c..f8f3e880c2 100644 --- a/src/sagemaker/tensorflow/__init__.py +++ b/src/sagemaker/tensorflow/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import sys import os diff --git a/src/sagemaker/tensorflow/defaults.py b/src/sagemaker/tensorflow/defaults.py index bca03df141..8b499d74fe 100644 --- a/src/sagemaker/tensorflow/defaults.py +++ b/src/sagemaker/tensorflow/defaults.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,4 +10,6 @@ # 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. +from __future__ import absolute_import + TF_VERSION = '1.6' diff --git a/src/sagemaker/tensorflow/estimator.py b/src/sagemaker/tensorflow/estimator.py index a057310b0a..0c38873026 100644 --- a/src/sagemaker/tensorflow/estimator.py +++ b/src/sagemaker/tensorflow/estimator.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import contextlib import logging import os diff --git a/src/sagemaker/tensorflow/model.py b/src/sagemaker/tensorflow/model.py index 3f93ef7ce8..b1e5d0b2bb 100644 --- a/src/sagemaker/tensorflow/model.py +++ b/src/sagemaker/tensorflow/model.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import sagemaker from sagemaker.fw_utils import create_image_uri from sagemaker.model import FrameworkModel, MODEL_SERVER_WORKERS_PARAM_NAME diff --git a/src/sagemaker/tensorflow/predictor.py b/src/sagemaker/tensorflow/predictor.py index 1b6dd260c6..41a054999e 100644 --- a/src/sagemaker/tensorflow/predictor.py +++ b/src/sagemaker/tensorflow/predictor.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import json import google.protobuf.json_format as json_format diff --git a/src/sagemaker/user_agent.py b/src/sagemaker/user_agent.py index b32d29c217..6f50c139b1 100644 --- a/src/sagemaker/user_agent.py +++ b/src/sagemaker/user_agent.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pkg_resources import platform import sys diff --git a/src/sagemaker/utils.py b/src/sagemaker/utils.py index 2ed0330d18..0ff5ba45c6 100644 --- a/src/sagemaker/utils.py +++ b/src/sagemaker/utils.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import time import re diff --git a/tests/__init__.py b/tests/__init__.py index 4d78ed0e5c..b04a7e2246 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,3 +10,4 @@ # 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. +from __future__ import absolute_import diff --git a/tests/component/__init__.py b/tests/component/__init__.py index e1e6f4571f..b04a7e2246 100644 --- a/tests/component/__init__.py +++ b/tests/component/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,3 +10,4 @@ # 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. +from __future__ import absolute_import diff --git a/tests/component/test_mxnet_estimator.py b/tests/component/test_mxnet_estimator.py index fe03a82ab6..5316d56130 100644 --- a/tests/component/test_mxnet_estimator.py +++ b/tests/component/test_mxnet_estimator.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock from sagemaker.mxnet import MXNet diff --git a/tests/component/test_tf_estimator.py b/tests/component/test_tf_estimator.py index 4fe8e9f806..8d7ede0429 100644 --- a/tests/component/test_tf_estimator.py +++ b/tests/component/test_tf_estimator.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock from sagemaker.tensorflow import TensorFlow diff --git a/tests/conftest.py b/tests/conftest.py index 8d9d361911..6445f62fa2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import json import boto3 diff --git a/tests/data/cifar_10/source/__init__.py b/tests/data/cifar_10/source/__init__.py index e69de29bb2..b04a7e2246 100644 --- a/tests/data/cifar_10/source/__init__.py +++ b/tests/data/cifar_10/source/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2017-2018 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. +from __future__ import absolute_import diff --git a/tests/data/cifar_10/source/resnet_cifar_10.py b/tests/data/cifar_10/source/resnet_cifar_10.py index 48ce081bfa..47d416ebcf 100644 --- a/tests/data/cifar_10/source/resnet_cifar_10.py +++ b/tests/data/cifar_10/source/resnet_cifar_10.py @@ -1,3 +1,15 @@ +# Copyright 2017-2018 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. from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/tests/data/cifar_10/source/resnet_model.py b/tests/data/cifar_10/source/resnet_model.py index 328e84ca55..098ae8f701 100644 --- a/tests/data/cifar_10/source/resnet_model.py +++ b/tests/data/cifar_10/source/resnet_model.py @@ -27,7 +27,6 @@ 'v1' variant in [1] is the use of batch normalization before every weight layer rather than after. """ - from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/tests/data/dummy_script.py b/tests/data/dummy_script.py index ffff6e4949..6381f25211 100644 --- a/tests/data/dummy_script.py +++ b/tests/data/dummy_script.py @@ -1,2 +1,16 @@ +# Copyright 2017-2018 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. +from __future__ import absolute_import + print('This is definitely code which does machine learning stuff') print('and not just a random file I threw together for unit testing.') diff --git a/tests/data/iris/failure_script.py b/tests/data/iris/failure_script.py index 01bfaf4976..2dd8783372 100644 --- a/tests/data/iris/failure_script.py +++ b/tests/data/iris/failure_script.py @@ -1,3 +1,17 @@ +# Copyright 2017-2018 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. +from __future__ import absolute_import + def estimator_fn(run_config, params): """For use with integration tests expecting failures.""" raise Exception('This failure is expected.') diff --git a/tests/data/iris/iris-dnn-classifier.py b/tests/data/iris/iris-dnn-classifier.py index 8585e75066..f77433bbb7 100644 --- a/tests/data/iris/iris-dnn-classifier.py +++ b/tests/data/iris/iris-dnn-classifier.py @@ -1,3 +1,17 @@ +# Copyright 2017-2018 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. +from __future__ import absolute_import + import numpy as np import os import tensorflow as tf diff --git a/tests/data/mxnet_mnist/failure_script.py b/tests/data/mxnet_mnist/failure_script.py index f0afa4fe08..f81416eec6 100644 --- a/tests/data/mxnet_mnist/failure_script.py +++ b/tests/data/mxnet_mnist/failure_script.py @@ -1,3 +1,17 @@ +# Copyright 2017-2018 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. +from __future__ import absolute_import + def train(**kwargs): """For use with integration tests expecting failures.""" raise Exception('This failure is expected.') diff --git a/tests/data/mxnet_mnist/mnist.py b/tests/data/mxnet_mnist/mnist.py index a0a1d317de..91bb2ca2b8 100644 --- a/tests/data/mxnet_mnist/mnist.py +++ b/tests/data/mxnet_mnist/mnist.py @@ -1,3 +1,17 @@ +# Copyright 2017-2018 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. +from __future__ import absolute_import + import logging import gzip diff --git a/tests/data/mxnet_mnist/mnist_hosting_with_custom_handlers.py b/tests/data/mxnet_mnist/mnist_hosting_with_custom_handlers.py index d5c27b0835..af3a802d5b 100644 --- a/tests/data/mxnet_mnist/mnist_hosting_with_custom_handlers.py +++ b/tests/data/mxnet_mnist/mnist_hosting_with_custom_handlers.py @@ -1,3 +1,17 @@ +# Copyright 2017-2018 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. +from __future__ import absolute_import + import gzip import json import mxnet as mx diff --git a/tests/integ/__init__.py b/tests/integ/__init__.py index 06a8153acb..c8b66220fe 100644 --- a/tests/integ/__init__.py +++ b/tests/integ/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import logging import os diff --git a/tests/integ/record_set.py b/tests/integ/record_set.py index 587ed88d14..77da668fbd 100644 --- a/tests/integ/record_set.py +++ b/tests/integ/record_set.py @@ -1,3 +1,17 @@ +# Copyright 2017-2018 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. +from __future__ import absolute_import + from six.moves.urllib.parse import urlparse from sagemaker.amazon.amazon_estimator import RecordSet diff --git a/tests/integ/test_byo_estimator.py b/tests/integ/test_byo_estimator.py index 1feb2468db..8f554f1793 100644 --- a/tests/integ/test_byo_estimator.py +++ b/tests/integ/test_byo_estimator.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import gzip import io import json diff --git a/tests/integ/test_factorization_machines.py b/tests/integ/test_factorization_machines.py index b5264656e6..437d77cfc2 100644 --- a/tests/integ/test_factorization_machines.py +++ b/tests/integ/test_factorization_machines.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import gzip import os import pickle @@ -37,7 +39,7 @@ def test_factorization_machines(sagemaker_session): fm = FactorizationMachines(role='SageMakerRole', train_instance_count=1, train_instance_type='ml.c4.xlarge', num_factors=10, predictor_type='regressor', - epochs=2, clip_gradient=1e2, eps=0.001, rescale_grad=1.0/100, + epochs=2, clip_gradient=1e2, eps=0.001, rescale_grad=1.0 / 100, sagemaker_session=sagemaker_session, base_job_name='test-fm') # training labels must be 'float32' diff --git a/tests/integ/test_kmeans.py b/tests/integ/test_kmeans.py index 9a865c915b..15fd15d3d2 100644 --- a/tests/integ/test_kmeans.py +++ b/tests/integ/test_kmeans.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import gzip import os import pickle diff --git a/tests/integ/test_lda.py b/tests/integ/test_lda.py index 73f55222b7..866c5d3bdb 100644 --- a/tests/integ/test_lda.py +++ b/tests/integ/test_lda.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import os import numpy as np diff --git a/tests/integ/test_linear_learner.py b/tests/integ/test_linear_learner.py index 2c936591cf..82f3b31feb 100644 --- a/tests/integ/test_linear_learner.py +++ b/tests/integ/test_linear_learner.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import gzip import os import pickle diff --git a/tests/integ/test_mxnet_train.py b/tests/integ/test_mxnet_train.py index c33c3420e9..bd94cc536c 100644 --- a/tests/integ/test_mxnet_train.py +++ b/tests/integ/test_mxnet_train.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import os import time diff --git a/tests/integ/test_ntm.py b/tests/integ/test_ntm.py index 8c4b650d9d..dcb89abca7 100644 --- a/tests/integ/test_ntm.py +++ b/tests/integ/test_ntm.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import os import numpy as np diff --git a/tests/integ/test_pca.py b/tests/integ/test_pca.py index 54a7769ace..c80a87b437 100644 --- a/tests/integ/test_pca.py +++ b/tests/integ/test_pca.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import gzip import os import pickle diff --git a/tests/integ/test_randomcutforest.py b/tests/integ/test_randomcutforest.py index 04945cc337..a749af985c 100644 --- a/tests/integ/test_randomcutforest.py +++ b/tests/integ/test_randomcutforest.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import numpy as np import pytest diff --git a/tests/integ/test_tf.py b/tests/integ/test_tf.py index bbcb79fbad..eb58eafbcb 100644 --- a/tests/integ/test_tf.py +++ b/tests/integ/test_tf.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import os import time diff --git a/tests/integ/test_tf_cifar.py b/tests/integ/test_tf_cifar.py index f75113ee27..4a1698fafc 100644 --- a/tests/integ/test_tf_cifar.py +++ b/tests/integ/test_tf_cifar.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import os import pickle diff --git a/tests/integ/timeout.py b/tests/integ/timeout.py index 4a063982ec..5915fcdf25 100644 --- a/tests/integ/timeout.py +++ b/tests/integ/timeout.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import signal from contextlib import contextmanager import logging diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 4a5780dd1e..2d945650f0 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. -import os - -DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data') +from __future__ import absolute_import + +import os + +DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data') diff --git a/tests/unit/test_amazon_estimator.py b/tests/unit/test_amazon_estimator.py index cf08e89f2c..4edc787ff0 100644 --- a/tests/unit/test_amazon_estimator.py +++ b/tests/unit/test_amazon_estimator.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock, patch, call import numpy as np diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index 1956e95ba5..36b5eacbdb 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest import sagemaker.cli.main as cli from mock import patch diff --git a/tests/unit/test_common.py b/tests/unit/test_common.py index d4d2b1b4d5..dc1ad48e17 100644 --- a/tests/unit/test_common.py +++ b/tests/unit/test_common.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import numpy as np import tempfile import pytest diff --git a/tests/unit/test_create_deploy_entities.py b/tests/unit/test_create_deploy_entities.py index e895540c40..bc688d8703 100644 --- a/tests/unit/test_create_deploy_entities.py +++ b/tests/unit/test_create_deploy_entities.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock diff --git a/tests/unit/test_default_bucket.py b/tests/unit/test_default_bucket.py index af5d9d0ec3..e7478cf956 100644 --- a/tests/unit/test_default_bucket.py +++ b/tests/unit/test_default_bucket.py @@ -1,15 +1,17 @@ -# Copyright 2017 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. +# Copyright 2017-2018 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. +from __future__ import absolute_import + import pytest from botocore.exceptions import ClientError from mock import Mock diff --git a/tests/unit/test_endpoint_from_job.py b/tests/unit/test_endpoint_from_job.py index bad6ab2f06..5588a0ac89 100644 --- a/tests/unit/test_endpoint_from_job.py +++ b/tests/unit/test_endpoint_from_job.py @@ -1,15 +1,17 @@ -# Copyright 2017 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. +# Copyright 2017-2018 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. +from __future__ import absolute_import + import pytest from mock import Mock diff --git a/tests/unit/test_endpoint_from_model_data.py b/tests/unit/test_endpoint_from_model_data.py index 13afb90565..615a49d087 100644 --- a/tests/unit/test_endpoint_from_model_data.py +++ b/tests/unit/test_endpoint_from_model_data.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from botocore.exceptions import ClientError from mock import Mock diff --git a/tests/unit/test_estimator.py b/tests/unit/test_estimator.py index ac76742ad3..53da9a97a8 100644 --- a/tests/unit/test_estimator.py +++ b/tests/unit/test_estimator.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import logging import json import os diff --git a/tests/unit/test_fm.py b/tests/unit/test_fm.py index 2948c8b153..ad6a93c523 100644 --- a/tests/unit/test_fm.py +++ b/tests/unit/test_fm.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock, patch diff --git a/tests/unit/test_fw_utils.py b/tests/unit/test_fw_utils.py index c061556181..b953182ebe 100644 --- a/tests/unit/test_fw_utils.py +++ b/tests/unit/test_fw_utils.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import inspect from mock import Mock import os diff --git a/tests/unit/test_hyperparameter.py b/tests/unit/test_hyperparameter.py index db7ed3f64c..4b07b7efee 100644 --- a/tests/unit/test_hyperparameter.py +++ b/tests/unit/test_hyperparameter.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from sagemaker.amazon.hyperparameter import Hyperparameter diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py index b7b8be0a8d..3177797e1c 100644 --- a/tests/unit/test_image.py +++ b/tests/unit/test_image.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import base64 import json import os diff --git a/tests/unit/test_kmeans.py b/tests/unit/test_kmeans.py index fcc4cebfe0..f2ca262c3c 100644 --- a/tests/unit/test_kmeans.py +++ b/tests/unit/test_kmeans.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock, patch diff --git a/tests/unit/test_lda.py b/tests/unit/test_lda.py index a5f71c1fc5..34e2d0bd8b 100644 --- a/tests/unit/test_lda.py +++ b/tests/unit/test_lda.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock, patch diff --git a/tests/unit/test_linear_learner.py b/tests/unit/test_linear_learner.py index dcfd1a1f74..bdc18c43ac 100644 --- a/tests/unit/test_linear_learner.py +++ b/tests/unit/test_linear_learner.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock, patch diff --git a/tests/unit/test_local_session.py b/tests/unit/test_local_session.py index 5ba7c0c956..f39644464f 100644 --- a/tests/unit/test_local_session.py +++ b/tests/unit/test_local_session.py @@ -1,4 +1,4 @@ -# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest import urllib3 diff --git a/tests/unit/test_model.py b/tests/unit/test_model.py index f0a36c3c9b..366d6c0004 100644 --- a/tests/unit/test_model.py +++ b/tests/unit/test_model.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.model import FrameworkModel from sagemaker.predictor import RealTimePredictor import os diff --git a/tests/unit/test_mxnet.py b/tests/unit/test_mxnet.py index 2f9784261d..34f76cc227 100644 --- a/tests/unit/test_mxnet.py +++ b/tests/unit/test_mxnet.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import logging import json @@ -22,7 +24,6 @@ from sagemaker.mxnet import MXNet from sagemaker.mxnet import MXNetPredictor, MXNetModel - DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data') SCRIPT_PATH = os.path.join(DATA_DIR, 'dummy_script.py') TIMESTAMP = '2017-11-06-14:14:15.672' @@ -42,13 +43,14 @@ @pytest.fixture() def sagemaker_session(): boto_mock = Mock(name='boto_session', region_name=REGION) - sms = Mock(name='sagemaker_session', boto_session=boto_mock, - boto_region_name=REGION, config=None, local_mode=False) - sms.sagemaker_client.describe_training_job = Mock(return_value={'ModelArtifacts': - {'S3ModelArtifacts': 's3://m/m.tar.gz'}}) - sms.default_bucket = Mock(name='default_bucket', return_value=BUCKET_NAME) - sms.expand_role = Mock(name="expand_role", return_value=ROLE) - return sms + session = Mock(name='sagemaker_session', boto_session=boto_mock, + boto_region_name=REGION, config=None, local_mode=False) + + describe = {'ModelArtifacts': {'S3ModelArtifacts': 's3://m/m.tar.gz'}} + session.sagemaker_client.describe_training_job = Mock(return_value=describe) + session.default_bucket = Mock(name='default_bucket', return_value=BUCKET_NAME) + session.expand_role = Mock(name="expand_role", return_value=ROLE) + return session def _get_full_image_uri(version): @@ -56,9 +58,11 @@ def _get_full_image_uri(version): def _create_train_job(version): - return {'image': _get_full_image_uri(version), - 'input_mode': 'File', - 'input_config': [{ + return { + 'image': _get_full_image_uri(version), + 'input_mode': 'File', + 'input_config': [ + { 'ChannelName': 'training', 'DataSource': { 'S3DataSource': { @@ -66,29 +70,31 @@ def _create_train_job(version): 'S3DataType': 'S3Prefix' } } - }], - 'role': ROLE, - 'job_name': JOB_NAME, - 'output_config': { - 'S3OutputPath': 's3://{}/'.format(BUCKET_NAME), - }, - 'resource_config': { - 'InstanceType': 'ml.c4.4xlarge', - 'InstanceCount': 1, - 'VolumeSizeInGB': 30, - }, - 'hyperparameters': { - 'sagemaker_program': json.dumps('dummy_script.py'), - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': str(logging.INFO), - 'sagemaker_job_name': json.dumps(JOB_NAME), - 'sagemaker_submit_directory': - json.dumps('s3://{}/{}/source/sourcedir.tar.gz'.format(BUCKET_NAME, JOB_NAME)), - 'sagemaker_region': '"us-west-2"' - }, - 'stop_condition': { - 'MaxRuntimeInSeconds': 24 * 60 * 60 - }} + } + ], + 'role': ROLE, + 'job_name': JOB_NAME, + 'output_config': { + 'S3OutputPath': 's3://{}/'.format(BUCKET_NAME), + }, + 'resource_config': { + 'InstanceType': 'ml.c4.4xlarge', + 'InstanceCount': 1, + 'VolumeSizeInGB': 30, + }, + 'hyperparameters': { + 'sagemaker_program': json.dumps('dummy_script.py'), + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': str(logging.INFO), + 'sagemaker_job_name': json.dumps(JOB_NAME), + 'sagemaker_submit_directory': + json.dumps('s3://{}/{}/source/sourcedir.tar.gz'.format(BUCKET_NAME, JOB_NAME)), + 'sagemaker_region': '"us-west-2"' + }, + 'stop_condition': { + 'MaxRuntimeInSeconds': 24 * 60 * 60 + } + } def test_create_model(sagemaker_session, mxnet_version): @@ -140,15 +146,15 @@ def test_mxnet(strftime, sagemaker_session, mxnet_version): model = mx.create_model() expected_image_base = '520713654638.dkr.ecr.us-west-2.amazonaws.com/sagemaker-mxnet:{}-gpu-py2' - assert {'Environment': - {'SAGEMAKER_SUBMIT_DIRECTORY': - 's3://mybucket/sagemaker-mxnet-{}/sourcedir.tar.gz'.format(TIMESTAMP), - 'SAGEMAKER_PROGRAM': 'dummy_script.py', - 'SAGEMAKER_ENABLE_CLOUDWATCH_METRICS': 'false', - 'SAGEMAKER_REGION': 'us-west-2', - 'SAGEMAKER_CONTAINER_LOG_LEVEL': '20'}, - 'Image': expected_image_base.format(mxnet_version), - 'ModelDataUrl': 's3://m/m.tar.gz'} == model.prepare_container_def(GPU) + environment = { + 'Environment': { + 'SAGEMAKER_SUBMIT_DIRECTORY': 's3://mybucket/sagemaker-mxnet-{}/sourcedir.tar.gz'.format(TIMESTAMP), + 'SAGEMAKER_PROGRAM': 'dummy_script.py', 'SAGEMAKER_ENABLE_CLOUDWATCH_METRICS': 'false', + 'SAGEMAKER_REGION': 'us-west-2', 'SAGEMAKER_CONTAINER_LOG_LEVEL': '20' + }, + 'Image': expected_image_base.format(mxnet_version), 'ModelDataUrl': 's3://m/m.tar.gz' + } + assert environment == model.prepare_container_def(GPU) assert 'cpu' in model.prepare_container_def(CPU)['Image'] predictor = mx.deploy(1, GPU) @@ -171,29 +177,36 @@ def test_train_image_default(sagemaker_session): def test_attach(sagemaker_session, mxnet_version): training_image = '1.dkr.ecr.us-west-2.amazonaws.com/sagemaker-mxnet-py2-cpu:{}-cpu-py2'.format(mxnet_version) - returned_job_description = {'AlgorithmSpecification': - {'TrainingInputMode': 'File', - 'TrainingImage': training_image}, - 'HyperParameters': - {'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', - 'sagemaker_program': '"iris-dnn-classifier.py"', - 'sagemaker_s3_uri_training': '"sagemaker-3/integ-test-data/tf_iris"', - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': '"logging.INFO"', - 'sagemaker_job_name': '"neo"', - 'training_steps': '100', - 'sagemaker_region': '"us-west-2"'}, - 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', - 'ResourceConfig': - {'VolumeSizeInGB': 30, - 'InstanceCount': 1, - 'InstanceType': 'ml.c4.xlarge'}, - 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, - 'TrainingJobName': 'neo', - 'TrainingJobStatus': 'Completed', - 'OutputDataConfig': {'KmsKeyId': '', - 'S3OutputPath': 's3://place/output/neo'}, - 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} + returned_job_description = { + 'AlgorithmSpecification': { + 'TrainingInputMode': 'File', + 'TrainingImage': training_image + }, + 'HyperParameters': { + 'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', + 'sagemaker_program': '"iris-dnn-classifier.py"', + 'sagemaker_s3_uri_training': '"sagemaker-3/integ-test-data/tf_iris"', + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': '"logging.INFO"', + 'sagemaker_job_name': '"neo"', + 'training_steps': '100', + 'sagemaker_region': '"us-west-2"' + }, + 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', + 'ResourceConfig': { + 'VolumeSizeInGB': 30, + 'InstanceCount': 1, + 'InstanceType': 'ml.c4.xlarge' + }, + 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, + 'TrainingJobName': 'neo', + 'TrainingJobStatus': 'Completed', + 'OutputDataConfig': { + 'KmsKeyId': '', + 'S3OutputPath': 's3://place/output/neo' + }, + 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'} + } sagemaker_session.sagemaker_client.describe_training_job = Mock(name='describe_training_job', return_value=returned_job_description) @@ -214,29 +227,28 @@ def test_attach(sagemaker_session, mxnet_version): def test_attach_old_container(sagemaker_session): - returned_job_description = {'AlgorithmSpecification': - {'TrainingInputMode': 'File', - 'TrainingImage': '1.dkr.ecr.us-west-2.amazonaws.com/sagemaker-mxnet-py2-cpu:1.0'}, - 'HyperParameters': - {'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', - 'sagemaker_program': '"iris-dnn-classifier.py"', - 'sagemaker_s3_uri_training': '"sagemaker-3/integ-test-data/tf_iris"', - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': '"logging.INFO"', - 'sagemaker_job_name': '"neo"', - 'training_steps': '100', - 'sagemaker_region': '"us-west-2"'}, - 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', - 'ResourceConfig': - {'VolumeSizeInGB': 30, - 'InstanceCount': 1, - 'InstanceType': 'ml.c4.xlarge'}, - 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, - 'TrainingJobName': 'neo', - 'TrainingJobStatus': 'Completed', - 'OutputDataConfig': {'KmsKeyId': '', - 'S3OutputPath': 's3://place/output/neo'}, - 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} + returned_job_description = {'AlgorithmSpecification': { + 'TrainingInputMode': 'File', + 'TrainingImage': '1.dkr.ecr.us-west-2.amazonaws.com/sagemaker-mxnet-py2-cpu:1.0'}, + 'HyperParameters': { + 'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', + 'sagemaker_program': '"iris-dnn-classifier.py"', + 'sagemaker_s3_uri_training': '"sagemaker-3/integ-test-data/tf_iris"', + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': '"logging.INFO"', + 'sagemaker_job_name': '"neo"', + 'training_steps': '100', + 'sagemaker_region': '"us-west-2"'}, + 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', + 'ResourceConfig': { + 'VolumeSizeInGB': 30, + 'InstanceCount': 1, + 'InstanceType': 'ml.c4.xlarge'}, + 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, + 'TrainingJobName': 'neo', + 'TrainingJobStatus': 'Completed', + 'OutputDataConfig': {'KmsKeyId': '', 'S3OutputPath': 's3://place/output/neo'}, + 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} sagemaker_session.sagemaker_client.describe_training_job = Mock(name='describe_training_job', return_value=returned_job_description) @@ -257,28 +269,28 @@ def test_attach_old_container(sagemaker_session): def test_attach_wrong_framework(sagemaker_session): - rjd = {'AlgorithmSpecification': - {'TrainingInputMode': 'File', + rjd = { + 'AlgorithmSpecification': { + 'TrainingInputMode': 'File', 'TrainingImage': '1.dkr.ecr.us-west-2.amazonaws.com/sagemaker-tensorflow-py2-cpu:1.0.4'}, - 'HyperParameters': - {'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', - 'checkpoint_path': '"s3://other/1508872349"', - 'sagemaker_program': '"iris-dnn-classifier.py"', - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': '"logging.INFO"', - 'training_steps': '100', - 'sagemaker_region': '"us-west-2"'}, - 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', - 'ResourceConfig': - {'VolumeSizeInGB': 30, - 'InstanceCount': 1, - 'InstanceType': 'ml.c4.xlarge'}, - 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, - 'TrainingJobName': 'neo', - 'TrainingJobStatus': 'Completed', - 'OutputDataConfig': {'KmsKeyId': '', - 'S3OutputPath': 's3://place/output/neo'}, - 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} + 'HyperParameters': { + 'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', + 'checkpoint_path': '"s3://other/1508872349"', + 'sagemaker_program': '"iris-dnn-classifier.py"', + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': '"logging.INFO"', + 'training_steps': '100', + 'sagemaker_region': '"us-west-2"'}, + 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', + 'ResourceConfig': { + 'VolumeSizeInGB': 30, + 'InstanceCount': 1, + 'InstanceType': 'ml.c4.xlarge'}, + 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, + 'TrainingJobName': 'neo', + 'TrainingJobStatus': 'Completed', + 'OutputDataConfig': {'KmsKeyId': '', 'S3OutputPath': 's3://place/output/neo'}, + 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} sagemaker_session.sagemaker_client.describe_training_job = Mock(name='describe_training_job', return_value=rjd) with pytest.raises(ValueError) as error: diff --git a/tests/unit/test_ntm.py b/tests/unit/test_ntm.py index e9a533aec5..ceff3e51e3 100644 --- a/tests/unit/test_ntm.py +++ b/tests/unit/test_ntm.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock, patch diff --git a/tests/unit/test_pca.py b/tests/unit/test_pca.py index 479a34d93e..b70a7b556a 100644 --- a/tests/unit/test_pca.py +++ b/tests/unit/test_pca.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock, patch diff --git a/tests/unit/test_predictor.py b/tests/unit/test_predictor.py index 5d863467ca..9a14d88aa1 100644 --- a/tests/unit/test_predictor.py +++ b/tests/unit/test_predictor.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import io import json import os diff --git a/tests/unit/test_randomcutforest.py b/tests/unit/test_randomcutforest.py index 97a460494c..98306abf73 100644 --- a/tests/unit/test_randomcutforest.py +++ b/tests/unit/test_randomcutforest.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest from mock import Mock, patch diff --git a/tests/unit/test_session.py b/tests/unit/test_session.py index 0256b54569..1e61aaf393 100644 --- a/tests/unit/test_session.py +++ b/tests/unit/test_session.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import pytest import io import six diff --git a/tests/unit/test_sync_directories.py b/tests/unit/test_sync_directories.py index 42434aaf49..ef7caeac7b 100644 --- a/tests/unit/test_sync_directories.py +++ b/tests/unit/test_sync_directories.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + import filecmp import os import random diff --git a/tests/unit/test_tf_estimator.py b/tests/unit/test_tf_estimator.py index 3a9b19e1c1..dc4192b06e 100644 --- a/tests/unit/test_tf_estimator.py +++ b/tests/unit/test_tf_estimator.py @@ -10,17 +10,19 @@ # 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. +from __future__ import absolute_import + import json import logging import os import pytest -from mock import Mock, patch +from mock import patch, Mock from sagemaker.fw_utils import create_image_uri from sagemaker.model import MODEL_SERVER_WORKERS_PARAM_NAME from sagemaker.session import s3_input -from sagemaker.tensorflow import defaults, TensorFlow, TensorFlowPredictor, TensorFlowModel +from sagemaker.tensorflow import defaults, TensorFlow, TensorFlowModel, TensorFlowPredictor DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data') SCRIPT_FILE = 'dummy_script.py' @@ -42,14 +44,13 @@ @pytest.fixture() def sagemaker_session(): boto_mock = Mock(name='boto_session', region_name=REGION) - sms = Mock(name='sagemaker_session', boto_session=boto_mock, - boto_region_name=REGION, config=None, local_mode=False) - sms.default_bucket = Mock(name='default_bucket', return_value=BUCKET_NAME) - sms.expand_role = Mock(name="expand_role", return_value=ROLE) - sms.sagemaker_client.describe_training_job = Mock(return_value={'ModelArtifacts': - {'S3ModelArtifacts': 's3://m/m.tar.gz'} - }) - return sms + session = Mock(name='sagemaker_session', boto_session=boto_mock, + boto_region_name=REGION, config=None, local_mode=False) + session.default_bucket = Mock(name='default_bucket', return_value=BUCKET_NAME) + session.expand_role = Mock(name="expand_role", return_value=ROLE) + describe = {'ModelArtifacts': {'S3ModelArtifacts': 's3://m/m.tar.gz'}} + session.sagemaker_client.describe_training_job = Mock(return_value=describe) + return session def _get_full_cpu_image_uri(version): @@ -61,9 +62,11 @@ def _get_full_gpu_image_uri(version): def _create_train_job(tf_version): - return {'image': _get_full_cpu_image_uri(tf_version), - 'input_mode': 'File', - 'input_config': [{ + return { + 'image': _get_full_cpu_image_uri(tf_version), + 'input_mode': 'File', + 'input_config': [ + { 'ChannelName': 'training', 'DataSource': { 'S3DataSource': { @@ -71,33 +74,35 @@ def _create_train_job(tf_version): 'S3DataType': 'S3Prefix' } } - }], - 'role': ROLE, - 'job_name': JOB_NAME, - 'output_config': { - 'S3OutputPath': 's3://{}/'.format(BUCKET_NAME), - }, - 'resource_config': { - 'InstanceType': 'ml.c4.4xlarge', - 'InstanceCount': 1, - 'VolumeSizeInGB': 30, - }, - 'hyperparameters': { - 'training_steps': '1000', - 'evaluation_steps': '10', - 'sagemaker_program': json.dumps('dummy_script.py'), - 'sagemaker_requirements': '"{}"'.format(REQUIREMENTS_FILE), - 'sagemaker_submit_directory': json.dumps('s3://{}/{}/source/sourcedir.tar.gz'.format( - BUCKET_NAME, JOB_NAME)), - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': str(logging.INFO), - 'sagemaker_job_name': json.dumps(JOB_NAME), - 'checkpoint_path': json.dumps('s3://{}/{}/checkpoints'.format(BUCKET_NAME, JOB_NAME)), - 'sagemaker_region': '"us-west-2"' - }, - 'stop_condition': { - 'MaxRuntimeInSeconds': 24 * 60 * 60 - }} + } + ], + 'role': ROLE, + 'job_name': JOB_NAME, + 'output_config': { + 'S3OutputPath': 's3://{}/'.format(BUCKET_NAME), + }, + 'resource_config': { + 'InstanceType': 'ml.c4.4xlarge', + 'InstanceCount': 1, + 'VolumeSizeInGB': 30, + }, + 'hyperparameters': { + 'training_steps': '1000', + 'evaluation_steps': '10', + 'sagemaker_program': json.dumps('dummy_script.py'), + 'sagemaker_requirements': '"{}"'.format(REQUIREMENTS_FILE), + 'sagemaker_submit_directory': json.dumps('s3://{}/{}/source/sourcedir.tar.gz'.format( + BUCKET_NAME, JOB_NAME)), + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': str(logging.INFO), + 'sagemaker_job_name': json.dumps(JOB_NAME), + 'checkpoint_path': json.dumps('s3://{}/{}/checkpoints'.format(BUCKET_NAME, JOB_NAME)), + 'sagemaker_region': '"us-west-2"' + }, + 'stop_condition': { + 'MaxRuntimeInSeconds': 24 * 60 * 60 + } + } def _build_tf(sagemaker_session, framework_version=defaults.TF_VERSION, train_instance_type=None, @@ -223,16 +228,17 @@ def test_tf(time, strftime, sagemaker_session, tf_version): model = tf.create_model() - assert {'Environment': - {'SAGEMAKER_SUBMIT_DIRECTORY': 's3://{}/{}/sourcedir.tar.gz'.format(BUCKET_NAME, JOB_NAME), - 'SAGEMAKER_PROGRAM': 'dummy_script.py', - 'SAGEMAKER_REQUIREMENTS': 'dummy_requirements.txt', - 'SAGEMAKER_ENABLE_CLOUDWATCH_METRICS': 'false', - 'SAGEMAKER_REGION': 'us-west-2', - 'SAGEMAKER_CONTAINER_LOG_LEVEL': '20' - }, - 'Image': create_image_uri('us-west-2', "tensorflow", INSTANCE_TYPE, tf_version, "py2"), - 'ModelDataUrl': 's3://m/m.tar.gz'} == model.prepare_container_def(INSTANCE_TYPE) + environment = { + 'Environment': { + 'SAGEMAKER_SUBMIT_DIRECTORY': 's3://{}/{}/sourcedir.tar.gz'.format(BUCKET_NAME, JOB_NAME), + 'SAGEMAKER_PROGRAM': 'dummy_script.py', 'SAGEMAKER_REQUIREMENTS': 'dummy_requirements.txt', + 'SAGEMAKER_ENABLE_CLOUDWATCH_METRICS': 'false', 'SAGEMAKER_REGION': 'us-west-2', + 'SAGEMAKER_CONTAINER_LOG_LEVEL': '20' + }, + 'Image': create_image_uri('us-west-2', "tensorflow", INSTANCE_TYPE, tf_version, "py2"), + 'ModelDataUrl': 's3://m/m.tar.gz' + } + assert environment == model.prepare_container_def(INSTANCE_TYPE) assert 'cpu' in model.prepare_container_def(INSTANCE_TYPE)['Image'] predictor = tf.deploy(1, INSTANCE_TYPE) @@ -365,29 +371,32 @@ def test_train_image_default(sagemaker_session): def test_attach(sagemaker_session, tf_version): training_image = '1.dkr.ecr.us-west-2.amazonaws.com/sagemaker-tensorflow-py2-cpu:{}-cpu-py2'.format(tf_version) - rjd = {'AlgorithmSpecification': - {'TrainingInputMode': 'File', - 'TrainingImage': training_image}, - 'HyperParameters': - {'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', - 'checkpoint_path': '"s3://other/1508872349"', - 'sagemaker_program': '"iris-dnn-classifier.py"', - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': '"logging.INFO"', - 'sagemaker_job_name': '"neo"', - 'training_steps': '100', - 'evaluation_steps': '10'}, - 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', - 'ResourceConfig': - {'VolumeSizeInGB': 30, - 'InstanceCount': 1, - 'InstanceType': 'ml.c4.xlarge'}, - 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, - 'TrainingJobName': 'neo', - 'TrainingJobStatus': 'Completed', - 'OutputDataConfig': {'KmsKeyId': '', - 'S3OutputPath': 's3://place/output/neo'}, - 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} + rjd = { + 'AlgorithmSpecification': { + 'TrainingInputMode': 'File', + 'TrainingImage': training_image + }, + 'HyperParameters': { + 'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', + 'checkpoint_path': '"s3://other/1508872349"', + 'sagemaker_program': '"iris-dnn-classifier.py"', + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': '"logging.INFO"', + 'sagemaker_job_name': '"neo"', + 'training_steps': '100', + 'evaluation_steps': '10' + }, + 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', + 'ResourceConfig': { + 'VolumeSizeInGB': 30, + 'InstanceCount': 1, + 'InstanceType': 'ml.c4.xlarge' + }, + 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, + 'TrainingJobName': 'neo', + 'TrainingJobStatus': 'Completed', + 'OutputDataConfig': {'KmsKeyId': '', 'S3OutputPath': 's3://place/output/neo'}, + 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} sagemaker_session.sagemaker_client.describe_training_job = Mock(name='describe_training_job', return_value=rjd) estimator = TensorFlow.attach(training_job_name='neo', sagemaker_session=sagemaker_session) @@ -412,29 +421,29 @@ def test_attach(sagemaker_session, tf_version): def test_attach_new_repo_name(sagemaker_session, tf_version): training_image = '520713654638.dkr.ecr.us-west-2.amazonaws.com/sagemaker-tensorflow:{}-cpu-py2'.format(tf_version) - rjd = {'AlgorithmSpecification': - {'TrainingInputMode': 'File', - 'TrainingImage': training_image}, - 'HyperParameters': - {'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', - 'checkpoint_path': '"s3://other/1508872349"', - 'sagemaker_program': '"iris-dnn-classifier.py"', - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': '"logging.INFO"', - 'sagemaker_job_name': '"neo"', - 'training_steps': '100', - 'evaluation_steps': '10'}, - 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', - 'ResourceConfig': - {'VolumeSizeInGB': 30, - 'InstanceCount': 1, - 'InstanceType': 'ml.c4.xlarge'}, - 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, - 'TrainingJobName': 'neo', - 'TrainingJobStatus': 'Completed', - 'OutputDataConfig': {'KmsKeyId': '', - 'S3OutputPath': 's3://place/output/neo'}, - 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} + rjd = { + 'AlgorithmSpecification': {'TrainingInputMode': 'File', 'TrainingImage': training_image}, + 'HyperParameters': { + 'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', + 'checkpoint_path': '"s3://other/1508872349"', + 'sagemaker_program': '"iris-dnn-classifier.py"', + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': '"logging.INFO"', + 'sagemaker_job_name': '"neo"', + 'training_steps': '100', + 'evaluation_steps': '10' + }, + 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', + 'ResourceConfig': { + 'VolumeSizeInGB': 30, + 'InstanceCount': 1, + 'InstanceType': 'ml.c4.xlarge' + }, + 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, + 'TrainingJobName': 'neo', + 'TrainingJobStatus': 'Completed', + 'OutputDataConfig': {'KmsKeyId': '', 'S3OutputPath': 's3://place/output/neo'}, + 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} sagemaker_session.sagemaker_client.describe_training_job = Mock(name='describe_training_job', return_value=rjd) estimator = TensorFlow.attach(training_job_name='neo', sagemaker_session=sagemaker_session) @@ -460,29 +469,29 @@ def test_attach_new_repo_name(sagemaker_session, tf_version): def test_attach_old_container(sagemaker_session): training_image = '1.dkr.ecr.us-west-2.amazonaws.com/sagemaker-tensorflow-py2-cpu:1.0' - rjd = {'AlgorithmSpecification': - {'TrainingInputMode': 'File', + rjd = { + 'AlgorithmSpecification': { + 'TrainingInputMode': 'File', 'TrainingImage': training_image}, - 'HyperParameters': - {'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', - 'checkpoint_path': '"s3://other/1508872349"', - 'sagemaker_program': '"iris-dnn-classifier.py"', - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': '"logging.INFO"', - 'sagemaker_job_name': '"neo"', - 'training_steps': '100', - 'evaluation_steps': '10'}, - 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', - 'ResourceConfig': - {'VolumeSizeInGB': 30, - 'InstanceCount': 1, - 'InstanceType': 'ml.c4.xlarge'}, - 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, - 'TrainingJobName': 'neo', - 'TrainingJobStatus': 'Completed', - 'OutputDataConfig': {'KmsKeyId': '', - 'S3OutputPath': 's3://place/output/neo'}, - 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} + 'HyperParameters': { + 'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', + 'checkpoint_path': '"s3://other/1508872349"', + 'sagemaker_program': '"iris-dnn-classifier.py"', + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': '"logging.INFO"', + 'sagemaker_job_name': '"neo"', + 'training_steps': '100', + 'evaluation_steps': '10'}, + 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', + 'ResourceConfig': { + 'VolumeSizeInGB': 30, + 'InstanceCount': 1, + 'InstanceType': 'ml.c4.xlarge'}, + 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, + 'TrainingJobName': 'neo', + 'TrainingJobStatus': 'Completed', + 'OutputDataConfig': {'KmsKeyId': '', 'S3OutputPath': 's3://place/output/neo'}, + 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} sagemaker_session.sagemaker_client.describe_training_job = Mock(name='describe_training_job', return_value=rjd) estimator = TensorFlow.attach(training_job_name='neo', sagemaker_session=sagemaker_session) @@ -506,26 +515,38 @@ def test_attach_old_container(sagemaker_session): def test_attach_wrong_framework(sagemaker_session): - returned_job_description = {'AlgorithmSpecification': - {'TrainingInputMode': 'File', - 'TrainingImage': '1.dkr.ecr.us-west-2.amazonaws.com/sagemaker-mxnet-py2-cpu:1.0'}, - 'HyperParameters': - {'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', - 'sagemaker_program': '"iris-dnn-classifier.py"', - 'sagemaker_enable_cloudwatch_metrics': 'false', - 'sagemaker_container_log_level': '"logging.INFO"', - 'training_steps': '100'}, - 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', - 'ResourceConfig': - {'VolumeSizeInGB': 30, - 'InstanceCount': 1, - 'InstanceType': 'ml.c4.xlarge'}, - 'StoppingCondition': {'MaxRuntimeInSeconds': 24 * 60 * 60}, - 'TrainingJobName': 'neo', - 'TrainingJobStatus': 'Completed', - 'OutputDataConfig': {'KmsKeyId': '', - 'S3OutputPath': 's3://place/output/neo'}, - 'TrainingJobOutput': {'S3TrainingJobOutput': 's3://here/output.tar.gz'}} + returned_job_description = { + 'AlgorithmSpecification': { + 'TrainingInputMode': 'File', + 'TrainingImage': '1.dkr.ecr.us-west-2.amazonaws.com/sagemaker-mxnet-py2-cpu:1.0' + }, + 'HyperParameters': { + 'sagemaker_submit_directory': '"s3://some/sourcedir.tar.gz"', + 'sagemaker_program': '"iris-dnn-classifier.py"', + 'sagemaker_enable_cloudwatch_metrics': 'false', + 'sagemaker_container_log_level': '"logging.INFO"', + 'training_steps': '100' + + }, + 'RoleArn': 'arn:aws:iam::366:role/SageMakerRole', + 'ResourceConfig': + {'VolumeSizeInGB': 30, + 'InstanceCount': 1, + 'InstanceType': 'ml.c4.xlarge' + }, + 'StoppingCondition': { + 'MaxRuntimeInSeconds': 24 * 60 * 60 + }, + 'TrainingJobName': 'neo', + 'TrainingJobStatus': 'Completed', + 'OutputDataConfig': { + 'KmsKeyId': '', + 'S3OutputPath': 's3://place/output/neo' + }, + 'TrainingJobOutput': { + 'S3TrainingJobOutput': 's3://here/output.tar.gz' + } + } sagemaker_session.sagemaker_client.describe_training_job = Mock(name='describe_training_job', return_value=returned_job_description) diff --git a/tests/unit/test_tf_predictor.py b/tests/unit/test_tf_predictor.py index a1edbce6f4..4a2c0ac7db 100644 --- a/tests/unit/test_tf_predictor.py +++ b/tests/unit/test_tf_predictor.py @@ -1,4 +1,4 @@ -# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright 2017-2018 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 @@ -10,20 +10,22 @@ # 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. -import sys +from __future__ import absolute_import import io import json +import sys + import numpy as np import pytest -import tensorflow as tf from google.protobuf import json_format +import tensorflow as tf from mock import Mock from tensorflow.python.saved_model.signature_constants import DEFAULT_SERVING_SIGNATURE_DEF_KEY, PREDICT_INPUTS from sagemaker.predictor import RealTimePredictor -from sagemaker.tensorflow.predictor import tf_serializer, tf_deserializer, tf_csv_serializer, tf_json_serializer, \ - tf_json_deserializer +from sagemaker.tensorflow.predictor import tf_csv_serializer, tf_deserializer, tf_json_deserializer, \ + tf_json_serializer, tf_serializer from sagemaker.tensorflow.tensorflow_serving.apis import classification_pb2 BUCKET_NAME = 'mybucket' diff --git a/tests/unit/test_upload_data.py b/tests/unit/test_upload_data.py index 43442c0c7f..bb7ccad858 100644 --- a/tests/unit/test_upload_data.py +++ b/tests/unit/test_upload_data.py @@ -1,18 +1,21 @@ -# Copyright 2017 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. +# Copyright 2017-2018 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. +from __future__ import absolute_import + import os -import pytest + from mock import Mock +import pytest import sagemaker from tests.unit import DATA_DIR @@ -34,8 +37,8 @@ def sagemaker_session(): def test_upload_data_absolute_dir(sagemaker_session): result_s3_uri = sagemaker_session.upload_data(UPLOAD_DATA_TESTS_FILES_DIR) - uploaded_files = [args[0] for name, args, kwargs in sagemaker_session.boto_session.mock_calls - if name == 'resource().Object().upload_file'] + uploaded_files = [args[0] for name, args, kwargs in sagemaker_session.boto_session.mock_calls + if name == 'resource().Object().upload_file'] assert result_s3_uri == 's3://{}/data'.format(BUCKET_NAME) assert len(uploaded_files) == 4 for file in uploaded_files: @@ -45,8 +48,8 @@ def test_upload_data_absolute_dir(sagemaker_session): def test_upload_data_absolute_file(sagemaker_session): result_s3_uri = sagemaker_session.upload_data(UPLOAD_DATA_TESTS_SINGLE_FILE) - uploaded_files = [args[0] for name, args, kwargs in sagemaker_session.boto_session.mock_calls - if name == 'resource().Object().upload_file'] + uploaded_files = [args[0] for name, args, kwargs in sagemaker_session.boto_session.mock_calls + if name == 'resource().Object().upload_file'] assert result_s3_uri == 's3://{}/data/{}'.format(BUCKET_NAME, SINGLE_FILE_NAME) assert len(uploaded_files) == 1 assert os.path.exists(uploaded_files[0]) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 0de9ceeb32..5004529a08 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -10,6 +10,8 @@ # 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. +from __future__ import absolute_import + from sagemaker.utils import get_config_value @@ -26,10 +28,7 @@ def test_get_config_value(): } assert get_config_value('local.region_name', config) == 'us-west-2' - assert get_config_value('local', config) == { - 'region_name': 'us-west-2', - 'port': '123' - } + assert get_config_value('local', config) == {'region_name': 'us-west-2', 'port': '123'} assert get_config_value('does_not.exist', config) is None assert get_config_value('other.key', None) is None diff --git a/tox.ini b/tox.ini index 3fff547a30..557dd297c7 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,24 @@ exclude = tests/data/ venv/ max-complexity = 10 +ignore = + FI10, + FI12, + FI13, + FI14, + FI15, + FI16, + FI17, + FI50, + FI51, + FI52, + FI53, + FI54, + FI55, + FI56, + FI57 + +require-code = True [testenv] # TEAMCITY_VERSION environment variable exists during build on Teamcity. teamcity-messages uses it in order to enable @@ -49,5 +67,7 @@ deps = [testenv:flake8] basepython = python -deps = flake8 -commands= flake8 +deps = + flake8 + flake8-future-import +commands = flake8