diff --git a/.githooks/pre-push b/.githooks/pre-push index 995ab70108..f73fa492b3 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -12,5 +12,5 @@ start_time=`date +%s` tox -e sphinx,doc8 --parallel all ./ci-scripts/displaytime.sh 'sphinx,doc8' $start_time start_time=`date +%s` -tox -e py38,py39,py310 --parallel all -- tests/unit -./ci-scripts/displaytime.sh 'py38,py39,py310 unit' $start_time +tox -e py39,py310,py311,py312 --parallel all -- tests/unit +./ci-scripts/displaytime.sh 'py39,py310,py311,py312 unit' $start_time diff --git a/.github/workflows/codebuild-ci-health.yml b/.github/workflows/codebuild-ci-health.yml index 7ecefd310f..119b9dbe9c 100644 --- a/.github/workflows/codebuild-ci-health.yml +++ b/.github/workflows/codebuild-ci-health.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["py38", "py39", "py310", "py311"] + python-version: ["py39", "py310", "py311","py312"] steps: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 diff --git a/.github/workflows/codebuild-ci.yml b/.github/workflows/codebuild-ci.yml index 8c6bd6b337..eef53ff06c 100644 --- a/.github/workflows/codebuild-ci.yml +++ b/.github/workflows/codebuild-ci.yml @@ -63,7 +63,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["py38","py39","py310","py311"] + python-version: ["py39","py310","py311","py312"] steps: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 diff --git a/doc/requirements.txt b/doc/requirements.txt index 71a95f7633..36425f324c 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,8 +1,8 @@ sphinx==5.1.1 sphinx-rtd-theme==0.5.0 docutils==0.15.2 -packaging==20.9 -jinja2==3.1.6 +packaging>=23.0,<25 +jinja2==3.1.4 schema==0.7.5 accelerate>=0.24.1,<=0.27.0 graphene<4.0 diff --git a/pyproject.toml b/pyproject.toml index 0122a6bf3c..b67f831a98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "sagemaker" dynamic = ["version", "optional-dependencies"] description = "Open source library for training and deploying models on Amazon SageMaker." readme = "README.rst" -requires-python = ">=3.8" +requires-python = ">=3.9" authors = [ { name = "Amazon Web Services" }, ] @@ -25,10 +25,10 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] dependencies = [ "attrs>=23.1.0,<24", @@ -39,15 +39,15 @@ dependencies = [ "google-pasta", "importlib-metadata>=1.4.0,<7.0", "jsonschema", - "numpy>=1.9.0,<2.0", + "numpy>=1.26.0,<2.0", "omegaconf>=2.2,<=2.3", - "packaging>=20.0", + "packaging>=23.0,<25", "pandas", "pathos", "platformdirs", "protobuf>=3.12,<6.0", "psutil", - "PyYAML~=6.0", + "PyYAML>=6.0.1", "requests", "sagemaker-core>=1.0.17,<2.0.0", "schema", diff --git a/requirements/extras/local_requirements.txt b/requirements/extras/local_requirements.txt index 68b9a1bcb3..ea57b82e9a 100644 --- a/requirements/extras/local_requirements.txt +++ b/requirements/extras/local_requirements.txt @@ -1,3 +1,3 @@ urllib3>=1.26.8,<3.0.0 docker>=5.0.2,<8.0.0 -PyYAML>=5.4.1,<7 +PyYAML>=6.0.1,<7 diff --git a/requirements/extras/scipy_requirements.txt b/requirements/extras/scipy_requirements.txt index 0e99587e6e..44ce1d9331 100644 --- a/requirements/extras/scipy_requirements.txt +++ b/requirements/extras/scipy_requirements.txt @@ -1 +1 @@ -scipy==1.10.1 +scipy==1.11.3 diff --git a/requirements/extras/test_requirements.txt b/requirements/extras/test_requirements.txt index de960e4619..91993b45e8 100644 --- a/requirements/extras/test_requirements.txt +++ b/requirements/extras/test_requirements.txt @@ -1,5 +1,5 @@ tox==3.24.5 -numpy>=1.24.0 +numpy>=1.26.0,<2.0 build[virtualenv]==1.2.1 flake8==4.0.1 pytest==6.2.5 @@ -14,7 +14,7 @@ awslogs==0.14.0 black==24.3.0 stopit==1.1.2 # Update tox.ini to have correct version of airflow constraints file -apache-airflow==2.9.3 +apache-airflow==2.10.4 apache-airflow-providers-amazon==7.2.1 attrs>=23.1.0,<24 fabric==2.6.0 @@ -26,14 +26,14 @@ pandas==1.4.4 scikit-learn==1.3.0 cloudpickle==2.2.1 jsonpickle<4.0.0 -PyYAML==6.0 +PyYAML>=6.0.1 # TODO find workaround xgboost>=1.6.2,<=1.7.6 pillow>=10.0.1,<=11 opentelemetry-proto==1.27.0 protobuf==4.25.5 -tensorboard>=2.9.0,<=2.15.2 -transformers==4.48.0 +tensorboard>=2.16.2,<=2.18.0 +transformers==4.46.1 sentencepiece==0.1.99 # https://github.com/triton-inference-server/server/issues/6246 tritonclient[http]<2.37.0 @@ -42,7 +42,7 @@ onnx==1.17.0 nbformat>=5.9,<6 accelerate>=0.24.1,<=0.27.0 schema==0.7.5 -tensorflow>=2.9.0,<=2.15.1 +tensorflow>=2.16.2,<=2.18.0 mlflow>=2.12.2,<2.13 huggingface_hub==0.26.2 uvicorn>=0.30.1 diff --git a/src/sagemaker/serve/utils/conda_in_process.yml b/src/sagemaker/serve/utils/conda_in_process.yml index 61badaa52f..7ac17d7a71 100644 --- a/src/sagemaker/serve/utils/conda_in_process.yml +++ b/src/sagemaker/serve/utils/conda_in_process.yml @@ -12,15 +12,15 @@ dependencies: - boto3>=1.34.142,<2.0 - cloudpickle==2.2.1 - google-pasta - - numpy>=1.9.0,<2.0 + - numpy>=1.26.0,<2.0 - protobuf>=3.12,<5.0 - smdebug_rulesconfig==1.0.1 - importlib-metadata>=1.4.0,<7.0 - - packaging>=20.0 + - packaging>=23.0,<25 - pandas - pathos - schema - - PyYAML~=6.0 + - PyYAML>=6.0.1 - jsonschema - platformdirs - tblib>=1.7.0,<4 @@ -43,7 +43,7 @@ dependencies: - colorama>=0.4.4 - contextlib2>=21.6.0 - decorator>=5.1.1 - - dill>=0.3.6 + - dill>=0.3.9 - docutils>=0.16 - entrypoints>=0.4 - filelock>=3.11.0 @@ -82,7 +82,7 @@ dependencies: - python-dateutil>=2.8.2 - pytz>=2023.3 - pytz-deprecation-shim>=0.1.0.post0 - - pyyaml>=5.4.1 + - pyyaml>=6.0.1 - regex>=2023.3.23 - requests>=2.28.2 - rich>=13.3.4 diff --git a/src/sagemaker/serve/utils/in_process_requirements.txt b/src/sagemaker/serve/utils/in_process_requirements.txt index e356e1720d..da1fd8e617 100644 --- a/src/sagemaker/serve/utils/in_process_requirements.txt +++ b/src/sagemaker/serve/utils/in_process_requirements.txt @@ -11,7 +11,7 @@ cloudpickle==2.2.1 colorama>=0.4.4 contextlib2>=21.6.0 decorator>=5.1.1 -dill>=0.3.6 +dill>=0.3.9 docutils>=0.16 entrypoints>=0.4 filelock>=3.11.0 @@ -50,7 +50,7 @@ pyrsistent>=0.19.3 python-dateutil>=2.8.2 pytz>=2023.3 pytz-deprecation-shim>=0.1.0.post0 -pyyaml>=5.4.1 +pyyaml>=6.0.1 regex>=2023.3.23 requests>=2.28.2 rich>=13.3.4 diff --git a/tests/data/pipeline/model_step/pytorch_mnist/requirements.txt b/tests/data/pipeline/model_step/pytorch_mnist/requirements.txt index 56d09228be..c25fca7e9f 100644 --- a/tests/data/pipeline/model_step/pytorch_mnist/requirements.txt +++ b/tests/data/pipeline/model_step/pytorch_mnist/requirements.txt @@ -1 +1 @@ -scipy>=1.8.1 +scipy>=1.11.3 diff --git a/tests/data/remote_function/requirements.txt b/tests/data/remote_function/requirements.txt index 0e99587e6e..44ce1d9331 100644 --- a/tests/data/remote_function/requirements.txt +++ b/tests/data/remote_function/requirements.txt @@ -1 +1 @@ -scipy==1.10.1 +scipy==1.11.3 diff --git a/tests/data/serve_resources/mlflow/pytorch/conda.yaml b/tests/data/serve_resources/mlflow/pytorch/conda.yaml index beecdbab08..b740d25b70 100644 --- a/tests/data/serve_resources/mlflow/pytorch/conda.yaml +++ b/tests/data/serve_resources/mlflow/pytorch/conda.yaml @@ -9,7 +9,7 @@ dependencies: - cffi==1.16.0 - cloudpickle==2.2.1 - defusedxml==0.7.1 - - dill==0.3.8 + - dill==0.3.9 - gmpy2==2.1.2 - numpy==1.26.4 - opt-einsum==3.3.0 diff --git a/tests/data/serve_resources/mlflow/pytorch/requirements.txt b/tests/data/serve_resources/mlflow/pytorch/requirements.txt index 450bcbfada..aacc85cb91 100644 --- a/tests/data/serve_resources/mlflow/pytorch/requirements.txt +++ b/tests/data/serve_resources/mlflow/pytorch/requirements.txt @@ -3,11 +3,11 @@ astunparse==1.6.3 cffi==1.16.0 cloudpickle==2.2.1 defusedxml==0.7.1 -dill==0.3.8 +dill==0.3.9 gmpy2==2.1.2 -numpy==1.24.4 +numpy==1.26.4 opt-einsum==3.3.0 -packaging==21.3 +packaging>=23.0,<25 pandas==2.2.1 pyyaml==6.0.1 requests==2.32.2 diff --git a/tests/data/serve_resources/mlflow/xgboost/requirements.txt b/tests/data/serve_resources/mlflow/xgboost/requirements.txt index 1130dcaec5..6f879340a7 100644 --- a/tests/data/serve_resources/mlflow/xgboost/requirements.txt +++ b/tests/data/serve_resources/mlflow/xgboost/requirements.txt @@ -1,8 +1,8 @@ mlflow==2.13.2 lz4==4.3.2 -numpy==1.24.4 +numpy==1.26.4 pandas==2.0.3 psutil==5.9.8 scikit-learn==1.3.2 -scipy==1.10.1 +scipy==1.11.3 xgboost==1.7.1 diff --git a/tests/data/workflow/requirements.txt b/tests/data/workflow/requirements.txt index 0e99587e6e..44ce1d9331 100644 --- a/tests/data/workflow/requirements.txt +++ b/tests/data/workflow/requirements.txt @@ -1 +1 @@ -scipy==1.10.1 +scipy==1.11.3 diff --git a/tests/integ/sagemaker/experiments/test_run.py b/tests/integ/sagemaker/experiments/test_run.py index 4f59d11c54..f75f513cc0 100644 --- a/tests/integ/sagemaker/experiments/test_run.py +++ b/tests/integ/sagemaker/experiments/test_run.py @@ -32,7 +32,7 @@ from sagemaker.experiments.trial_component import _TrialComponent from sagemaker.sklearn import SKLearn from sagemaker.utils import retry_with_backoff, unique_name_from_base -from tests.integ.sagemaker.experiments.helpers import name, cleanup_exp_resources +from tests.integ.sagemaker.experiments.helpers import name, cleanup_exp_resources, clear_run_context from sagemaker.experiments.run import ( RUN_NAME_BASE, DELIMITER, @@ -55,7 +55,7 @@ def artifact_file_path(tempdir): metric_name = "Test-Local-Init-Log-Metric" -def test_local_run_with_load(sagemaker_session, artifact_file_path): +def test_local_run_with_load(sagemaker_session, artifact_file_path, clear_run_context): exp_name = f"My-Local-Exp-{name()}" with cleanup_exp_resources(exp_names=[exp_name], sagemaker_session=sagemaker_session): # Run name is not provided, will create a new TC @@ -86,7 +86,9 @@ def verify_load_run(): retry_with_backoff(verify_load_run, 4) -def test_two_local_run_init_with_same_run_name_and_different_exp_names(sagemaker_session): +def test_two_local_run_init_with_same_run_name_and_different_exp_names( + sagemaker_session, clear_run_context +): exp_name1 = f"my-two-local-exp1-{name()}" exp_name2 = f"my-two-local-exp2-{name()}" run_name = "test-run" @@ -124,7 +126,9 @@ def test_two_local_run_init_with_same_run_name_and_different_exp_names(sagemaker ("my-test4", "test-run", "run-display-name-test"), # with supplied display name ], ) -def test_run_name_vs_trial_component_name_edge_cases(sagemaker_session, input_names): +def test_run_name_vs_trial_component_name_edge_cases( + sagemaker_session, input_names, clear_run_context +): exp_name, run_name, run_display_name = input_names with cleanup_exp_resources(exp_names=[exp_name], sagemaker_session=sagemaker_session): with Run( @@ -177,6 +181,7 @@ def test_run_from_local_and_train_job_and_all_exp_cfg_match( execution_role, sagemaker_client_config, sagemaker_metrics_config, + clear_run_context, ): # Notes: # 1. The 1st Run created locally and its exp config was auto passed to the job @@ -277,6 +282,7 @@ def test_run_from_local_and_train_job_and_exp_cfg_not_match( execution_role, sagemaker_client_config, sagemaker_metrics_config, + clear_run_context, ): # Notes: # 1. The 1st Run created locally and its exp config was auto passed to the job @@ -363,6 +369,7 @@ def test_run_from_train_job_only( execution_role, sagemaker_client_config, sagemaker_metrics_config, + clear_run_context, ): # Notes: # 1. No Run created locally or specified in experiment config @@ -413,6 +420,7 @@ def test_run_from_processing_job_and_override_default_exp_config( execution_role, sagemaker_client_config, sagemaker_metrics_config, + clear_run_context, ): # Notes: # 1. The 1st Run (run) created locally @@ -492,6 +500,7 @@ def test_run_from_transform_job( execution_role, sagemaker_client_config, sagemaker_metrics_config, + clear_run_context, ): # Notes: # 1. The 1st Run (run) created locally @@ -573,6 +582,7 @@ def test_load_run_auto_pass_in_exp_config_to_job( execution_role, sagemaker_client_config, sagemaker_metrics_config, + clear_run_context, ): # Notes: # 1. In local side, load the Run created previously and invoke a job under the load context @@ -621,7 +631,7 @@ def test_load_run_auto_pass_in_exp_config_to_job( ) -def test_list(run_obj, sagemaker_session): +def test_list(run_obj, sagemaker_session, clear_run_context): tc1 = _TrialComponent.create( trial_component_name=f"non-run-tc1-{name()}", sagemaker_session=sagemaker_session, @@ -643,7 +653,7 @@ def test_list(run_obj, sagemaker_session): assert run_tcs[0].experiment_config == run_obj.experiment_config -def test_list_twice(run_obj, sagemaker_session): +def test_list_twice(run_obj, sagemaker_session, clear_run_context): tc1 = _TrialComponent.create( trial_component_name=f"non-run-tc1-{name()}", sagemaker_session=sagemaker_session, @@ -720,8 +730,8 @@ def _generate_processor( ) return FrameworkProcessor( estimator_cls=PyTorch, - framework_version="1.10", - py_version="py38", + framework_version="1.13.1", + py_version="py39", instance_count=1, instance_type="ml.m5.xlarge", role=execution_role, diff --git a/tests/integ/sagemaker/workflow/test_workflow.py b/tests/integ/sagemaker/workflow/test_workflow.py index 2643a3b88e..9ef0b14a04 100644 --- a/tests/integ/sagemaker/workflow/test_workflow.py +++ b/tests/integ/sagemaker/workflow/test_workflow.py @@ -1122,8 +1122,8 @@ def test_model_registration_with_tuning_model( entry_point=entry_point, source_dir=base_dir, role=role, - framework_version="1.10", - py_version="py38", + framework_version="1.13.1", + py_version="py39", instance_count=instance_count, instance_type=instance_type, sagemaker_session=pipeline_session, @@ -1159,8 +1159,8 @@ def test_model_registration_with_tuning_model( ), entry_point=entry_point, source_dir=base_dir, - framework_version="1.10", - py_version="py38", + framework_version="1.13.1", + py_version="py39", sagemaker_session=pipeline_session, ) step_model_regis_args = model.register( diff --git a/tests/unit/sagemaker/huggingface/test_llm_utils.py b/tests/unit/sagemaker/huggingface/test_llm_utils.py index 675a6fd885..9bb1b451a1 100644 --- a/tests/unit/sagemaker/huggingface/test_llm_utils.py +++ b/tests/unit/sagemaker/huggingface/test_llm_utils.py @@ -65,7 +65,7 @@ def test_huggingface_model_metadata_unauthorized_exception(self, mock_urllib): "Trying to access a gated/private HuggingFace model without valid credentials. " "Please provide a HUGGING_FACE_HUB_TOKEN in env_vars" ) - self.assertEquals(expected_error_msg, str(context.exception)) + self.assertEqual(expected_error_msg, str(context.exception)) @patch("sagemaker.huggingface.llm_utils.urllib") def test_huggingface_model_metadata_general_exception(self, mock_urllib): @@ -76,7 +76,7 @@ def test_huggingface_model_metadata_general_exception(self, mock_urllib): expected_error_msg = ( f"Did not find model metadata for the following HuggingFace Model ID {MOCK_HF_ID}" ) - self.assertEquals(expected_error_msg, str(context.exception)) + self.assertEqual(expected_error_msg, str(context.exception)) @patch("huggingface_hub.snapshot_download") def test_download_huggingface_model_metadata(self, mock_snapshot_download): diff --git a/tests/unit/sagemaker/jumpstart/constants.py b/tests/unit/sagemaker/jumpstart/constants.py index 2eb7469e21..ae02c597da 100644 --- a/tests/unit/sagemaker/jumpstart/constants.py +++ b/tests/unit/sagemaker/jumpstart/constants.py @@ -14360,7 +14360,7 @@ "jmespath==1.0.1", "jsonschema==4.17.3", "multiprocess==0.70.14", - "numpy==1.24.3", + "numpy==1.26.4", "oscrypto==1.3.0", "packaging==23.1", "pandas==2.0.2", diff --git a/tests/unit/sagemaker/jumpstart/estimator/test_sagemaker_config.py b/tests/unit/sagemaker/jumpstart/estimator/test_sagemaker_config.py index 073921d5ba..39eca166ee 100644 --- a/tests/unit/sagemaker/jumpstart/estimator/test_sagemaker_config.py +++ b/tests/unit/sagemaker/jumpstart/estimator/test_sagemaker_config.py @@ -123,16 +123,16 @@ def test_without_arg_overwrites_without_kwarg_collisions_with_config( mock_retrieve_model_init_kwargs.return_value = {} - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_estimator_init.call_args[1].get("role"), config_role) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_estimator_init.call_args[1].get("role"), config_role) assert "enable_network_isolation" not in mock_estimator_init.call_args[1] assert "encrypt_inter_container_traffic" not in mock_estimator_init.call_args[1] estimator.deploy() - self.assertEquals(mock_get_sagemaker_config_value.call_count, 3) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 3) - self.assertEquals(mock_estimator_deploy.call_args[1].get("role"), config_inference_role) + self.assertEqual(mock_estimator_deploy.call_args[1].get("role"), config_inference_role) assert "enable_network_isolation" not in mock_estimator_deploy.call_args[1] @@ -181,13 +181,13 @@ def test_without_arg_overwrites_with_kwarg_collisions_with_config( model_id=model_id, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 3) - self.assertEquals(mock_estimator_init.call_args[1].get("role"), config_role) - self.assertEquals( + self.assertEqual(mock_get_sagemaker_config_value.call_count, 3) + self.assertEqual(mock_estimator_init.call_args[1].get("role"), config_role) + self.assertEqual( mock_estimator_init.call_args[1].get("enable_network_isolation"), config_enable_network_isolation, ) - self.assertEquals( + self.assertEqual( mock_estimator_init.call_args[1].get("encrypt_inter_container_traffic"), config_intercontainer_encryption, ) @@ -200,11 +200,11 @@ def test_without_arg_overwrites_with_kwarg_collisions_with_config( estimator.deploy() - self.assertEquals(mock_get_sagemaker_config_value.call_count, 6) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 6) - self.assertEquals(mock_estimator_deploy.call_args[1].get("role"), config_inference_role) + self.assertEqual(mock_estimator_deploy.call_args[1].get("role"), config_inference_role) - self.assertEquals( + self.assertEqual( mock_estimator_deploy.call_args[1].get("enable_network_isolation"), config_inference_enable_network_isolation, ) @@ -257,13 +257,13 @@ def test_with_arg_overwrites_with_kwarg_collisions_with_config( encrypt_inter_container_traffic=override_encrypt_inter_container_traffic, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_estimator_init.call_args[1].get("role"), override_role) - self.assertEquals( + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_estimator_init.call_args[1].get("role"), override_role) + self.assertEqual( mock_estimator_init.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) - self.assertEquals( + self.assertEqual( mock_estimator_init.call_args[1].get("encrypt_inter_container_traffic"), override_encrypt_inter_container_traffic, ) @@ -280,13 +280,13 @@ def test_with_arg_overwrites_with_kwarg_collisions_with_config( enable_network_isolation=override_inference_enable_network_isolation, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 3) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 3) - self.assertEquals( + self.assertEqual( mock_estimator_deploy.call_args[1].get("role"), mock_inference_override_role ) - self.assertEquals( + self.assertEqual( mock_estimator_deploy.call_args[1].get("enable_network_isolation"), override_inference_enable_network_isolation, ) @@ -336,13 +336,13 @@ def test_with_arg_overwrites_without_kwarg_collisions_with_config( encrypt_inter_container_traffic=override_encrypt_inter_container_traffic, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_estimator_init.call_args[1].get("role"), override_role) - self.assertEquals( + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_estimator_init.call_args[1].get("role"), override_role) + self.assertEqual( mock_estimator_init.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) - self.assertEquals( + self.assertEqual( mock_estimator_init.call_args[1].get("encrypt_inter_container_traffic"), override_encrypt_inter_container_traffic, ) @@ -355,13 +355,13 @@ def test_with_arg_overwrites_without_kwarg_collisions_with_config( enable_network_isolation=override_inference_enable_network_isolation, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 3) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 3) - self.assertEquals( + self.assertEqual( mock_estimator_deploy.call_args[1].get("role"), mock_inference_override_role ) - self.assertEquals( + self.assertEqual( mock_estimator_deploy.call_args[1].get("enable_network_isolation"), override_inference_enable_network_isolation, ) @@ -412,8 +412,8 @@ def test_without_arg_overwrites_without_kwarg_collisions_without_config( model_id=model_id, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_estimator_init.call_args[1].get("role"), execution_role) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_estimator_init.call_args[1].get("role"), execution_role) assert "enable_network_isolation" not in mock_estimator_init.call_args[1] assert "encrypt_inter_container_traffic" not in mock_estimator_init.call_args[1] @@ -421,9 +421,9 @@ def test_without_arg_overwrites_without_kwarg_collisions_without_config( mock_retrieve_model_init_kwargs.return_value = {} - self.assertEquals(mock_get_sagemaker_config_value.call_count, 3) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 3) - self.assertEquals(mock_estimator_deploy.call_args[1].get("role"), execution_role) + self.assertEqual(mock_estimator_deploy.call_args[1].get("role"), execution_role) assert "enable_network_isolation" not in mock_estimator_deploy.call_args[1] @@ -475,13 +475,13 @@ def test_without_arg_overwrites_with_kwarg_collisions_without_config( model_id=model_id, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 3) - self.assertEquals(mock_estimator_init.call_args[1].get("role"), execution_role) - self.assertEquals( + self.assertEqual(mock_get_sagemaker_config_value.call_count, 3) + self.assertEqual(mock_estimator_init.call_args[1].get("role"), execution_role) + self.assertEqual( mock_estimator_init.call_args[1].get("enable_network_isolation"), metadata_enable_network_isolation, ) - self.assertEquals( + self.assertEqual( mock_estimator_init.call_args[1].get("encrypt_inter_container_traffic"), metadata_intercontainer_encryption, ) @@ -492,11 +492,11 @@ def test_without_arg_overwrites_with_kwarg_collisions_without_config( estimator.deploy() - self.assertEquals(mock_get_sagemaker_config_value.call_count, 6) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 6) - self.assertEquals(mock_estimator_deploy.call_args[1].get("role"), execution_role) + self.assertEqual(mock_estimator_deploy.call_args[1].get("role"), execution_role) - self.assertEquals( + self.assertEqual( mock_estimator_deploy.call_args[1].get("enable_network_isolation"), metadata_inference_enable_network_isolation, ) @@ -548,13 +548,13 @@ def test_with_arg_overwrites_with_kwarg_collisions_without_config( encrypt_inter_container_traffic=override_encrypt_inter_container_traffic, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_estimator_init.call_args[1].get("role"), override_role) - self.assertEquals( + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_estimator_init.call_args[1].get("role"), override_role) + self.assertEqual( mock_estimator_init.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) - self.assertEquals( + self.assertEqual( mock_estimator_init.call_args[1].get("encrypt_inter_container_traffic"), override_encrypt_inter_container_traffic, ) @@ -568,11 +568,11 @@ def test_with_arg_overwrites_with_kwarg_collisions_without_config( enable_network_isolation=override_inference_enable_network_isolation, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 3) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 3) - self.assertEquals(mock_estimator_deploy.call_args[1].get("role"), override_inference_role) + self.assertEqual(mock_estimator_deploy.call_args[1].get("role"), override_inference_role) - self.assertEquals( + self.assertEqual( mock_estimator_deploy.call_args[1].get("enable_network_isolation"), override_inference_enable_network_isolation, ) @@ -618,13 +618,13 @@ def test_with_arg_overwrites_without_kwarg_collisions_without_config( enable_network_isolation=override_enable_network_isolation, encrypt_inter_container_traffic=override_encrypt_inter_container_traffic, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_estimator_init.call_args[1].get("role"), override_role) - self.assertEquals( + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_estimator_init.call_args[1].get("role"), override_role) + self.assertEqual( mock_estimator_init.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) - self.assertEquals( + self.assertEqual( mock_estimator_init.call_args[1].get("encrypt_inter_container_traffic"), override_encrypt_inter_container_traffic, ) @@ -634,11 +634,11 @@ def test_with_arg_overwrites_without_kwarg_collisions_without_config( enable_network_isolation=override_enable_network_isolation, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 3) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 3) - self.assertEquals(mock_estimator_deploy.call_args[1].get("role"), override_inference_role) + self.assertEqual(mock_estimator_deploy.call_args[1].get("role"), override_inference_role) - self.assertEquals( + self.assertEqual( mock_estimator_deploy.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) diff --git a/tests/unit/sagemaker/jumpstart/model/test_sagemaker_config.py b/tests/unit/sagemaker/jumpstart/model/test_sagemaker_config.py index 2be4bde7e4..a0299ebb1a 100644 --- a/tests/unit/sagemaker/jumpstart/model/test_sagemaker_config.py +++ b/tests/unit/sagemaker/jumpstart/model/test_sagemaker_config.py @@ -99,9 +99,9 @@ def test_without_arg_overwrites_without_kwarg_collisions_with_config( model_id=model_id, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_model_init.call_args[1].get("role"), config_role) + self.assertEqual(mock_model_init.call_args[1].get("role"), config_role) assert "enable_network_isolation" not in mock_model_init.call_args[1] @@ -147,10 +147,10 @@ def test_all_arg_overwrites_without_kwarg_collisions_with_config( role=override_role, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_model_init.call_args[1].get("role"), override_role) - self.assertEquals( + self.assertEqual(mock_model_init.call_args[1].get("role"), override_role) + self.assertEqual( mock_model_init.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) @@ -197,10 +197,10 @@ def test_without_arg_overwrites_all_kwarg_collisions_with_config( model_id=model_id, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 2) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 2) - self.assertEquals(mock_model_init.call_args[1].get("role"), config_role) - self.assertEquals( + self.assertEqual(mock_model_init.call_args[1].get("role"), config_role) + self.assertEqual( mock_model_init.call_args[1].get("enable_network_isolation"), config_enable_network_isolation, ) @@ -249,10 +249,10 @@ def test_with_arg_overwrites_all_kwarg_collisions_with_config( enable_network_isolation=override_enable_network_isolation, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_model_init.call_args[1].get("role"), override_role) - self.assertEquals( + self.assertEqual(mock_model_init.call_args[1].get("role"), override_role) + self.assertEqual( mock_model_init.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) @@ -299,10 +299,10 @@ def test_without_arg_overwrites_all_kwarg_collisions_without_config( model_id=model_id, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 2) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 2) - self.assertEquals(mock_model_init.call_args[1].get("role"), execution_role) - self.assertEquals( + self.assertEqual(mock_model_init.call_args[1].get("role"), execution_role) + self.assertEqual( mock_model_init.call_args[1].get("enable_network_isolation"), metadata_enable_network_isolation, ) @@ -350,10 +350,10 @@ def test_with_arg_overwrites_all_kwarg_collisions_without_config( enable_network_isolation=override_enable_network_isolation, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_model_init.call_args[1].get("role"), override_role) - self.assertEquals( + self.assertEqual(mock_model_init.call_args[1].get("role"), override_role) + self.assertEqual( mock_model_init.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) @@ -398,9 +398,9 @@ def test_without_arg_overwrites_without_kwarg_collisions_without_config( model_id=model_id, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_model_init.call_args[1].get("role"), execution_role) + self.assertEqual(mock_model_init.call_args[1].get("role"), execution_role) assert "enable_network_isolation" not in mock_model_init.call_args[1] @mock.patch( @@ -445,10 +445,10 @@ def test_with_arg_overwrites_without_kwarg_collisions_without_config( enable_network_isolation=override_enable_network_isolation, ) - self.assertEquals(mock_get_sagemaker_config_value.call_count, 1) + self.assertEqual(mock_get_sagemaker_config_value.call_count, 1) - self.assertEquals(mock_model_init.call_args[1].get("role"), override_role) - self.assertEquals( + self.assertEqual(mock_model_init.call_args[1].get("role"), override_role) + self.assertEqual( mock_model_init.call_args[1].get("enable_network_isolation"), override_enable_network_isolation, ) diff --git a/tests/unit/sagemaker/jumpstart/test_utils.py b/tests/unit/sagemaker/jumpstart/test_utils.py index e3e3110da8..de9be1d51d 100644 --- a/tests/unit/sagemaker/jumpstart/test_utils.py +++ b/tests/unit/sagemaker/jumpstart/test_utils.py @@ -1388,7 +1388,7 @@ def test_no_model_id_no_version_found(self): mock_sagemaker_session.list_tags = mock_list_tags mock_list_tags.return_value = [{"Key": "blah", "Value": "blah1"}] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), (None, None, None, None), ) @@ -1403,7 +1403,7 @@ def test_model_id_no_version_found(self): {"Key": JumpStartTag.MODEL_ID, "Value": "model_id"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), ("model_id", None, None, None), ) @@ -1418,7 +1418,7 @@ def test_no_model_id_version_found(self): {"Key": JumpStartTag.MODEL_VERSION, "Value": "model_version"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), (None, "model_version", None, None), ) @@ -1430,7 +1430,7 @@ def test_no_config_name_found(self): mock_sagemaker_session.list_tags = mock_list_tags mock_list_tags.return_value = [{"Key": "blah", "Value": "blah1"}] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), (None, None, None, None), ) @@ -1445,7 +1445,7 @@ def test_inference_config_name_found(self): {"Key": JumpStartTag.INFERENCE_CONFIG_NAME, "Value": "config_name"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), (None, None, "config_name", None), ) @@ -1460,7 +1460,7 @@ def test_training_config_name_found(self): {"Key": JumpStartTag.TRAINING_CONFIG_NAME, "Value": "config_name"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), (None, None, None, "config_name"), ) @@ -1476,7 +1476,7 @@ def test_both_config_name_found(self): {"Key": JumpStartTag.TRAINING_CONFIG_NAME, "Value": "training_config_name"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), (None, None, "inference_config_name", "training_config_name"), ) @@ -1492,7 +1492,7 @@ def test_model_id_version_found(self): {"Key": JumpStartTag.MODEL_VERSION, "Value": "model_version"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), ("model_id", "model_version", None, None), ) @@ -1510,7 +1510,7 @@ def test_multiple_model_id_versions_found(self): {"Key": JumpStartTag.MODEL_VERSION, "Value": "model_version_2"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), (None, None, None, None), ) @@ -1528,7 +1528,7 @@ def test_multiple_model_id_versions_found_aliases_consistent(self): {"Key": random.choice(EXTRA_MODEL_VERSION_TAGS), "Value": "model_version_1"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), ("model_id_1", "model_version_1", None, None), ) @@ -1546,7 +1546,7 @@ def test_multiple_model_id_versions_found_aliases_inconsistent(self): {"Key": random.choice(EXTRA_MODEL_VERSION_TAGS), "Value": "model_version_2"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), (None, None, None, None), ) @@ -1564,7 +1564,7 @@ def test_multiple_config_names_found_aliases_inconsistent(self): {"Key": JumpStartTag.INFERENCE_CONFIG_NAME, "Value": "config_name_2"}, ] - self.assertEquals( + self.assertEqual( utils.get_jumpstart_model_info_from_resource_arn("some-arn", mock_sagemaker_session), ("model_id_1", "model_version_1", None, None), ) diff --git a/tests/unit/sagemaker/modules/train/test_model_trainer.py b/tests/unit/sagemaker/modules/train/test_model_trainer.py index 770420c354..bd8b54ae4a 100644 --- a/tests/unit/sagemaker/modules/train/test_model_trainer.py +++ b/tests/unit/sagemaker/modules/train/test_model_trainer.py @@ -1049,18 +1049,19 @@ def mock_upload_data(path, bucket, key_prefix): model_trainer.train() - assert mock_local_container.train.called_once_with( - training_job_name=unique_name, - instance_type=compute.instance_type, - instance_count=compute.instance_count, - image=training_image, - container_root=local_container_root, - sagemaker_session=modules_session, - container_entry_point=DEFAULT_ENTRYPOINT, - container_arguments=DEFAULT_ARGUMENTS, - hyper_parameters=hyperparameters, - environment=environment, - ) + mock_local_container.assert_called_once_with( + training_job_name=unique_name, + instance_type=compute.instance_type, + instance_count=compute.instance_count, + image=training_image, + container_root=local_container_root, + sagemaker_session=modules_session, + container_entrypoint=DEFAULT_ENTRYPOINT, + container_arguments=DEFAULT_ARGUMENTS, + input_data_config=ANY, + hyper_parameters=hyperparameters, + environment=environment, +) def test_safe_configs(): diff --git a/tests/unit/sagemaker/serve/model_server/djl_serving/test_djl_prepare.py b/tests/unit/sagemaker/serve/model_server/djl_serving/test_djl_prepare.py index 183d15d13e..aa99e1971c 100644 --- a/tests/unit/sagemaker/serve/model_server/djl_serving/test_djl_prepare.py +++ b/tests/unit/sagemaker/serve/model_server/djl_serving/test_djl_prepare.py @@ -52,8 +52,8 @@ def test_create_dir_structure_from_new(self, mock_path, mock_disk_usage, mock_di mock_disk_space.assert_called_once_with(mock_model_path) mock_disk_usage.assert_called_once() - self.assertEquals(ret_model_path, mock_model_path) - self.assertEquals(ret_code_dir, mock_code_dir) + self.assertEqual(ret_model_path, mock_model_path) + self.assertEqual(ret_code_dir, mock_code_dir) @patch("sagemaker.serve.model_server.djl_serving.prepare.Path") def test_create_dir_structure_invalid_path(self, mock_path): @@ -65,7 +65,7 @@ def test_create_dir_structure_invalid_path(self, mock_path): with self.assertRaises(ValueError) as context: _create_dir_structure(mock_model_path) - self.assertEquals("model_dir is not a valid directory", str(context.exception)) + self.assertEqual("model_dir is not a valid directory", str(context.exception)) @patch("sagemaker.serve.model_server.djl_serving.prepare.S3Downloader") @patch("builtins.open", new_callable=mock_open, read_data="data") diff --git a/tests/unit/sagemaker/serve/model_server/multi_model_server/test_multi_model_server_prepare.py b/tests/unit/sagemaker/serve/model_server/multi_model_server/test_multi_model_server_prepare.py index e877c1e7e9..567a72182a 100644 --- a/tests/unit/sagemaker/serve/model_server/multi_model_server/test_multi_model_server_prepare.py +++ b/tests/unit/sagemaker/serve/model_server/multi_model_server/test_multi_model_server_prepare.py @@ -91,8 +91,8 @@ def test_create_dir_structure_from_new(self, mock_path, mock_disk_usage, mock_di mock_disk_space.assert_called_once_with(mock_model_path) mock_disk_usage.assert_called_once() - self.assertEquals(ret_model_path, mock_model_path) - self.assertEquals(ret_code_dir, mock_code_dir) + self.assertEqual(ret_model_path, mock_model_path) + self.assertEqual(ret_code_dir, mock_code_dir) @patch("sagemaker.serve.model_server.multi_model_server.prepare.Path") def test_create_dir_structure_invalid_path(self, mock_path): @@ -104,4 +104,4 @@ def test_create_dir_structure_invalid_path(self, mock_path): with self.assertRaises(ValueError) as context: _create_dir_structure(mock_model_path) - self.assertEquals("model_dir is not a valid directory", str(context.exception)) + self.assertEqual("model_dir is not a valid directory", str(context.exception)) diff --git a/tests/unit/sagemaker/serve/model_server/tgi/test_tgi_prepare.py b/tests/unit/sagemaker/serve/model_server/tgi/test_tgi_prepare.py index 88d109831d..ed94f10ce9 100644 --- a/tests/unit/sagemaker/serve/model_server/tgi/test_tgi_prepare.py +++ b/tests/unit/sagemaker/serve/model_server/tgi/test_tgi_prepare.py @@ -50,8 +50,8 @@ def test_create_dir_structure_from_new(self, mock_path, mock_disk_usage, mock_di mock_disk_space.assert_called_once_with(mock_model_path) mock_disk_usage.assert_called_once() - self.assertEquals(ret_model_path, mock_model_path) - self.assertEquals(ret_code_dir, mock_code_dir) + self.assertEqual(ret_model_path, mock_model_path) + self.assertEqual(ret_code_dir, mock_code_dir) @patch("sagemaker.serve.model_server.tgi.prepare.Path") def test_create_dir_structure_invalid_path(self, mock_path): @@ -63,7 +63,7 @@ def test_create_dir_structure_invalid_path(self, mock_path): with self.assertRaises(ValueError) as context: _create_dir_structure(mock_model_path) - self.assertEquals("model_dir is not a valid directory", str(context.exception)) + self.assertEqual("model_dir is not a valid directory", str(context.exception)) @patch("sagemaker.serve.model_server.tgi.prepare.S3Downloader") @patch("builtins.open", read_data="data") diff --git a/tests/unit/sagemaker/workflow/test_pipeline.py b/tests/unit/sagemaker/workflow/test_pipeline.py index 14c2d442eb..94b1dce090 100644 --- a/tests/unit/sagemaker/workflow/test_pipeline.py +++ b/tests/unit/sagemaker/workflow/test_pipeline.py @@ -19,7 +19,7 @@ import pytest from mock import Mock, call, patch -from mock.mock import MagicMock +from mock.mock import MagicMock, ANY from sagemaker import s3 from sagemaker.remote_function.job import _JobSettings @@ -99,7 +99,7 @@ def test_pipeline_create_and_update_with_config_injection(sagemaker_session_mock RoleArn=pipeline_role_arn, ) pipeline.upsert() - assert sagemaker_session_mock.sagemaker_client.update_pipeline.called_with( + sagemaker_session_mock.sagemaker_client.update_pipeline.assert_called_with( PipelineName="MyPipeline", PipelineDefinition=pipeline.definition(), RoleArn=pipeline_role_arn, @@ -130,7 +130,7 @@ def test_pipeline_create_with_parallelism_config(sagemaker_session_mock, role_ar role_arn=role_arn, parallelism_config=dict(MaxParallelExecutionSteps=10), ) - assert sagemaker_session_mock.sagemaker_client.create_pipeline.called_with( + sagemaker_session_mock.sagemaker_client.create_pipeline.assert_called_with( PipelineName="MyPipeline", PipelineDefinition=pipeline.definition(), RoleArn=role_arn, @@ -149,7 +149,7 @@ def test_pipeline_create_and_start_with_parallelism_config(sagemaker_session_moc role_arn=role_arn, parallelism_config=dict(MaxParallelExecutionSteps=10), ) - assert sagemaker_session_mock.sagemaker_client.create_pipeline.called_with( + sagemaker_session_mock.sagemaker_client.create_pipeline.assert_called_with( PipelineName="MyPipeline", PipelineDefinition=pipeline.definition(), RoleArn=role_arn, @@ -168,7 +168,7 @@ def test_pipeline_create_and_start_with_parallelism_config(sagemaker_session_moc # Specify ParallelismConfiguration to another value which will be honored in backend pipeline.start(parallelism_config=dict(MaxParallelExecutionSteps=20)) - assert sagemaker_session_mock.sagemaker_client.start_pipeline_execution.called_with( + sagemaker_session_mock.sagemaker_client.start_pipeline_execution.assert_called_with( PipelineName="MyPipeline", ParallelismConfiguration={"MaxParallelExecutionSteps": 20}, ) @@ -209,7 +209,7 @@ def test_pipeline_update(sagemaker_session_mock, role_arn): assert not pipeline.steps pipeline.update(role_arn=role_arn) assert len(json.loads(pipeline.definition())["Steps"]) == 0 - assert sagemaker_session_mock.sagemaker_client.update_pipeline.called_with( + sagemaker_session_mock.sagemaker_client.update_pipeline.assert_called_with( PipelineName="MyPipeline", PipelineDefinition=pipeline.definition(), RoleArn=role_arn ) @@ -253,7 +253,7 @@ def test_pipeline_update(sagemaker_session_mock, role_arn): pipeline.update(role_arn=role_arn) assert len(json.loads(pipeline.definition())["Steps"]) == 3 - assert sagemaker_session_mock.sagemaker_client.update_pipeline.called_with( + sagemaker_session_mock.sagemaker_client.update_pipeline.assert_called_with( PipelineName="MyPipeline", PipelineDefinition=pipeline.definition(), RoleArn=role_arn ) @@ -345,7 +345,11 @@ def test_pipeline_update_with_parallelism_config(sagemaker_session_mock, role_ar role_arn=role_arn, parallelism_config=dict(MaxParallelExecutionSteps=10), ) - assert sagemaker_session_mock.sagemaker_client.update_pipeline.called_with( + pipeline.update( + role_arn=role_arn, + parallelism_config={"MaxParallelExecutionSteps": 10}, + ) + sagemaker_session_mock.sagemaker_client.update_pipeline.assert_called_with( PipelineName="MyPipeline", PipelineDefinition=pipeline.definition(), RoleArn=role_arn, @@ -418,13 +422,13 @@ def _raise_does_already_exists_client_error(**kwargs): sagemaker_session_mock.sagemaker_client.update_pipeline.assert_called_once_with( PipelineName="MyPipeline", PipelineDefinition=pipeline.definition(), RoleArn=role_arn ) - assert sagemaker_session_mock.sagemaker_client.list_tags.called_with( - ResourceArn="mock_pipeline_arn" + sagemaker_session_mock.sagemaker_client.list_tags.assert_called_with( + ResourceArn="pipeline-arn" ) tags.append({"Key": "dummy", "Value": "dummy_tag"}) - assert sagemaker_session_mock.sagemaker_client.add_tags.called_with( - ResourceArn="mock_pipeline_arn", Tags=tags + sagemaker_session_mock.sagemaker_client.add_tags.assert_called_with( + ResourceArn="pipeline-arn", Tags=tags ) @@ -523,7 +527,7 @@ def test_pipeline_delete(sagemaker_session_mock): sagemaker_session=sagemaker_session_mock, ) pipeline.delete() - assert sagemaker_session_mock.sagemaker_client.delete_pipeline.called_with( + sagemaker_session_mock.sagemaker_client.delete_pipeline.assert_called_with( PipelineName="MyPipeline", ) @@ -536,7 +540,7 @@ def test_pipeline_describe(sagemaker_session_mock): sagemaker_session=sagemaker_session_mock, ) pipeline.describe() - assert sagemaker_session_mock.sagemaker_client.describe_pipeline.called_with( + sagemaker_session_mock.sagemaker_client.describe_pipeline.assert_called_with( PipelineName="MyPipeline", ) @@ -552,17 +556,17 @@ def test_pipeline_start(sagemaker_session_mock): sagemaker_session=sagemaker_session_mock, ) pipeline.start() - assert sagemaker_session_mock.start_pipeline_execution.called_with( + sagemaker_session_mock.sagemaker_client.start_pipeline_execution.assert_called_with( PipelineName="MyPipeline", ) pipeline.start(execution_display_name="pipeline-execution") - assert sagemaker_session_mock.start_pipeline_execution.called_with( + sagemaker_session_mock.sagemaker_client.start_pipeline_execution.assert_called_with( PipelineName="MyPipeline", PipelineExecutionDisplayName="pipeline-execution" ) pipeline.start(parameters=dict(alpha="epsilon")) - assert sagemaker_session_mock.start_pipeline_execution.called_with( + sagemaker_session_mock.sagemaker_client.start_pipeline_execution.assert_called_with( PipelineName="MyPipeline", PipelineParameters=[{"Name": "alpha", "Value": "epsilon"}] ) @@ -821,10 +825,8 @@ def test_pipeline_build_parameters_from_execution(sagemaker_session_mock): pipeline_execution_arn=reference_execution_arn, parameter_value_overrides=parameter_value_overrides, ) - assert ( - sagemaker_session_mock.sagemaker_client.list_pipeline_parameters_for_execution.called_with( - PipelineExecutionArn=reference_execution_arn - ) + sagemaker_session_mock.sagemaker_client.list_pipeline_parameters_for_execution.assert_called_with( + PipelineExecutionArn=reference_execution_arn ) assert len(parameters) == 1 assert parameters["TestParameterName"] == "NewParameterValue" @@ -850,10 +852,8 @@ def test_pipeline_build_parameters_from_execution_with_invalid_overrides(sagemak + f"are not present in the pipeline execution: {reference_execution_arn}" in str(error) ) - assert ( - sagemaker_session_mock.sagemaker_client.list_pipeline_parameters_for_execution.called_with( - PipelineExecutionArn=reference_execution_arn - ) + sagemaker_session_mock.sagemaker_client.list_pipeline_parameters_for_execution.assert_called_with( + PipelineExecutionArn=reference_execution_arn ) @@ -908,24 +908,23 @@ def test_pipeline_execution_basics(sagemaker_session_mock): ) execution = pipeline.start() execution.stop() - assert sagemaker_session_mock.sagemaker_client.stop_pipeline_execution.called_with( + sagemaker_session_mock.sagemaker_client.stop_pipeline_execution.assert_called_with( PipelineExecutionArn="my:arn" ) execution.describe() - assert sagemaker_session_mock.sagemaker_client.describe_pipeline_execution.called_with( + sagemaker_session_mock.sagemaker_client.describe_pipeline_execution.assert_called_with( PipelineExecutionArn="my:arn" ) steps = execution.list_steps() - assert sagemaker_session_mock.sagemaker_client.describe_pipeline_execution_steps.called_with( + sagemaker_session_mock.sagemaker_client.list_pipeline_execution_steps.assert_called_with( PipelineExecutionArn="my:arn" ) assert len(steps) == 1 list_parameters_response = execution.list_parameters() - assert ( - sagemaker_session_mock.sagemaker_client.list_pipeline_parameters_for_execution.called_with( - PipelineExecutionArn="my:arn" - ) + sagemaker_session_mock.sagemaker_client.list_pipeline_parameters_for_execution.assert_called_with( + PipelineExecutionArn="my:arn" ) + parameter_list = list_parameters_response["PipelineParameters"] assert len(parameter_list) == 1 assert parameter_list[0]["Name"] == "TestParameterName" diff --git a/tox.ini b/tox.ini index b16c0d2f0b..7fa611ed13 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ [tox] isolated_build = true -envlist = black-format,flake8,pylint,docstyle,sphinx,doc8,twine,py38,py39,py310,py311 +envlist = black-format,flake8,pylint,docstyle,sphinx,doc8,twine,py39,py310,py311,py312 skip_missing_interpreters = False @@ -67,7 +67,7 @@ markers = [testenv] setenv = PYTHONHASHSEED=42 -pip_version = pip==21.3 +pip_version = pip==24.3 passenv = AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY @@ -82,15 +82,15 @@ passenv = # Can be used to specify which tests to run, e.g.: tox -- -s commands = python -c "import os; os.system('install-custom-pkgs --install-boto-wheels')" - pip install 'apache-airflow==2.9.3' --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.9.3/constraints-3.8.txt" - pip install 'torch==2.0.1+cpu' -f 'https://download.pytorch.org/whl/torch_stable.html' - pip install 'torchvision==0.15.2+cpu' -f 'https://download.pytorch.org/whl/torch_stable.html' - pip install 'dill>=0.3.8' + pip install 'apache-airflow==2.10.4' --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.10.4/constraints-3.9.txt" + pip install 'torch==2.3.1+cpu' -f 'https://download.pytorch.org/whl/torch_stable.html' + pip install 'torchvision==0.18.1+cpu' -f 'https://download.pytorch.org/whl/torch_stable.html' + pip install 'dill>=0.3.9' pytest {posargs} deps = .[test] depends = - {py38,py39,py310,p311}: clean + {py39,py310,py311,py312}: clean [testenv:runcoverage] description = run unit tests with coverage @@ -132,7 +132,7 @@ commands = twine check dist/*.tar.gz [testenv:sphinx] -pip_version = pip==21.3 +pip_version = pip==24.3 changedir = doc # pip install requirements.txt is separate as RTD does it in separate steps # having the requirements.txt installed in deps above results in Double Requirement exception