Skip to content

Commit dc444d7

Browse files
authored
change: include py38 tox env and some dependency upgrades (#1593)
1 parent ea5c34d commit dc444d7

13 files changed

+45
-44
lines changed

.pylintrc

+10-9
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,22 @@ confidence=
7676
# --disable=W"
7777
disable=
7878
C0330, # Black disagrees with and explicitly violates this: https://github.com/python/black/issues/48
79-
too-many-locals,
79+
abstract-method, # TODO: Fix abstract methods
8080
arguments-differ,
81-
too-many-lines,
81+
cyclic-import, # TODO: Resolve cyclic imports
8282
fixme,
83-
too-many-arguments,
8483
invalid-name,
85-
too-many-instance-attributes,
86-
len-as-condition, # TODO: Enable this check once pylint 2.4.0 is released and consumed due to the fix in https://github.com/PyCQA/pylint/issues/2684
8784
import-error, # Since we run Pylint before any of our builds in tox, this will always fail
88-
protected-access, # TODO: Fix access
89-
abstract-method, # TODO: Fix abstract methods
90-
useless-object-inheritance, # TODO: Enable this check and fix code once Python 2 is no longer supported.
91-
cyclic-import, # TODO: Resolve cyclic imports
85+
import-outside-toplevel,
9286
no-self-use, # TODO: Convert methods to functions where appropriate
87+
protected-access, # TODO: Fix access
88+
signature-differs, # TODO: fix kwargs
89+
too-many-arguments,
9390
too-many-branches, # TODO: Simplify or ignore as appropriate
91+
too-many-instance-attributes,
92+
too-many-lines,
93+
too-many-locals,
94+
useless-object-inheritance, # TODO: Enable this check and fix code once Python 2 is no longer supported.
9495

9596
[REPORTS]
9697
# Set the output format. Available formats are text, parseable, colorized, msvs

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ def read_version():
6060
extras["test"] = (
6161
[
6262
extras["all"],
63-
"tox==3.13.1",
63+
"tox==3.15.1",
6464
"flake8",
65-
"pytest==4.4.1",
65+
"pytest==4.6.10",
6666
"pytest-cov",
6767
"pytest-rerunfailures",
6868
"pytest-xdist",
6969
"mock",
7070
"contextlib2",
7171
"awslogs",
72-
"black==19.3b0 ; python_version >= '3.6'",
72+
"black==19.10b0 ; python_version >= '3.6'",
7373
"stopit==1.1.2",
7474
"apache-airflow==1.10.5",
7575
"fabric>=2.0",

src/sagemaker/amazon/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ def read_recordio(f):
261261
"""
262262
while True:
263263
try:
264-
read_kmagic, = struct.unpack("I", f.read(4))
264+
(read_kmagic,) = struct.unpack("I", f.read(4))
265265
except struct.error:
266266
return
267267
assert read_kmagic == _kmagic
268-
len_record, = struct.unpack("I", f.read(4))
268+
(len_record,) = struct.unpack("I", f.read(4))
269269
pad = (((len_record + 3) >> 2) << 2) - len_record
270270
yield f.read(len_record)
271271
if pad:

src/sagemaker/cli/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, args):
4141
self.script = args.script
4242
self.instance_type = args.instance_type
4343
self.instance_count = args.instance_count
44-
self.environment = {k: v for k, v in (kv.split("=") for kv in args.env)}
44+
self.environment = dict((kv.split("=") for kv in args.env))
4545

4646
self.session = sagemaker.Session()
4747

src/sagemaker/rl/estimator.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,10 @@ def _validate_framework_format(cls, framework):
362362
Args:
363363
framework:
364364
"""
365-
if framework and framework not in RLFramework:
365+
if framework and framework not in list(RLFramework):
366366
raise ValueError(
367-
"Invalid type: {}, valid RL frameworks types are: [{}]".format(
368-
framework, [t for t in RLFramework]
367+
"Invalid type: {}, valid RL frameworks types are: {}".format(
368+
framework, list(RLFramework)
369369
)
370370
)
371371

@@ -375,11 +375,9 @@ def _validate_toolkit_format(cls, toolkit):
375375
Args:
376376
toolkit:
377377
"""
378-
if toolkit and toolkit not in RLToolkit:
378+
if toolkit and toolkit not in list(RLToolkit):
379379
raise ValueError(
380-
"Invalid type: {}, valid RL toolkits types are: [{}]".format(
381-
toolkit, [t for t in RLToolkit]
382-
)
380+
"Invalid type: {}, valid RL toolkits types are: {}".format(toolkit, list(RLToolkit))
383381
)
384382

385383
@classmethod

src/sagemaker/tuner.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ def __init__(self, warm_start_type, parents):
9292
warm start the new tuning job.
9393
"""
9494

95-
if warm_start_type not in WarmStartTypes:
95+
if warm_start_type not in list(WarmStartTypes):
9696
raise ValueError(
97-
"Invalid type: {}, valid warm start types are: [{}]".format(
98-
warm_start_type, [t for t in WarmStartTypes]
97+
"Invalid type: {}, valid warm start types are: {}".format(
98+
warm_start_type, list(WarmStartTypes)
9999
)
100100
)
101101

src/sagemaker/workflow/airflow.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,17 @@ def tuning_config(tuner, inputs, job_name=None, include_cls_metadata=False, mini
315315
}
316316

317317
if tuner.estimator:
318-
tune_config[
319-
"TrainingJobDefinition"
320-
], s3_operations = _extract_training_config_from_estimator(
318+
(
319+
tune_config["TrainingJobDefinition"],
320+
s3_operations,
321+
) = _extract_training_config_from_estimator(
321322
tuner, inputs, include_cls_metadata, mini_batch_size
322323
)
323324
else:
324-
tune_config[
325-
"TrainingJobDefinitions"
326-
], s3_operations = _extract_training_config_list_from_estimator_dict(
325+
(
326+
tune_config["TrainingJobDefinitions"],
327+
s3_operations,
328+
) = _extract_training_config_list_from_estimator_dict(
327329
tuner, inputs, include_cls_metadata, mini_batch_size
328330
)
329331

tests/integ/test_monitoring_files.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def test_constraint_violations_object_creation_from_file_path_with_customization
319319

320320

321321
def test_constraint_violations_object_creation_from_file_path_without_customizations(
322-
sagemaker_session
322+
sagemaker_session,
323323
):
324324
constraint_violations = ConstraintViolations.from_file_path(
325325
constraint_violations_file_path=os.path.join(
@@ -354,7 +354,7 @@ def test_constraint_violations_object_creation_from_string_with_customizations(
354354

355355

356356
def test_constraint_violations_object_creation_from_string_without_customizations(
357-
sagemaker_session
357+
sagemaker_session,
358358
):
359359
with open(os.path.join(tests.integ.DATA_DIR, "monitor/constraint_violations.json"), "r") as f:
360360
file_body = f.read()
@@ -404,7 +404,7 @@ def test_constraint_violations_object_creation_from_s3_uri_with_customizations(
404404

405405

406406
def test_constraint_violations_object_creation_from_s3_uri_without_customizations(
407-
sagemaker_session
407+
sagemaker_session,
408408
):
409409
with open(os.path.join(tests.integ.DATA_DIR, "monitor/constraint_violations.json"), "r") as f:
410410
file_body = f.read()

tests/integ/test_multi_variant_endpoint.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
tests.integ.DATA_DIR, "sparkml_model", "mleap_model.tar.gz"
5454
)
5555
SPARK_ML_DEFAULT_VARIANT_NAME = (
56-
"AllTraffic"
57-
) # default defined in src/sagemaker/session.py def production_variant
56+
"AllTraffic" # default defined in src/sagemaker/session.py def production_variant
57+
)
5858
SPARK_ML_WRONG_VARIANT_NAME = "WRONG_VARIANT"
5959
SPARK_ML_TEST_DATA = "1.0,C,38.0,71.5,1.0,female"
6060
SPARK_ML_MODEL_SCHEMA = json.dumps(

tests/integ/test_tfs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_predict_with_entry_point(tfs_predictor_with_model_and_entry_point_same_
163163

164164
@pytest.mark.local_mode
165165
def test_predict_with_model_and_entry_point_and_dependencies_separated(
166-
tfs_predictor_with_model_and_entry_point_and_dependencies
166+
tfs_predictor_with_model_and_entry_point_and_dependencies,
167167
):
168168
input_data = {"instances": [1.0, 2.0, 5.0]}
169169
expected_result = {"predictions": [4.0, 4.5, 6.0]}

tests/unit/test_image.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ def test__aws_credentials_with_long_lived_credentials():
799799

800800
@patch("sagemaker.local.image._aws_credentials_available_in_metadata_service")
801801
def test__aws_credentials_with_short_lived_credentials_and_ec2_metadata_service_having_credentials(
802-
mock
802+
mock,
803803
):
804804
credentials = Credentials(
805805
access_key=_random_string(), secret_key=_random_string(), token=_random_string()
@@ -814,7 +814,7 @@ def test__aws_credentials_with_short_lived_credentials_and_ec2_metadata_service_
814814

815815
@patch("sagemaker.local.image._aws_credentials_available_in_metadata_service")
816816
def test__aws_credentials_with_short_lived_credentials_and_ec2_metadata_service_having_no_credentials(
817-
mock
817+
mock,
818818
):
819819
credentials = Credentials(
820820
access_key=_random_string(), secret_key=_random_string(), token=_random_string()

tests/unit/test_tuner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def test_attach_tuning_job_with_estimator_from_hyperparameters(sagemaker_session
517517

518518

519519
def test_attach_tuning_job_with_estimator_from_hyperparameters_with_early_stopping(
520-
sagemaker_session
520+
sagemaker_session,
521521
):
522522
job_details = copy.deepcopy(TUNING_JOB_DETAILS)
523523
job_details["HyperParameterTuningJobConfig"]["TrainingJobEarlyStoppingType"] = "Auto"

tox.ini

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = black-format,flake8,pylint,twine,sphinx,doc8,py27,py36,py37
7+
envlist = black-format,flake8,pylint,twine,sphinx,doc8,py27,py36,py37,py38
88

99
skip_missing_interpreters = False
1010

@@ -80,7 +80,7 @@ basepython = python3
8080
skipdist = true
8181
skip_install = true
8282
deps =
83-
pylint==2.3.1
83+
pylint==2.5.2
8484
commands =
8585
python -m pylint --rcfile=.pylintrc -j 0 src/sagemaker
8686

@@ -129,13 +129,13 @@ commands = doc8
129129
[testenv:black-format]
130130
# Used during development (before committing) to format .py files.
131131
basepython = python3
132-
deps = black==19.3b0
132+
deps = black==19.10b0
133133
commands =
134134
black -l 100 ./
135135

136136
[testenv:black-check]
137137
# Used by automated build steps to check that all files are properly formatted.
138138
basepython = python3
139-
deps = black==19.3b0
139+
deps = black==19.10b0
140140
commands =
141141
black -l 100 --check ./

0 commit comments

Comments
 (0)