1818from sagemaker import Session
1919from sagemaker .tensorflow import TensorFlow
2020from tests .integ import DATA_DIR , REGION
21- from tests .integ .timeout import timeout_and_delete_endpoint , timeout
21+ from tests .integ .timeout import timeout_and_delete_endpoint_by_name , timeout
2222
2323DATA_PATH = os .path .join (DATA_DIR , 'iris' , 'data' )
2424
@@ -43,12 +43,14 @@ def test_tf(sagemaker_session, tf_full_version):
4343 sagemaker_session = sagemaker_session ,
4444 base_job_name = 'test-tf' )
4545
46- inputs = estimator . sagemaker_session .upload_data (path = DATA_PATH , key_prefix = 'integ-test-data/tf_iris' )
46+ inputs = sagemaker_session .upload_data (path = DATA_PATH , key_prefix = 'integ-test-data/tf_iris' )
4747 estimator .fit (inputs )
4848 print ('job succeeded: {}' .format (estimator .latest_training_job .name ))
4949
50- with timeout_and_delete_endpoint (estimator = estimator , minutes = 20 ):
51- json_predictor = estimator .deploy (initial_instance_count = 1 , instance_type = 'ml.c4.xlarge' )
50+ endpoint_name = estimator .latest_training_job .name
51+ with timeout_and_delete_endpoint_by_name (endpoint_name , sagemaker_session , minutes = 20 ):
52+ json_predictor = estimator .deploy (initial_instance_count = 1 , instance_type = 'ml.c4.xlarge' ,
53+ endpoint_name = endpoint_name )
5254
5355 features = [6.4 , 3.2 , 4.5 , 1.5 ]
5456 dict_result = json_predictor .predict ({'inputs' : features })
@@ -81,9 +83,11 @@ def test_tf_async(sagemaker_session, tf_full_version):
8183 training_job_name = estimator .latest_training_job .name
8284 time .sleep (20 )
8385
84- with timeout_and_delete_endpoint (estimator = estimator , minutes = 35 ):
86+ endpoint_name = training_job_name
87+ with timeout_and_delete_endpoint_by_name (endpoint_name , sagemaker_session , minutes = 35 ):
8588 estimator = TensorFlow .attach (training_job_name = training_job_name , sagemaker_session = sagemaker_session )
86- json_predictor = estimator .deploy (initial_instance_count = 1 , instance_type = 'ml.c4.xlarge' )
89+ json_predictor = estimator .deploy (initial_instance_count = 1 , instance_type = 'ml.c4.xlarge' ,
90+ endpoint_name = endpoint_name )
8791
8892 result = json_predictor .predict ([6.4 , 3.2 , 4.5 , 1.5 ])
8993 print ('predict result: {}' .format (result ))
0 commit comments