|
1 |
| -# Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 1 | +# Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
2 | 2 | #
|
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You
|
4 | 4 | # may not use this file except in compliance with the License. A copy of
|
|
14 | 14 |
|
15 | 15 | import json
|
16 | 16 | import os
|
17 |
| -import time |
18 | 17 |
|
19 | 18 | import pytest
|
20 | 19 | from tests.integ import DATA_DIR, TRANSFORM_DEFAULT_TIMEOUT_MINUTES
|
|
30 | 29 | from sagemaker.predictor import RealTimePredictor, json_serializer
|
31 | 30 | from sagemaker.sparkml.model import SparkMLModel
|
32 | 31 | from sagemaker.utils import sagemaker_timestamp
|
| 32 | +from tests.integ.retry import retries |
33 | 33 |
|
34 | 34 | SPARKML_DATA_PATH = os.path.join(DATA_DIR, "sparkml_model")
|
35 | 35 | XGBOOST_DATA_PATH = os.path.join(DATA_DIR, "xgboost_model")
|
@@ -190,16 +190,11 @@ def test_inference_pipeline_model_deploy_with_update_endpoint(
|
190 | 190 | model.deploy(1, cpu_instance_type, update_endpoint=True, endpoint_name=endpoint_name)
|
191 | 191 |
|
192 | 192 | # Wait for endpoint to finish updating
|
193 |
| - max_retry_count = 40 # Endpoint update takes ~7min. 40 retries * 30s sleeps = 20min timeout |
194 |
| - current_retry_count = 0 |
195 |
| - while current_retry_count <= max_retry_count: |
196 |
| - if current_retry_count >= max_retry_count: |
197 |
| - raise Exception("Endpoint status not 'InService' within expected timeout.") |
198 |
| - time.sleep(30) |
| 193 | + # Endpoint update takes ~7min. 40 retries * 30s sleeps = 20min timeout |
| 194 | + for _ in retries(40, "Waiting for 'InService' endpoint status", seconds_to_sleep=30): |
199 | 195 | new_endpoint = sagemaker_session.sagemaker_client.describe_endpoint(
|
200 | 196 | EndpointName=endpoint_name
|
201 | 197 | )
|
202 |
| - current_retry_count += 1 |
203 | 198 | if new_endpoint["EndpointStatus"] == "InService":
|
204 | 199 | break
|
205 | 200 |
|
|
0 commit comments