Skip to content

Commit a83bed5

Browse files
authored
breaking: deprecate constants from defaults (#1590)
1 parent 66178b4 commit a83bed5

22 files changed

+98
-144
lines changed

src/sagemaker/chainer/defaults.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,4 @@
1313
"""Placeholder docstring"""
1414
from __future__ import absolute_import
1515

16-
CHAINER_VERSION = "4.1.0"
17-
"""Default Chainer version for when the framework version is not specified.
18-
This is no longer updated so as to not break existing workflows.
19-
"""
20-
21-
LATEST_VERSION = "5.0.0"
22-
"""The latest version of Chainer included in the SageMaker pre-built Docker images."""
23-
2416
LATEST_PY2_VERSION = "5.0.0"

src/sagemaker/chainer/estimator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class Chainer(Framework):
4040
_process_slots_per_host = "sagemaker_process_slots_per_host"
4141
_additional_mpi_options = "sagemaker_additional_mpi_options"
4242

43-
LATEST_VERSION = defaults.LATEST_VERSION
44-
4543
def __init__(
4644
self,
4745
entry_point,

src/sagemaker/cli/mxnet.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from __future__ import absolute_import
1515

1616
from sagemaker.cli.common import HostCommand, TrainCommand
17-
from sagemaker.mxnet import defaults
17+
18+
MXNET_VERSION = "1.2"
1819

1920

2021
def train(args):
@@ -42,7 +43,7 @@ def create_estimator(self):
4243

4344
return MXNet(
4445
entry_point=self.script,
45-
framework_version=defaults.MXNET_VERSION,
46+
framework_version=MXNET_VERSION,
4647
py_version=self.python,
4748
role=self.role_name,
4849
base_job_name=self.job_name,
@@ -66,7 +67,7 @@ def create_model(self, model_url):
6667
model_data=model_url,
6768
role=self.role_name,
6869
entry_point=self.script,
69-
framework_version=defaults.MXNET_VERSION,
70+
framework_version=MXNET_VERSION,
7071
py_version=self.python,
7172
name=self.endpoint_name,
7273
env=self.environment,

src/sagemaker/mxnet/defaults.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,4 @@
1313
"""Placeholder docstring"""
1414
from __future__ import absolute_import
1515

16-
MXNET_VERSION = "1.2"
17-
"""Default MXNet version for when the framework version is not specified.
18-
This is no longer updated so as to not break existing workflows.
19-
"""
20-
21-
LATEST_VERSION = "1.6.0"
22-
"""The latest version of MXNet included in the SageMaker pre-built Docker images."""
23-
2416
LATEST_PY2_VERSION = "1.6.0"

src/sagemaker/mxnet/estimator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class MXNet(Framework):
3838
__framework_name__ = "mxnet"
3939
_LOWEST_SCRIPT_MODE_VERSION = ["1", "3"]
4040

41-
LATEST_VERSION = defaults.LATEST_VERSION
42-
4341
def __init__(
4442
self,
4543
entry_point,
@@ -115,7 +113,7 @@ def __init__(
115113
:class:`~sagemaker.estimator.EstimatorBase`.
116114
"""
117115
validate_version_or_image_args(framework_version, py_version, image_name)
118-
if py_version and py_version == "py2":
116+
if py_version == "py2":
119117
logger.warning(
120118
python_deprecation_warning(self.__framework_name__, defaults.LATEST_PY2_VERSION)
121119
)

src/sagemaker/mxnet/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __init__(
115115
:class:`~sagemaker.model.Model`.
116116
"""
117117
validate_version_or_image_args(framework_version, py_version, image)
118-
if py_version and py_version == "py2":
118+
if py_version == "py2":
119119
logger.warning(
120120
python_deprecation_warning(self.__framework_name__, defaults.LATEST_PY2_VERSION)
121121
)

src/sagemaker/pytorch/defaults.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,4 @@
1313
"""Placeholder docstring"""
1414
from __future__ import absolute_import
1515

16-
PYTORCH_VERSION = "0.4"
17-
"""Default PyTorch version for when the framework version is not specified.
18-
The default version is no longer updated so as to not break existing workflows.
19-
"""
20-
21-
LATEST_VERSION = "1.5.0"
22-
"""The latest version of PyTorch included in the SageMaker pre-built Docker images."""
23-
24-
PYTHON_VERSION = "py3"
25-
2616
LATEST_PY2_VERSION = "1.3.1"

src/sagemaker/pytorch/estimator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class PyTorch(Framework):
3535

3636
__framework_name__ = "pytorch"
3737

38-
LATEST_VERSION = defaults.LATEST_VERSION
39-
4038
def __init__(
4139
self,
4240
entry_point,

src/sagemaker/pytorch/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(
114114
:class:`~sagemaker.model.Model`.
115115
"""
116116
validate_version_or_image_args(framework_version, py_version, image)
117-
if py_version and py_version == "py2":
117+
if py_version == "py2":
118118
logger.warning(
119119
python_deprecation_warning(self.__framework_name__, defaults.LATEST_PY2_VERSION)
120120
)

src/sagemaker/sklearn/defaults.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,3 @@
1414
from __future__ import absolute_import
1515

1616
SKLEARN_NAME = "scikit-learn"
17-
18-
SKLEARN_VERSION = "0.20.0"
19-
20-
LATEST_PY2_VERSION = "0.20.0"

src/sagemaker/tensorflow/defaults.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,4 @@
1313
"""Placeholder docstring"""
1414
from __future__ import absolute_import
1515

16-
TF_VERSION = "1.11"
17-
"""Default TF version for when the framework version is not specified.
18-
This is no longer updated so as to not break existing workflows.
19-
"""
20-
21-
LATEST_VERSION = "2.2.0"
22-
"""The latest version of TensorFlow included in the SageMaker pre-built Docker images."""
23-
24-
LATEST_SERVING_VERSION = "2.1.0"
25-
"""The latest version of TensorFlow Serving included in the SageMaker pre-built Docker images."""
26-
2716
LATEST_PY2_VERSION = "2.1.0"

src/sagemaker/tensorflow/estimator.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ class TensorFlow(Framework):
3636
__framework_name__ = "tensorflow"
3737
_ECR_REPO_NAME = "tensorflow-scriptmode"
3838

39-
LATEST_VERSION = defaults.LATEST_VERSION
40-
41-
_LATEST_1X_VERSION = "1.15.2"
42-
4339
_HIGHEST_LEGACY_MODE_ONLY_VERSION = version.Version("1.10.0")
4440
_HIGHEST_PYTHON_2_VERSION = version.Version("2.1.0")
4541

src/sagemaker/xgboost/defaults.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@
1515

1616
XGBOOST_NAME = "xgboost"
1717
XGBOOST_1P_VERSIONS = ["1", "latest"]
18-
XGBOOST_VERSION_0_90 = "0.90"
18+
1919
XGBOOST_VERSION_0_90_1 = "0.90-1"
2020
XGBOOST_VERSION_0_90_2 = "0.90-2"
21+
2122
XGBOOST_LATEST_VERSION = "1.0-1"
23+
2224
# XGBOOST_SUPPORTED_VERSIONS has XGBoost Framework versions sorted from oldest to latest
2325
XGBOOST_SUPPORTED_VERSIONS = [
2426
XGBOOST_VERSION_0_90_1,
2527
XGBOOST_VERSION_0_90_2,
2628
XGBOOST_LATEST_VERSION,
2729
]
30+
31+
# TODO: evaluate use of this constant. it's used in precisely one place in different a module
32+
# may possibly be unnecessary indirection
2833
XGBOOST_VERSION_EQUIVALENTS = ["-cpu-py3"]

tests/conftest.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@
2121
from botocore.config import Config
2222

2323
from sagemaker import Session, utils
24-
from sagemaker.chainer import Chainer
2524
from sagemaker.local import LocalSession
26-
from sagemaker.mxnet import MXNet
27-
from sagemaker.pytorch import PyTorch
2825
from sagemaker.rl import RLEstimator
29-
from sagemaker.sklearn.defaults import SKLEARN_VERSION
30-
from sagemaker.tensorflow import TensorFlow
31-
from sagemaker.tensorflow.defaults import LATEST_VERSION, LATEST_SERVING_VERSION
3226

3327
DEFAULT_REGION = "us-west-2"
3428
CUSTOM_BUCKET_NAME_PREFIX = "sagemaker-custom-bucket"
@@ -49,10 +43,10 @@ def pytest_addoption(parser):
4943
parser.addoption("--sagemaker-client-config", action="store", default=None)
5044
parser.addoption("--sagemaker-runtime-config", action="store", default=None)
5145
parser.addoption("--boto-config", action="store", default=None)
52-
parser.addoption("--chainer-full-version", action="store", default=Chainer.LATEST_VERSION)
53-
parser.addoption("--mxnet-full-version", action="store", default=MXNet.LATEST_VERSION)
46+
parser.addoption("--chainer-full-version", action="store", default="5.0.0")
47+
parser.addoption("--mxnet-full-version", action="store", default="1.6.0")
5448
parser.addoption("--ei-mxnet-full-version", action="store", default="1.5.1")
55-
parser.addoption("--pytorch-full-version", action="store", default=PyTorch.LATEST_VERSION)
49+
parser.addoption("--pytorch-full-version", action="store", default="1.5.0")
5650
parser.addoption(
5751
"--rl-coach-mxnet-full-version",
5852
action="store",
@@ -64,10 +58,10 @@ def pytest_addoption(parser):
6458
parser.addoption(
6559
"--rl-ray-full-version", action="store", default=RLEstimator.RAY_LATEST_VERSION
6660
)
67-
parser.addoption("--sklearn-full-version", action="store", default=SKLEARN_VERSION)
68-
parser.addoption("--tf-full-version", action="store")
61+
parser.addoption("--sklearn-full-version", action="store", default="0.20.0")
62+
parser.addoption("--tf-full-version", action="store", default="2.2.0")
6963
parser.addoption("--ei-tf-full-version", action="store")
70-
parser.addoption("--xgboost-full-version", action="store", default=SKLEARN_VERSION)
64+
parser.addoption("--xgboost-full-version", action="store", default="1.0-1")
7165

7266

7367
def pytest_configure(config):
@@ -291,17 +285,13 @@ def sklearn_full_version(request):
291285
return request.config.getoption("--sklearn-full-version")
292286

293287

294-
@pytest.fixture(scope="module", params=[TensorFlow._LATEST_1X_VERSION, LATEST_VERSION])
288+
@pytest.fixture(scope="module")
295289
def tf_full_version(request):
296-
tf_version = request.config.getoption("--tf-full-version")
297-
if tf_version is None:
298-
return request.param
299-
else:
300-
return tf_version
290+
return request.config.getoption("--tf-full-version")
301291

302292

303293
@pytest.fixture(scope="module")
304-
def tf_full_py_version(tf_full_version, request):
294+
def tf_full_py_version(tf_full_version):
305295
"""fixture to match tf_full_version
306296
307297
Fixture exists as such, since tf_full_version may be overridden --tf-full-version.
@@ -312,9 +302,17 @@ def tf_full_py_version(tf_full_version, request):
312302
version = [int(val) for val in tf_full_version.split(".")]
313303
if version < [1, 11]:
314304
return "py2"
315-
if tf_full_version in [TensorFlow._LATEST_1X_VERSION, LATEST_VERSION]:
316-
return "py37"
317-
return "py3"
305+
if version < [2, 2]:
306+
return "py3"
307+
return "py37"
308+
309+
310+
@pytest.fixture(scope="module")
311+
def tf_serving_version(tf_full_version):
312+
full_version = [int(val) for val in tf_full_version.split(".")]
313+
if full_version < [2, 2]:
314+
return tf_full_version
315+
return "2.1.0"
318316

319317

320318
@pytest.fixture(scope="module", params=["1.15.0", "2.0.0"])
@@ -384,10 +382,3 @@ def pytest_generate_tests(metafunc):
384382
@pytest.fixture(scope="module")
385383
def xgboost_full_version(request):
386384
return request.config.getoption("--xgboost-full-version")
387-
388-
389-
@pytest.fixture(scope="module")
390-
def tf_serving_version(tf_full_version):
391-
if tf_full_version == LATEST_VERSION:
392-
return LATEST_SERVING_VERSION
393-
return tf_full_version

tests/integ/test_airflow_config.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
from sagemaker.pytorch.estimator import PyTorch
4141
from sagemaker.sklearn import SKLearn
4242
from sagemaker.tensorflow import TensorFlow
43-
from sagemaker.xgboost.defaults import XGBOOST_LATEST_VERSION
4443
from sagemaker.workflow import airflow as sm_airflow
4544
from sagemaker.utils import sagemaker_timestamp
4645

@@ -550,7 +549,9 @@ def test_sklearn_airflow_config_uploads_data_source_to_s3(
550549

551550

552551
@pytest.mark.canary_quick
553-
def test_tf_airflow_config_uploads_data_source_to_s3(sagemaker_session, cpu_instance_type):
552+
def test_tf_airflow_config_uploads_data_source_to_s3(
553+
sagemaker_session, cpu_instance_type, tf_full_version, tf_full_py_version
554+
):
554555
with timeout(seconds=AIRFLOW_CONFIG_TIMEOUT_IN_SECONDS):
555556
tf = TensorFlow(
556557
image_name=get_image_uri(
@@ -561,8 +562,8 @@ def test_tf_airflow_config_uploads_data_source_to_s3(sagemaker_session, cpu_inst
561562
train_instance_count=SINGLE_INSTANCE_COUNT,
562563
train_instance_type=cpu_instance_type,
563564
sagemaker_session=sagemaker_session,
564-
framework_version=TensorFlow.LATEST_VERSION,
565-
py_version="py37", # only version available with 2.2.0
565+
framework_version=tf_full_version,
566+
py_version=tf_full_py_version,
566567
metric_definitions=[
567568
{"Name": "train:global_steps", "Regex": r"global_step\/sec:\s(.*)"}
568569
],
@@ -583,11 +584,13 @@ def test_tf_airflow_config_uploads_data_source_to_s3(sagemaker_session, cpu_inst
583584

584585
@pytest.mark.canary_quick
585586
@pytest.mark.skipif(PYTHON_VERSION == "py2", reason="XGBoost container does not support Python 2.")
586-
def test_xgboost_airflow_config_uploads_data_source_to_s3(sagemaker_session, cpu_instance_type):
587+
def test_xgboost_airflow_config_uploads_data_source_to_s3(
588+
sagemaker_session, cpu_instance_type, xgboost_full_version
589+
):
587590
with timeout(seconds=AIRFLOW_CONFIG_TIMEOUT_IN_SECONDS):
588591
xgboost = XGBoost(
589592
entry_point=os.path.join(DATA_DIR, "dummy_script.py"),
590-
framework_version=XGBOOST_LATEST_VERSION,
593+
framework_version=xgboost_full_version,
591594
role=ROLE,
592595
sagemaker_session=sagemaker_session,
593596
train_instance_type=cpu_instance_type,

tests/integ/test_git.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_github(sagemaker_local_session):
8484

8585
@pytest.mark.local_mode
8686
@pytest.mark.skip("needs a secure authentication approach")
87-
def test_private_github(sagemaker_local_session):
87+
def test_private_github(sagemaker_local_session, mxnet_full_version):
8888
script_path = "mnist.py"
8989
data_path = os.path.join(DATA_DIR, "mxnet_mnist")
9090
git_config = {
@@ -102,7 +102,7 @@ def test_private_github(sagemaker_local_session):
102102
role="SageMakerRole",
103103
source_dir=source_dir,
104104
dependencies=dependencies,
105-
framework_version=MXNet.LATEST_VERSION,
105+
framework_version=mxnet_full_version,
106106
py_version=PYTHON_VERSION,
107107
train_instance_count=1,
108108
train_instance_type="local",
@@ -222,7 +222,7 @@ def test_github_with_ssh_passphrase_not_configured(sagemaker_local_session, skle
222222

223223
@pytest.mark.local_mode
224224
@pytest.mark.skip("needs a secure authentication approach")
225-
def test_codecommit(sagemaker_local_session):
225+
def test_codecommit(sagemaker_local_session, mxnet_full_version):
226226
script_path = "mnist.py"
227227
data_path = os.path.join(DATA_DIR, "mxnet_mnist")
228228
git_config = {
@@ -238,7 +238,7 @@ def test_codecommit(sagemaker_local_session):
238238
role="SageMakerRole",
239239
source_dir=source_dir,
240240
dependencies=dependencies,
241-
framework_version=MXNet.LATEST_VERSION,
241+
framework_version=mxnet_full_version,
242242
py_version=PYTHON_VERSION,
243243
train_instance_count=1,
244244
train_instance_type="local",

tests/integ/test_sklearn_train.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import pytest
1919
import numpy
2020

21-
from sagemaker.sklearn.defaults import SKLEARN_VERSION
2221
from sagemaker.sklearn import SKLearn
2322
from sagemaker.sklearn import SKLearnModel
2423
from sagemaker.utils import sagemaker_timestamp, unique_name_from_base
@@ -147,12 +146,15 @@ def test_deploy_model(
147146
reason="This test has always failed, but the failure was masked by a bug. "
148147
"This test should be fixed. Details in https://github.com/aws/sagemaker-python-sdk/pull/968"
149148
)
150-
def test_async_fit(sagemaker_session, cpu_instance_type):
149+
def test_async_fit(sagemaker_session, cpu_instance_type, sklearn_full_version):
151150
endpoint_name = "test-sklearn-attach-deploy-{}".format(sagemaker_timestamp())
152151

153152
with timeout(minutes=5):
154153
training_job_name = _run_mnist_training_job(
155-
sagemaker_session, cpu_instance_type, sklearn_full_version=SKLEARN_VERSION, wait=False
154+
sagemaker_session,
155+
cpu_instance_type,
156+
sklearn_full_version=sklearn_full_version,
157+
wait=False,
156158
)
157159

158160
print("Waiting to re-attach to the training job: %s" % training_job_name)

0 commit comments

Comments
 (0)