Skip to content

Commit 2d095ed

Browse files
Py312 upgrade step 2: Update dependencies, integ tests and unit tests (#5123)
* clean up * bump maxdepth for doc/api/training to fix readthedocs * change maxdepth for readthedocs rendering doc/api/training page * change maxdepth for readthedocs rendering doc/api/training page * change maxdepth for readthedocs rendering doc/api/training page
1 parent 79c4ddd commit 2d095ed

File tree

54 files changed

+1555
-1236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1555
-1236
lines changed

.githooks/pre-push

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ start_time=`date +%s`
1212
tox -e sphinx,doc8 --parallel all
1313
./ci-scripts/displaytime.sh 'sphinx,doc8' $start_time
1414
start_time=`date +%s`
15-
tox -e py38,py39,py310 --parallel all -- tests/unit
16-
./ci-scripts/displaytime.sh 'py38,py39,py310 unit' $start_time
15+
tox -e py39,py310,py311,py312 --parallel all -- tests/unit
16+
./ci-scripts/displaytime.sh 'py39,py310,py311,py312 unit' $start_time

.pylintrc

+19-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,24 @@ disable=
9494
useless-object-inheritance, # TODO: Enable this check and fix code once Python 2 is no longer supported.
9595
super-with-arguments,
9696
raise-missing-from,
97-
E1136,
97+
C0116, # Missing function or method docstring
98+
C0209, # Use f-string instead of format
99+
E0015, # Unrecognized option found in config
100+
E0702, # Raising a string instead of an exception
101+
E1101, # Module has no member (likely dynamic attr)
102+
E1136, # Value assigned to something inferred as None
103+
R0022, # Useless option value in config
104+
R1710, # Inconsistent return statements
105+
R1714, # Consider using `in` with comparisons
106+
R1729, # Use a generator
107+
R1732,
108+
R1735, # Consider using a dict or list literal
109+
W0237, # Argument renamed in override
110+
W0613, # Unused argument
111+
W0621, # Redefining name from outer scope
112+
W0719
113+
W1404, # Implicit string concatenation
114+
W1514, # `open()` used without encoding
98115

99116
[REPORTS]
100117
# Set the output format. Available formats are text, parseable, colorized, msvs
@@ -436,4 +453,4 @@ analyse-fallback-blocks=no
436453

437454
# Exceptions that will emit a warning when being caught. Defaults to
438455
# "Exception"
439-
overgeneral-exceptions=Exception
456+
overgeneral-exceptions=builtins.Exception

.readthedocs.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
version: 2
66

77
build:
8-
os: ubuntu-20.04
8+
os: ubuntu-22.04
99
tools:
10-
python: "3.9"
10+
python: "3.12"
1111

1212

1313
python:

doc/api/inference/model_builder.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Model Builder
33

44
This module contains classes related to Amazon Sagemaker Model Builder
55

6-
.. autoclass:: sagemaker.serve.builder.model_builder.ModelBuilder
6+
.. autoclass:: sagemaker.serve.ModelBuilder
77

8-
.. automethod:: sagemaker.serve.builder.model_builder.ModelBuilder.build
8+
.. automethod:: sagemaker.serve.ModelBuilder.build
99

10-
.. automethod:: sagemaker.serve.builder.model_builder.ModelBuilder.save
10+
.. automethod:: sagemaker.serve.ModelBuilder.save
1111

12-
.. autoclass:: sagemaker.serve.spec.inference_spec.InferenceSpec
12+
.. autoclass:: sagemaker.serve.InferenceSpec
1313

14-
.. autoclass:: sagemaker.serve.builder.schema_builder.SchemaBuilder
14+
.. autoclass:: sagemaker.serve.SchemaBuilder
1515

16-
.. autoclass:: sagemaker.serve.marshalling.custom_payload_translator.CustomPayloadTranslator
16+
.. autoclass:: sagemaker.serve.CustomPayloadTranslator

doc/api/training/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Training APIs
33
#############
44

55
.. toctree::
6-
:maxdepth: 4
6+
:maxdepth: 1
77

88
model_trainer
99
algorithm

doc/conf.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,11 @@
8383

8484
html_css_files = [
8585
"https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css",
86+
"theme_overrides.css",
87+
"pagination.css",
88+
"search_accessories.css",
8689
]
8790

88-
html_context = {
89-
"css_files": [
90-
"_static/theme_overrides.css",
91-
"_static/pagination.css",
92-
"_static/search_accessories.css",
93-
]
94-
}
95-
9691
# Example configuration for intersphinx: refer to the Python standard library.
9792
intersphinx_mapping = {"python": ("http://docs.python.org/", None)}
9893

doc/requirements.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
sphinx==5.1.1
2-
sphinx-rtd-theme==0.5.0
3-
docutils==0.15.2
4-
packaging==20.9
1+
sphinx==7.2.6
2+
sphinx-rtd-theme==3.0.0
3+
docutils>=0.18.1,<0.21
4+
packaging>=23.0,<25
55
jinja2==3.1.6
66
schema==0.7.5
77
accelerate>=0.24.1,<=0.27.0

pyproject.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "sagemaker"
77
dynamic = ["version", "optional-dependencies"]
88
description = "Open source library for training and deploying models on Amazon SageMaker."
99
readme = "README.rst"
10-
requires-python = ">=3.8"
10+
requires-python = ">=3.9"
1111
authors = [
1212
{ name = "Amazon Web Services" },
1313
]
@@ -25,10 +25,10 @@ classifiers = [
2525
"License :: OSI Approved :: Apache Software License",
2626
"Natural Language :: English",
2727
"Programming Language :: Python",
28-
"Programming Language :: Python :: 3.8",
2928
"Programming Language :: Python :: 3.9",
3029
"Programming Language :: Python :: 3.10",
3130
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
3232
]
3333
dependencies = [
3434
"attrs>=23.1.0,<24",
@@ -39,15 +39,15 @@ dependencies = [
3939
"google-pasta",
4040
"importlib-metadata>=1.4.0,<7.0",
4141
"jsonschema",
42-
"numpy>=1.9.0,<2.0",
42+
"numpy==1.26.4",
4343
"omegaconf>=2.2,<=2.3",
44-
"packaging>=20.0",
44+
"packaging>=23.0,<25",
4545
"pandas",
4646
"pathos",
4747
"platformdirs",
4848
"protobuf>=3.12,<6.0",
4949
"psutil",
50-
"PyYAML~=6.0",
50+
"PyYAML>=6.0.1",
5151
"requests",
5252
"sagemaker-core>=1.0.17,<2.0.0",
5353
"schema",
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
urllib3>=1.26.8,<3.0.0
22
docker>=5.0.2,<8.0.0
3-
PyYAML>=5.4.1,<7
3+
PyYAML>=6.0.1,<7
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
scipy==1.10.1
1+
scipy==1.11.3

requirements/extras/test_requirements.txt

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tox==3.24.5
2-
numpy>=1.24.0
2+
numpy==1.26.4
33
build[virtualenv]==1.2.1
4-
flake8==4.0.1
4+
flake8==7.1.2
55
pytest==6.2.5
66
pytest-cov==3.0.0
77
pytest-rerunfailures==10.2
@@ -14,10 +14,10 @@ awslogs==0.14.0
1414
black==24.3.0
1515
stopit==1.1.2
1616
# Update tox.ini to have correct version of airflow constraints file
17-
apache-airflow==2.9.3
17+
apache-airflow==2.10.4
1818
apache-airflow-providers-amazon==7.2.1
1919
attrs>=23.1.0,<24
20-
fabric==2.6.0
20+
fabric==3.2.2
2121
requests==2.32.2
2222
sagemaker-experiments==0.1.35
2323
Jinja2==3.1.6
@@ -26,13 +26,13 @@ pandas==1.4.4
2626
scikit-learn==1.3.0
2727
cloudpickle==2.2.1
2828
jsonpickle<4.0.0
29-
PyYAML==6.0
29+
PyYAML>=6.0.1
3030
# TODO find workaround
3131
xgboost>=1.6.2,<=1.7.6
3232
pillow>=10.0.1,<=11
3333
opentelemetry-proto==1.27.0
3434
protobuf==4.25.5
35-
tensorboard>=2.9.0,<=2.15.2
35+
tensorboard>=2.16.2,<=2.18.0
3636
transformers==4.48.0
3737
sentencepiece==0.1.99
3838
# https://github.com/triton-inference-server/server/issues/6246
@@ -42,7 +42,7 @@ onnx==1.17.0
4242
nbformat>=5.9,<6
4343
accelerate>=0.24.1,<=0.27.0
4444
schema==0.7.5
45-
tensorflow>=2.9.0,<=2.15.1
45+
tensorflow>=2.16.2,<=2.18.0
4646
mlflow>=2.12.2,<2.13
4747
huggingface_hub==0.26.2
4848
uvicorn>=0.30.1
@@ -51,3 +51,4 @@ nest-asyncio
5151
sagemaker-mlflow>=0.1.0
5252
deepdiff>=8.0.0
5353
orderly-set<5.4.0
54+
lexicon
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
doc8==0.10.1
2-
Pygments==2.15.0
1+
doc8==1.1.2
2+
Pygments==2.18.0
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
flake8==4.0.1
2-
flake8-future-import==0.4.6
1+
flake8==7.1.2
2+
flake8-future-import==0.4.7
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pylint==2.6.2
2-
astroid==2.4.2
1+
pylint==3.0.3
2+
astroid==3.0.2
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pyenchant==3.2.2
2-
pylint==2.6.2
2+
pylint==3.0.3

src/sagemaker/config/config_schema.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ def _simple_path(*args: str):
540540
"minItems": 0,
541541
"maxItems": 50,
542542
},
543-
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html#sagemaker-CreateTrainingJob-request-Environment
543+
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/
544+
# API_CreateTrainingJob.html#sagemaker-CreateTrainingJob-request-Environment
544545
"environmentVariables": {
545546
TYPE: OBJECT,
546547
ADDITIONAL_PROPERTIES: False,
@@ -553,13 +554,15 @@ def _simple_path(*args: str):
553554
},
554555
"maxProperties": 48,
555556
},
556-
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_S3DataSource.html#sagemaker-Type-S3DataSource-S3Uri
557+
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/
558+
# API_S3DataSource.html#sagemaker-Type-S3DataSource-S3Uri
557559
"s3Uri": {
558560
TYPE: "string",
559561
"pattern": "^(https|s3)://([^/]+)/?(.*)$",
560562
"maxLength": 1024,
561563
},
562-
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_AlgorithmSpecification.html#sagemaker-Type-AlgorithmSpecification-ContainerEntrypoint
564+
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/
565+
# API_AlgorithmSpecification.html#sagemaker-Type-AlgorithmSpecification-ContainerEntrypoint
563566
"preExecutionCommand": {TYPE: "string", "pattern": r".*"},
564567
# Regex based on https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_PipelineDefinitionS3Location.html
565568
# except with an additional ^ and $ for the beginning and the end to closer align to
@@ -570,7 +573,8 @@ def _simple_path(*args: str):
570573
"minLength": 3,
571574
"maxLength": 63,
572575
},
573-
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_MonitoringJobDefinition.html#sagemaker-Type-MonitoringJobDefinition-Environment
576+
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/
577+
# API_MonitoringJobDefinition.html#sagemaker-Type-MonitoringJobDefinition-Environment
574578
"environment-Length256-Properties50": {
575579
TYPE: OBJECT,
576580
ADDITIONAL_PROPERTIES: False,
@@ -583,7 +587,8 @@ def _simple_path(*args: str):
583587
},
584588
"maxProperties": 50,
585589
},
586-
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTransformJob.html#sagemaker-CreateTransformJob-request-Environment
590+
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/
591+
# API_CreateTransformJob.html#sagemaker-CreateTransformJob-request-Environment
587592
"environment-Length10240-Properties16": {
588593
TYPE: OBJECT,
589594
ADDITIONAL_PROPERTIES: False,
@@ -596,7 +601,8 @@ def _simple_path(*args: str):
596601
},
597602
"maxProperties": 16,
598603
},
599-
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ContainerDefinition.html#sagemaker-Type-ContainerDefinition-Environment
604+
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/
605+
# API_ContainerDefinition.html#sagemaker-Type-ContainerDefinition-Environment
600606
"environment-Length1024-Properties16": {
601607
TYPE: OBJECT,
602608
ADDITIONAL_PROPERTIES: False,
@@ -609,7 +615,8 @@ def _simple_path(*args: str):
609615
},
610616
"maxProperties": 16,
611617
},
612-
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateProcessingJob.html#sagemaker-CreateProcessingJob-request-Environment
618+
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/
619+
# API_CreateProcessingJob.html#sagemaker-CreateProcessingJob-request-Environment
613620
"environment-Length256-Properties100": {
614621
TYPE: OBJECT,
615622
ADDITIONAL_PROPERTIES: False,
@@ -622,7 +629,8 @@ def _simple_path(*args: str):
622629
},
623630
"maxProperties": 100,
624631
},
625-
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html#sagemaker-CreateTrainingJob-request-Environment
632+
# Regex is taken from https://docs.aws.amazon.com/sagemaker/latest/APIReference/
633+
# API_CreateTrainingJob.html#sagemaker-CreateTrainingJob-request-Environment
626634
"environment-Length512-Properties48": {
627635
TYPE: OBJECT,
628636
ADDITIONAL_PROPERTIES: False,

src/sagemaker/feature_store/dataset_builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def _construct_query_string(self, base: FeatureGroupToBeMerged) -> str:
929929
selected_features += ", "
930930
selected_features += ", ".join(
931931
[
932-
f'fg_{i}."{feature_name}" as "{feature_name}.{(i+1)}"'
932+
f'fg_{i}."{feature_name}" as "{feature_name}.{(i + 1)}"'
933933
for feature_name in feature_group.projected_feature_names
934934
]
935935
)

src/sagemaker/jumpstart/factory/model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def get_default_predictor(
104104
"""
105105

106106
# if there's a non-default predictor, do not mutate -- return as is
107-
if type(predictor) != Predictor: # pylint: disable=C0123
107+
if not isinstance(predictor, Predictor):
108108
raise RuntimeError(
109109
"Can only get default predictor from base Predictor class. "
110110
f"Using Predictor class '{type(predictor).__name__}'."

src/sagemaker/local/entities.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -845,10 +845,10 @@ def _initialize_and_validate_parameters(self, overridden_parameters):
845845
)
846846
raise ClientError(error_msg, "start_pipeline_execution")
847847
parameter_type = default_parameters[param_name].parameter_type
848-
if type(param_value) != parameter_type.python_type: # pylint: disable=C0123
848+
if not isinstance(param_value, parameter_type.python_type):
849849
error_msg = self._construct_validation_exception_message(
850-
"Unexpected type for parameter '{}'. Expected {} but found "
851-
"{}.".format(param_name, parameter_type.python_type, type(param_value))
850+
f"Unexpected type for parameter '{param_name}'. Expected \
851+
{parameter_type.python_type} but found {type(param_value)}."
852852
)
853853
raise ClientError(error_msg, "start_pipeline_execution")
854854
if param_value == "":

src/sagemaker/model_monitor/clarify_model_monitoring.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,9 @@ def __init__(
8686
object that configures network isolation, encryption of
8787
inter-container traffic, security group IDs, and subnets.
8888
"""
89-
if type(self) == __class__: # pylint: disable=unidiomatic-typecheck
89+
if self.__class__ is __class__:
9090
raise TypeError(
91-
"{} is abstract, please instantiate its subclasses instead.".format(
92-
__class__.__name__
93-
)
91+
f"{__class__.__name__} is abstract, please instantiate its subclasses instead."
9492
)
9593

9694
session = sagemaker_session or Session()

src/sagemaker/serve/model_server/multi_model_server/prepare.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def prepare_for_mms(
8484
image_uri: str,
8585
inference_spec: InferenceSpec = None,
8686
) -> str:
87-
"""Prepares for InferenceSpec using model_path, writes inference.py, and captures dependencies to generate secret_key.
87+
"""Prepares for InferenceSpec using model_path, writes inference.py, \
88+
and captures dependencies to generate secret_key.
8889
8990
Args:to
9091
model_path (str) : Argument

0 commit comments

Comments
 (0)