Skip to content

change: retry downstream_trials test #2712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/integ/sagemaker/lineage/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import uuid
from datetime import datetime
import time


def name():
Expand All @@ -30,3 +31,16 @@ def names():
)
for i in range(3)
]


def retry(callable, num_attempts=8):
assert num_attempts >= 1
for i in range(num_attempts):
try:
return callable()
except Exception as ex:
if i == num_attempts - 1:
raise ex
print("Retrying", ex)
time.sleep(2 ** i)
assert False, "logic error in retry"
21 changes: 14 additions & 7 deletions tests/integ/sagemaker/lineage/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pytest

from sagemaker.lineage import artifact
from tests.integ.sagemaker.lineage.helpers import retry


def test_create_delete(artifact_obj):
Expand Down Expand Up @@ -103,14 +104,20 @@ def test_list_by_type(artifact_objs, sagemaker_session):

def test_downstream_trials(trial_associated_artifact, trial_obj, sagemaker_session):
# allow trial components to index, 30 seconds max
for i in range(3):
time.sleep(10)
trials = trial_associated_artifact.downstream_trials(sagemaker_session=sagemaker_session)
if len(trials) > 0:
break
def validate():
for i in range(3):
time.sleep(10)
trials = trial_associated_artifact.downstream_trials(
sagemaker_session=sagemaker_session
)
logging.info(f"Found {len(trials)} downstream trials.")
if len(trials) > 0:
break

assert len(trials) == 1
assert trial_obj.trial_name in trials

assert len(trials) == 1
assert trial_obj.trial_name in trials
retry(validate, num_attempts=3)


@pytest.mark.timeout(30)
Expand Down