|
28 | 28 | from tests.integ.sagemaker.serve.constants import ( |
29 | 29 | PYTORCH_SQUEEZENET_RESOURCE_DIR, |
30 | 30 | SERVE_SAGEMAKER_ENDPOINT_TIMEOUT, |
31 | | - SERVE_LOCAL_CONTAINER_TIMEOUT, |
32 | 31 | PYTHON_VERSION_IS_NOT_310, |
33 | 32 | ) |
34 | 33 | from tests.integ.timeout import timeout |
@@ -182,46 +181,46 @@ def model_builder(request): |
182 | 181 | # ), f"{caught_ex} was thrown when running pytorch squeezenet local container test" |
183 | 182 |
|
184 | 183 |
|
185 | | -# @pytest.mark.skipif( |
186 | | -# PYTHON_VERSION_IS_NOT_310, # or NOT_RUNNING_ON_INF_EXP_DEV_PIPELINE, |
187 | | -# reason="The goal of these test are to test the serving components of our feature", |
188 | | -# ) |
189 | | -# @pytest.mark.parametrize( |
190 | | -# "model_builder", ["model_builder_inference_spec_schema_builder"], indirect=True |
191 | | -# ) |
192 | | -# @pytest.mark.slow_test |
193 | | -# def test_happy_pytorch_sagemaker_endpoint( |
194 | | -# sagemaker_session, model_builder, cpu_instance_type, test_image |
195 | | -# ): |
196 | | -# logger.info("Running in SAGEMAKER_ENDPOINT mode...") |
197 | | -# caught_ex = None |
198 | | -# |
199 | | -# iam_client = sagemaker_session.boto_session.client("iam") |
200 | | -# role_arn = iam_client.get_role(RoleName=ROLE_NAME)["Role"]["Arn"] |
201 | | -# |
202 | | -# model = model_builder.build( |
203 | | -# mode=Mode.SAGEMAKER_ENDPOINT, role_arn=role_arn, sagemaker_session=sagemaker_session |
204 | | -# ) |
205 | | -# |
206 | | -# with timeout(minutes=SERVE_SAGEMAKER_ENDPOINT_TIMEOUT): |
207 | | -# try: |
208 | | -# logger.info("Deploying and predicting in SAGEMAKER_ENDPOINT mode...") |
209 | | -# predictor = model.deploy(instance_type=cpu_instance_type, initial_instance_count=1) |
210 | | -# logger.info("Endpoint successfully deployed.") |
211 | | -# predictor.predict(test_image) |
212 | | -# except Exception as e: |
213 | | -# caught_ex = e |
214 | | -# finally: |
215 | | -# cleanup_model_resources( |
216 | | -# sagemaker_session=model_builder.sagemaker_session, |
217 | | -# model_name=model.name, |
218 | | -# endpoint_name=model.endpoint_name, |
219 | | -# ) |
220 | | -# if caught_ex: |
221 | | -# logger.exception(caught_ex) |
222 | | -# assert ( |
223 | | -# False |
224 | | -# ), f"{caught_ex} was thrown when running pytorch squeezenet sagemaker endpoint test" |
| 184 | +@pytest.mark.skipif( |
| 185 | + PYTHON_VERSION_IS_NOT_310, # or NOT_RUNNING_ON_INF_EXP_DEV_PIPELINE, |
| 186 | + reason="The goal of these test are to test the serving components of our feature", |
| 187 | +) |
| 188 | +@pytest.mark.parametrize( |
| 189 | + "model_builder", ["model_builder_inference_spec_schema_builder"], indirect=True |
| 190 | +) |
| 191 | +@pytest.mark.slow_test |
| 192 | +def test_happy_pytorch_sagemaker_endpoint( |
| 193 | + sagemaker_session, model_builder, cpu_instance_type, test_image |
| 194 | +): |
| 195 | + logger.info("Running in SAGEMAKER_ENDPOINT mode...") |
| 196 | + caught_ex = None |
| 197 | + |
| 198 | + iam_client = sagemaker_session.boto_session.client("iam") |
| 199 | + role_arn = iam_client.get_role(RoleName=ROLE_NAME)["Role"]["Arn"] |
| 200 | + |
| 201 | + model = model_builder.build( |
| 202 | + mode=Mode.SAGEMAKER_ENDPOINT, role_arn=role_arn, sagemaker_session=sagemaker_session |
| 203 | + ) |
| 204 | + |
| 205 | + with timeout(minutes=SERVE_SAGEMAKER_ENDPOINT_TIMEOUT): |
| 206 | + try: |
| 207 | + logger.info("Deploying and predicting in SAGEMAKER_ENDPOINT mode...") |
| 208 | + predictor = model.deploy(instance_type=cpu_instance_type, initial_instance_count=1) |
| 209 | + logger.info("Endpoint successfully deployed.") |
| 210 | + predictor.predict(test_image) |
| 211 | + except Exception as e: |
| 212 | + caught_ex = e |
| 213 | + finally: |
| 214 | + cleanup_model_resources( |
| 215 | + sagemaker_session=model_builder.sagemaker_session, |
| 216 | + model_name=model.name, |
| 217 | + endpoint_name=model.endpoint_name, |
| 218 | + ) |
| 219 | + if caught_ex: |
| 220 | + logger.exception(caught_ex) |
| 221 | + assert ( |
| 222 | + False |
| 223 | + ), f"{caught_ex} was thrown when running pytorch squeezenet sagemaker endpoint test" |
225 | 224 |
|
226 | 225 |
|
227 | 226 | # @pytest.mark.skipif( |
|
0 commit comments