1919from mock import Mock , patch
2020import pytest
2121
22- from sagemaker_inference import environment
22+ from sagemaker_inference import environment , model_server
2323from sagemaker_pytorch_serving_container import torchserve
24- from sagemaker_pytorch_serving_container .torchserve import TS_NAMESPACE , REQUIREMENTS_PATH
24+ from sagemaker_pytorch_serving_container .torchserve import TS_NAMESPACE
2525
2626PYTHON_PATH = "python_path"
2727DEFAULT_CONFIGURATION = "default_configuration"
3131@patch ("subprocess.Popen" )
3232@patch ("sagemaker_pytorch_serving_container.torchserve._retrieve_ts_server_process" )
3333@patch ("sagemaker_pytorch_serving_container.torchserve._add_sigterm_handler" )
34- @patch ("sagemaker_pytorch_serving_container.torchserve ._install_requirements" )
34+ @patch ("sagemaker_inference.model_server ._install_requirements" )
3535@patch ("os.path.exists" , return_value = True )
3636@patch ("sagemaker_pytorch_serving_container.torchserve._create_torchserve_config_file" )
3737@patch ("sagemaker_pytorch_serving_container.torchserve._set_python_path" )
@@ -72,7 +72,7 @@ def test_start_torchserve_default_service_handler(
7272@patch ("subprocess.Popen" )
7373@patch ("sagemaker_pytorch_serving_container.torchserve._retrieve_ts_server_process" )
7474@patch ("sagemaker_pytorch_serving_container.torchserve._add_sigterm_handler" )
75- @patch ("sagemaker_pytorch_serving_container.torchserve ._install_requirements" )
75+ @patch ("sagemaker_inference.model_server ._install_requirements" )
7676@patch ("os.path.exists" , return_value = True )
7777@patch ("sagemaker_pytorch_serving_container.torchserve._create_torchserve_config_file" )
7878@patch ("sagemaker_pytorch_serving_container.torchserve._set_python_path" )
@@ -92,7 +92,7 @@ def test_start_torchserve_default_service_handler_multi_model(
9292
9393 set_python_path .assert_called_once_with ()
9494 create_config .assert_called_once_with (torchserve .DEFAULT_HANDLER_SERVICE )
95- exists .assert_called_once_with (REQUIREMENTS_PATH )
95+ exists .assert_called_once_with (model_server . REQUIREMENTS_PATH )
9696 install_requirements .assert_called_once_with ()
9797
9898 ts_model_server_cmd = [
@@ -210,15 +210,15 @@ def test_add_sigterm_handler(signal_call):
210210
211211@patch ("subprocess.check_call" )
212212def test_install_requirements (check_call ):
213- torchserve ._install_requirements ()
213+ model_server ._install_requirements ()
214214 for i in ['pip' , 'install' , '-r' , '/opt/ml/model/code/requirements.txt' ]:
215215 assert i in check_call .call_args .args [0 ]
216216
217217
218218@patch ("subprocess.check_call" , side_effect = subprocess .CalledProcessError (0 , "cmd" ))
219219def test_install_requirements_installation_failed (check_call ):
220220 with pytest .raises (ValueError ) as e :
221- torchserve ._install_requirements ()
221+ model_server ._install_requirements ()
222222 assert "failed to install required packages" in str (e .value )
223223
224224
0 commit comments