35
35
def pytest_addoption (parser ):
36
36
parser .addoption ("--boto-model-file" , action = "store" , default = None )
37
37
parser .addoption ("--runslow" , action = "store_true" , default = False , help = "run slow tests" )
38
+ parser .addoption ("--sagemaker-endpoint" , action = "store" , default = None )
38
39
39
40
40
41
def pytest_configure (config ):
@@ -56,12 +57,17 @@ def boto_model_file(request):
56
57
return request .config .getoption ("--boto-model-file" )
57
58
58
59
60
+ @pytest .fixture (scope = "session" )
61
+ def sagemaker_endpoint (request ):
62
+ return request .config .getoption ("--sagemaker-endpoint" )
63
+
64
+
59
65
@pytest .fixture
60
- def sagemaker_boto_client ():
61
- if os .environ .get ("SAGEMAKER_ENDPOINT" , "" ).strip ():
62
- return boto3 .client ("sagemaker" , endpoint_url = os .environ .get ("SAGEMAKER_ENDPOINT" ))
63
- else :
66
+ def sagemaker_boto_client (sagemaker_endpoint ):
67
+ if sagemaker_endpoint is None :
64
68
return boto3 .client ("sagemaker" )
69
+ else :
70
+ return boto3 .client ("sagemaker" , endpoint_url = sagemaker_endpoint )
65
71
66
72
67
73
@pytest .fixture (scope = "session" )
@@ -280,7 +286,7 @@ def processing_job_name(sagemaker_boto_client, training_role_arn, docker_image):
280
286
281
287
282
288
@pytest .fixture (scope = "session" )
283
- def docker_image (boto_model_file ):
289
+ def docker_image (boto_model_file , sagemaker_endpoint ):
284
290
client = docker .from_env ()
285
291
ecr_client = boto3 .client ("ecr" )
286
292
token = ecr_client .get_authorization_token ()
@@ -328,7 +334,7 @@ def docker_image(boto_model_file):
328
334
"library" : "smexperiments-0.1.0.tar.gz" ,
329
335
"botomodel" : "boto/sagemaker-experiments-2017-07-24.normal.json" ,
330
336
"script" : "scripts/script.py" ,
331
- "endpoint" : os . environ . get ( "SAGEMAKER_ENDPOINT" , "" ) ,
337
+ "endpoint" : sagemaker_endpoint ,
332
338
},
333
339
)
334
340
client .images .push (tag , auth_config = {"username" : username , "password" : password })
0 commit comments