Skip to content

Commit 7104337

Browse files
Payton Staubmufaddal-rohawala
authored andcommitted
fix: Re-deploy static integ test endpoint if it is not found
1 parent c8ca3b7 commit 7104337

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

tests/integ/sagemaker/lineage/conftest.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
from tests.integ.sagemaker.lineage.helpers import name, names
3737

3838
SLEEP_TIME_SECONDS = 1
39-
STATIC_PIPELINE_NAME = "SdkIntegTestStaticPipeline14"
40-
STATIC_ENDPOINT_NAME = "SdkIntegTestStaticEndpoint14"
39+
STATIC_PIPELINE_NAME = "SdkIntegTestStaticPipeline15"
40+
STATIC_ENDPOINT_NAME = "SdkIntegTestStaticEndpoint15"
4141

4242

4343
@pytest.fixture
@@ -518,6 +518,13 @@ def _get_static_pipeline_execution_arn(sagemaker_session):
518518
def static_endpoint_context(sagemaker_session, static_pipeline_execution_arn):
519519
endpoint_arn = get_endpoint_arn_from_static_pipeline(sagemaker_session)
520520

521+
if endpoint_arn is None:
522+
_deploy_static_endpoint(
523+
execution_arn=static_pipeline_execution_arn,
524+
sagemaker_session=sagemaker_session,
525+
)
526+
endpoint_arn = get_endpoint_arn_from_static_pipeline(sagemaker_session)
527+
521528
contexts = sagemaker_session.sagemaker_client.list_contexts(SourceUri=endpoint_arn)[
522529
"ContextSummaries"
523530
]
@@ -584,11 +591,17 @@ def static_dataset_artifact(static_model_artifact, sagemaker_session):
584591

585592

586593
def get_endpoint_arn_from_static_pipeline(sagemaker_session):
587-
endpoint_arn = sagemaker_session.sagemaker_client.describe_endpoint(
588-
EndpointName=STATIC_ENDPOINT_NAME
589-
)["EndpointArn"]
594+
try:
595+
endpoint_arn = sagemaker_session.sagemaker_client.describe_endpoint(
596+
EndpointName=STATIC_ENDPOINT_NAME
597+
)["EndpointArn"]
590598

591-
return endpoint_arn
599+
return endpoint_arn
600+
except ClientError as e:
601+
error = e.response["Error"]
602+
if error["Code"] == "ValidationException":
603+
return None
604+
raise e
592605

593606

594607
def get_model_package_arn_from_static_pipeline(pipeline_execution_arn, sagemaker_session):
@@ -654,7 +667,7 @@ def _deploy_static_endpoint(execution_arn, sagemaker_session):
654667
sagemaker_session=sagemaker_session,
655668
)
656669
model_package.deploy(1, "ml.t2.medium", endpoint_name=STATIC_ENDPOINT_NAME)
657-
time.sleep(60)
670+
time.sleep(120)
658671
except ClientError as e:
659672
if e.response["Error"]["Code"] == "ValidationException":
660673
print(f"Endpoint {STATIC_ENDPOINT_NAME} already exists. Continuing.")

0 commit comments

Comments
 (0)