18
18
import boto3
19
19
import numpy
20
20
import pytest
21
- import tests .integ .local_mode_utils as local_mode_utils
21
+ import tempfile
22
+
23
+ import tests .integ .lock as lock
22
24
from tests .integ import DATA_DIR , PYTHON_VERSION
23
25
from tests .integ .timeout import timeout
24
26
25
27
from sagemaker .local import LocalSession , LocalSagemakerRuntimeClient , LocalSagemakerClient
26
28
from sagemaker .mxnet import MXNet
27
29
from sagemaker .tensorflow import TensorFlow
28
30
31
+ LOCK_PATH = os .path .join (tempfile .gettempdir (), 'sagemaker_test_local_mode_lock' )
29
32
DATA_PATH = os .path .join (DATA_DIR , 'iris' , 'data' )
30
33
DEFAULT_REGION = 'us-west-2'
31
34
@@ -101,7 +104,7 @@ def test_tf_local_mode(tf_full_version, sagemaker_local_session):
101
104
print ('job succeeded: {}' .format (estimator .latest_training_job .name ))
102
105
103
106
endpoint_name = estimator .latest_training_job .name
104
- with local_mode_utils .lock ():
107
+ with lock .lock (LOCK_PATH ):
105
108
try :
106
109
json_predictor = estimator .deploy (initial_instance_count = 1 ,
107
110
instance_type = 'local' ,
@@ -140,7 +143,7 @@ def test_tf_distributed_local_mode(sagemaker_local_session):
140
143
141
144
endpoint_name = estimator .latest_training_job .name
142
145
143
- with local_mode_utils .lock ():
146
+ with lock .lock (LOCK_PATH ):
144
147
try :
145
148
json_predictor = estimator .deploy (initial_instance_count = 1 ,
146
149
instance_type = 'local' ,
@@ -178,7 +181,7 @@ def test_tf_local_data(sagemaker_local_session):
178
181
print ('job succeeded: {}' .format (estimator .latest_training_job .name ))
179
182
180
183
endpoint_name = estimator .latest_training_job .name
181
- with local_mode_utils .lock ():
184
+ with lock .lock (LOCK_PATH ):
182
185
try :
183
186
json_predictor = estimator .deploy (initial_instance_count = 1 ,
184
187
instance_type = 'local' ,
@@ -217,7 +220,7 @@ def test_tf_local_data_local_script():
217
220
print ('job succeeded: {}' .format (estimator .latest_training_job .name ))
218
221
219
222
endpoint_name = estimator .latest_training_job .name
220
- with local_mode_utils .lock ():
223
+ with lock .lock (LOCK_PATH ):
221
224
try :
222
225
json_predictor = estimator .deploy (initial_instance_count = 1 ,
223
226
instance_type = 'local' ,
@@ -241,7 +244,7 @@ def test_local_mode_serving_from_s3_model(sagemaker_local_session, mxnet_model,
241
244
s3_model .sagemaker_session = sagemaker_local_session
242
245
243
246
predictor = None
244
- with local_mode_utils .lock ():
247
+ with lock .lock (LOCK_PATH ):
245
248
try :
246
249
predictor = s3_model .deploy (initial_instance_count = 1 , instance_type = 'local' )
247
250
data = numpy .zeros (shape = (1 , 1 , 28 , 28 ))
@@ -255,7 +258,7 @@ def test_local_mode_serving_from_s3_model(sagemaker_local_session, mxnet_model,
255
258
def test_local_mode_serving_from_local_model (tmpdir , sagemaker_local_session , mxnet_model ):
256
259
predictor = None
257
260
258
- with local_mode_utils .lock ():
261
+ with lock .lock (LOCK_PATH ):
259
262
try :
260
263
path = 'file://%s' % (str (tmpdir ))
261
264
model = mxnet_model (path )
@@ -285,7 +288,7 @@ def test_mxnet_local_mode(sagemaker_local_session, mxnet_full_version):
285
288
mx .fit ({'train' : train_input , 'test' : test_input })
286
289
endpoint_name = mx .latest_training_job .name
287
290
288
- with local_mode_utils .lock ():
291
+ with lock .lock (LOCK_PATH ):
289
292
try :
290
293
predictor = mx .deploy (1 , 'local' , endpoint_name = endpoint_name )
291
294
data = numpy .zeros (shape = (1 , 1 , 28 , 28 ))
@@ -310,7 +313,7 @@ def test_mxnet_local_data_local_script(mxnet_full_version):
310
313
mx .fit ({'train' : train_input , 'test' : test_input })
311
314
endpoint_name = mx .latest_training_job .name
312
315
313
- with local_mode_utils .lock ():
316
+ with lock .lock (LOCK_PATH ):
314
317
try :
315
318
predictor = mx .deploy (1 , 'local' , endpoint_name = endpoint_name )
316
319
data = numpy .zeros (shape = (1 , 1 , 28 , 28 ))
@@ -365,7 +368,7 @@ def test_local_transform_mxnet(sagemaker_local_session, tmpdir, mxnet_full_versi
365
368
transformer = mx .transformer (1 , 'local' , assemble_with = 'Line' , max_payload = 1 ,
366
369
strategy = 'SingleRecord' , output_path = output_path )
367
370
368
- with local_mode_utils .lock ():
371
+ with lock .lock (LOCK_PATH ):
369
372
transformer .transform (transform_input , content_type = 'text/csv' , split_type = 'Line' )
370
373
transformer .wait ()
371
374
0 commit comments