10
10
# distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
11
# ANY KIND, either express or implied. See the License for the specific
12
12
# language governing permissions and limitations under the License.
13
+ from __future__ import absolute_import
13
14
import os
14
15
import signal
15
16
import subprocess
@@ -86,11 +87,9 @@ def test_start_torchserve_default_service_handler_multi_model(
86
87
subprocess_popen ,
87
88
subprocess_call ,
88
89
):
89
- torchserve .ENABLE_MULTI_MODEL = True
90
+ torchserve .ENABLE_MULTI_MODEL = True
90
91
torchserve .start_torchserve ()
91
- torchserve .ENABLE_MULTI_MODEL = False
92
-
93
- #adapt.assert_called_once_with(torchserve.DEFAULT_HANDLER_SERVICE)
92
+ torchserve .ENABLE_MULTI_MODEL = False
94
93
create_config .assert_called_once_with ()
95
94
exists .assert_called_once_with (REQUIREMENTS_PATH )
96
95
install_requirements .assert_called_once_with ()
@@ -112,50 +111,6 @@ def test_start_torchserve_default_service_handler_multi_model(
112
111
sigterm .assert_called_once_with (retrieve .return_value )
113
112
114
113
115
- @patch ("subprocess.call" )
116
- @patch ("subprocess.Popen" )
117
- @patch ("sagemaker_pytorch_serving_container.torchserve._retrieve_ts_server_process" )
118
- @patch ("sagemaker_pytorch_serving_container.torchserve._add_sigterm_handler" )
119
- @patch ("sagemaker_pytorch_serving_container.torchserve._install_requirements" )
120
- @patch ("os.path.exists" , return_value = True )
121
- @patch ("sagemaker_pytorch_serving_container.torchserve._create_torchserve_config_file" )
122
- @patch ("sagemaker_pytorch_serving_container.torchserve._adapt_to_ts_format" )
123
- def test_start_torchserve_default_service_handler (
124
- adapt ,
125
- create_config ,
126
- exists ,
127
- install_requirements ,
128
- sigterm ,
129
- retrieve ,
130
- subprocess_popen ,
131
- subprocess_call ,
132
- ):
133
- torchserve .start_torchserve ()
134
-
135
- adapt .assert_called_once_with (torchserve .DEFAULT_HANDLER_SERVICE )
136
- create_config .assert_called_once_with ()
137
- exists .assert_called_once_with (REQUIREMENTS_PATH )
138
- install_requirements .assert_called_once_with ()
139
-
140
- ts_model_server_cmd = [
141
- "torchserve" ,
142
- "--start" ,
143
- "--model-store" ,
144
- torchserve .MODEL_STORE ,
145
- "--ts-config" ,
146
- torchserve .TS_CONFIG_FILE ,
147
- "--log-config" ,
148
- torchserve .DEFAULT_TS_LOG_FILE ,
149
- "--models" ,
150
- "model.mar"
151
- ]
152
-
153
- subprocess_popen .assert_called_once_with (ts_model_server_cmd )
154
- sigterm .assert_called_once_with (retrieve .return_value )
155
-
156
-
157
-
158
-
159
114
@patch ("subprocess.call" )
160
115
@patch ("subprocess.Popen" )
161
116
@patch ("sagemaker_pytorch_serving_container.torchserve._retrieve_ts_server_process" )
@@ -190,7 +145,6 @@ def test_adapt_to_ts_format(path_exists, make_dir, subprocess_check_call, set_py
190
145
torchserve .DEFAULT_TS_MODEL_NAME ,
191
146
"--handler" ,
192
147
handler_service ,
193
- #importlib.import_module(DEFAULT_TS_HANDLER_SERVICE).__file__,
194
148
"--serialized-file" ,
195
149
os .path .join (environment .model_dir , torchserve .DEFAULT_TS_MODEL_SERIALIZED_FILE ),
196
150
"--export-path" ,
@@ -288,15 +242,14 @@ def test_generate_ts_config_properties_default_workers(env, read_file):
288
242
assert workers not in ts_config_properties
289
243
290
244
291
-
292
245
@patch ("sagemaker_inference.utils.read_file" , return_value = DEFAULT_CONFIGURATION )
293
246
@patch ("sagemaker_inference.environment.Environment" )
294
247
def test_generate_ts_config_properties_multi_model (env , read_file ):
295
248
env .return_value .torchserve_workers = None
296
249
297
- torchserve .ENABLE_MULTI_MODEL = True
250
+ torchserve .ENABLE_MULTI_MODEL = True
298
251
ts_config_properties = torchserve ._generate_ts_config_properties ()
299
- torchserve .ENABLE_MULTI_MODEL = False
252
+ torchserve .ENABLE_MULTI_MODEL = False
300
253
301
254
workers = "default_workers_per_model={}" .format (None )
302
255
@@ -306,7 +259,6 @@ def test_generate_ts_config_properties_multi_model(env, read_file):
306
259
assert workers not in ts_config_properties
307
260
308
261
309
-
310
262
@patch ("signal.signal" )
311
263
def test_add_sigterm_handler (signal_call ):
312
264
ts = Mock ()
0 commit comments