Skip to content

change: include py38 tox env and some dependency upgrades #1593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
222a56e
feature: Use boto3 DEFAULT_SESSION when no boto3 session specified. (…
nadiaya Jun 5, 2020
b3f51a8
change: remove v2 Session warnings (#1556)
laurenyu Jun 8, 2020
13c1e5f
prepare release v1.61.0
Jun 9, 2020
a84152a
update development version to v1.61.1.dev0
Jun 9, 2020
5d57f7b
docs: workflows navigation (#1563)
aaronmarkham Jun 10, 2020
8eebfe4
change: make instance_type optional for prepare_container_def (#1567)
laurenyu Jun 10, 2020
fad5c0d
feature: Support for multi variant endpoint invocation with target va…
aakashpydi Jun 10, 2020
fb5d7a3
Revert "feature: Support for multi variant endpoint invocation with t…
chuyang-deng Jun 11, 2020
0920972
doc: fix typo in MXNet documentation (#1575)
theofpa Jun 11, 2020
77b7c7f
prepare release v1.62.0
Jun 11, 2020
47b668a
update development version to v1.62.1.dev0
Jun 11, 2020
faa4993
doc: improve docstring and remove unavailable links (#1572)
chuyang-deng Jun 11, 2020
47df021
feature: Support for multi variant endpoint invocation with target va…
aakashpydi Jun 12, 2020
974b734
feature: Allow selecting inference response content for automl genera…
pdasamzn Jun 12, 2020
4249796
prepare release v1.63.0
Jun 12, 2020
f586b3f
update development version to v1.63.1.dev0
Jun 12, 2020
b214078
feature: add support for SKLearn 0.23 (#1561)
Jun 12, 2020
0001e1b
change: include py38 tox env and some dependency upgrades
metrizable Jun 3, 2020
b35a0e1
change: include py38 tox env and some dependency upgrades
metrizable Jun 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,22 @@ confidence=
# --disable=W"
disable=
C0330, # Black disagrees with and explicitly violates this: https://github.com/python/black/issues/48
too-many-locals,
abstract-method, # TODO: Fix abstract methods
arguments-differ,
too-many-lines,
cyclic-import, # TODO: Resolve cyclic imports
fixme,
too-many-arguments,
invalid-name,
too-many-instance-attributes,
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
import-error, # Since we run Pylint before any of our builds in tox, this will always fail
protected-access, # TODO: Fix access
abstract-method, # TODO: Fix abstract methods
useless-object-inheritance, # TODO: Enable this check and fix code once Python 2 is no longer supported.
cyclic-import, # TODO: Resolve cyclic imports
import-outside-toplevel,
no-self-use, # TODO: Convert methods to functions where appropriate
protected-access, # TODO: Fix access
signature-differs, # TODO: fix kwargs
too-many-arguments,
too-many-branches, # TODO: Simplify or ignore as appropriate
too-many-instance-attributes,
too-many-lines,
too-many-locals,
useless-object-inheritance, # TODO: Enable this check and fix code once Python 2 is no longer supported.

[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ def read_version():
extras["test"] = (
[
extras["all"],
"tox==3.13.1",
"tox==3.15.1",
"flake8",
"pytest==4.4.1",
"pytest==4.6.10",
"pytest-cov",
"pytest-rerunfailures",
"pytest-xdist",
"mock",
"contextlib2",
"awslogs",
"black==19.3b0 ; python_version >= '3.6'",
"black==19.10b0 ; python_version >= '3.6'",
"stopit==1.1.2",
"apache-airflow==1.10.5",
"fabric>=2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/sagemaker/amazon/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ def read_recordio(f):
"""
while True:
try:
read_kmagic, = struct.unpack("I", f.read(4))
(read_kmagic,) = struct.unpack("I", f.read(4))
except struct.error:
return
assert read_kmagic == _kmagic
len_record, = struct.unpack("I", f.read(4))
(len_record,) = struct.unpack("I", f.read(4))
pad = (((len_record + 3) >> 2) << 2) - len_record
yield f.read(len_record)
if pad:
Expand Down
2 changes: 1 addition & 1 deletion src/sagemaker/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, args):
self.script = args.script
self.instance_type = args.instance_type
self.instance_count = args.instance_count
self.environment = {k: v for k, v in (kv.split("=") for kv in args.env)}
self.environment = dict((kv.split("=") for kv in args.env))

self.session = sagemaker.Session()

Expand Down
12 changes: 5 additions & 7 deletions src/sagemaker/rl/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ def _validate_framework_format(cls, framework):
Args:
framework:
"""
if framework and framework not in RLFramework:
if framework and framework not in list(RLFramework):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some Googling to see if there's a more Pythonic way of doing this, and the best I found was:

if framework and framework not in RLFramework.__members__

I don't have a strong preference, though

raise ValueError(
"Invalid type: {}, valid RL frameworks types are: [{}]".format(
framework, [t for t in RLFramework]
"Invalid type: {}, valid RL frameworks types are: {}".format(
framework, list(RLFramework)
)
)

Expand All @@ -375,11 +375,9 @@ def _validate_toolkit_format(cls, toolkit):
Args:
toolkit:
"""
if toolkit and toolkit not in RLToolkit:
if toolkit and toolkit not in list(RLToolkit):
raise ValueError(
"Invalid type: {}, valid RL toolkits types are: [{}]".format(
toolkit, [t for t in RLToolkit]
)
"Invalid type: {}, valid RL toolkits types are: {}".format(toolkit, list(RLToolkit))
)

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions src/sagemaker/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def __init__(self, warm_start_type, parents):
warm start the new tuning job.
"""

if warm_start_type not in WarmStartTypes:
if warm_start_type not in list(WarmStartTypes):
raise ValueError(
"Invalid type: {}, valid warm start types are: [{}]".format(
warm_start_type, [t for t in WarmStartTypes]
"Invalid type: {}, valid warm start types are: {}".format(
warm_start_type, list(WarmStartTypes)
)
)

Expand Down
14 changes: 8 additions & 6 deletions src/sagemaker/workflow/airflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,17 @@ def tuning_config(tuner, inputs, job_name=None, include_cls_metadata=False, mini
}

if tuner.estimator:
tune_config[
"TrainingJobDefinition"
], s3_operations = _extract_training_config_from_estimator(
(
tune_config["TrainingJobDefinition"],
s3_operations,
) = _extract_training_config_from_estimator(
tuner, inputs, include_cls_metadata, mini_batch_size
)
else:
tune_config[
"TrainingJobDefinitions"
], s3_operations = _extract_training_config_list_from_estimator_dict(
(
tune_config["TrainingJobDefinitions"],
s3_operations,
) = _extract_training_config_list_from_estimator_dict(
tuner, inputs, include_cls_metadata, mini_batch_size
)

Expand Down
6 changes: 3 additions & 3 deletions tests/integ/test_monitoring_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def test_constraint_violations_object_creation_from_file_path_with_customization


def test_constraint_violations_object_creation_from_file_path_without_customizations(
sagemaker_session
sagemaker_session,
):
constraint_violations = ConstraintViolations.from_file_path(
constraint_violations_file_path=os.path.join(
Expand Down Expand Up @@ -354,7 +354,7 @@ def test_constraint_violations_object_creation_from_string_with_customizations(


def test_constraint_violations_object_creation_from_string_without_customizations(
sagemaker_session
sagemaker_session,
):
with open(os.path.join(tests.integ.DATA_DIR, "monitor/constraint_violations.json"), "r") as f:
file_body = f.read()
Expand Down Expand Up @@ -404,7 +404,7 @@ def test_constraint_violations_object_creation_from_s3_uri_with_customizations(


def test_constraint_violations_object_creation_from_s3_uri_without_customizations(
sagemaker_session
sagemaker_session,
):
with open(os.path.join(tests.integ.DATA_DIR, "monitor/constraint_violations.json"), "r") as f:
file_body = f.read()
Expand Down
4 changes: 2 additions & 2 deletions tests/integ/test_multi_variant_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
tests.integ.DATA_DIR, "sparkml_model", "mleap_model.tar.gz"
)
SPARK_ML_DEFAULT_VARIANT_NAME = (
"AllTraffic"
) # default defined in src/sagemaker/session.py def production_variant
"AllTraffic" # default defined in src/sagemaker/session.py def production_variant
)
SPARK_ML_WRONG_VARIANT_NAME = "WRONG_VARIANT"
SPARK_ML_TEST_DATA = "1.0,C,38.0,71.5,1.0,female"
SPARK_ML_MODEL_SCHEMA = json.dumps(
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/test_tfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_predict_with_entry_point(tfs_predictor_with_model_and_entry_point_same_

@pytest.mark.local_mode
def test_predict_with_model_and_entry_point_and_dependencies_separated(
tfs_predictor_with_model_and_entry_point_and_dependencies
tfs_predictor_with_model_and_entry_point_and_dependencies,
):
input_data = {"instances": [1.0, 2.0, 5.0]}
expected_result = {"predictions": [4.0, 4.5, 6.0]}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def test__aws_credentials_with_long_lived_credentials():

@patch("sagemaker.local.image._aws_credentials_available_in_metadata_service")
def test__aws_credentials_with_short_lived_credentials_and_ec2_metadata_service_having_credentials(
mock
mock,
):
credentials = Credentials(
access_key=_random_string(), secret_key=_random_string(), token=_random_string()
Expand All @@ -814,7 +814,7 @@ def test__aws_credentials_with_short_lived_credentials_and_ec2_metadata_service_

@patch("sagemaker.local.image._aws_credentials_available_in_metadata_service")
def test__aws_credentials_with_short_lived_credentials_and_ec2_metadata_service_having_no_credentials(
mock
mock,
):
credentials = Credentials(
access_key=_random_string(), secret_key=_random_string(), token=_random_string()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def test_attach_tuning_job_with_estimator_from_hyperparameters(sagemaker_session


def test_attach_tuning_job_with_estimator_from_hyperparameters_with_early_stopping(
sagemaker_session
sagemaker_session,
):
job_details = copy.deepcopy(TUNING_JOB_DETAILS)
job_details["HyperParameterTuningJobConfig"]["TrainingJobEarlyStoppingType"] = "Auto"
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

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

skip_missing_interpreters = False

Expand Down Expand Up @@ -80,7 +80,7 @@ basepython = python3
skipdist = true
skip_install = true
deps =
pylint==2.3.1
pylint==2.5.2
commands =
python -m pylint --rcfile=.pylintrc -j 0 src/sagemaker

Expand Down Expand Up @@ -129,13 +129,13 @@ commands = doc8
[testenv:black-format]
# Used during development (before committing) to format .py files.
basepython = python3
deps = black==19.3b0
deps = black==19.10b0
commands =
black -l 100 ./

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