3535def pytest_addoption (parser ):
3636 parser .addoption ("--boto-model-file" , action = "store" , default = None )
3737 parser .addoption ("--runslow" , action = "store_true" , default = False , help = "run slow tests" )
38+ parser .addoption ("--sagemaker-endpoint" , action = "store" , default = None )
3839
3940
4041def pytest_configure (config ):
@@ -56,12 +57,17 @@ def boto_model_file(request):
5657 return request .config .getoption ("--boto-model-file" )
5758
5859
60+ @pytest .fixture (scope = "session" )
61+ def sagemaker_endpoint (request ):
62+ return request .config .getoption ("--sagemaker-endpoint" )
63+
64+
5965@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 :
6468 return boto3 .client ("sagemaker" )
69+ else :
70+ return boto3 .client ("sagemaker" , endpoint_url = sagemaker_endpoint )
6571
6672
6773@pytest .fixture (scope = "session" )
@@ -280,7 +286,7 @@ def processing_job_name(sagemaker_boto_client, training_role_arn, docker_image):
280286
281287
282288@pytest .fixture (scope = "session" )
283- def docker_image (boto_model_file ):
289+ def docker_image (boto_model_file , sagemaker_endpoint ):
284290 client = docker .from_env ()
285291 ecr_client = boto3 .client ("ecr" )
286292 token = ecr_client .get_authorization_token ()
@@ -328,7 +334,7 @@ def docker_image(boto_model_file):
328334 "library" : "smexperiments-0.1.0.tar.gz" ,
329335 "botomodel" : "boto/sagemaker-experiments-2017-07-24.normal.json" ,
330336 "script" : "scripts/script.py" ,
331- "endpoint" : os . environ . get ( "SAGEMAKER_ENDPOINT" , "" ) ,
337+ "endpoint" : sagemaker_endpoint ,
332338 },
333339 )
334340 client .images .push (tag , auth_config = {"username" : username , "password" : password })
0 commit comments