File tree Expand file tree Collapse file tree 2 files changed +27
-10
lines changed
tests/integ/sagemaker/lineage Expand file tree Collapse file tree 2 files changed +27
-10
lines changed Original file line number Diff line number Diff line change 15
15
16
16
import uuid
17
17
from datetime import datetime
18
-
18
+ from contextlib import contextmanager
19
+ import time
19
20
20
21
def name ():
21
22
return "lineage-integ-{}-{}" .format (
@@ -30,3 +31,15 @@ def names():
30
31
)
31
32
for i in range (3 )
32
33
]
34
+
35
+ def retry (callable , num_attempts = 8 ):
36
+ assert num_attempts >= 1
37
+ for i in range (num_attempts ):
38
+ try :
39
+ return callable ()
40
+ except Exception as ex :
41
+ if i == num_attempts - 1 :
42
+ raise ex
43
+ print ("Retrying" , ex )
44
+ time .sleep (2 ** i )
45
+ assert False , "logic error in retry"
Original file line number Diff line number Diff line change 20
20
import pytest
21
21
22
22
from sagemaker .lineage import artifact
23
-
23
+ from tests . integ . sagemaker . lineage . helpers import retry
24
24
25
25
def test_create_delete (artifact_obj ):
26
26
# fixture does create and then delete, this test ensures it happens at least once
@@ -103,14 +103,18 @@ def test_list_by_type(artifact_objs, sagemaker_session):
103
103
104
104
def test_downstream_trials (trial_associated_artifact , trial_obj , sagemaker_session ):
105
105
# allow trial components to index, 30 seconds max
106
- for i in range (3 ):
107
- time .sleep (10 )
108
- trials = trial_associated_artifact .downstream_trials (sagemaker_session = sagemaker_session )
109
- if len (trials ) > 0 :
110
- break
111
-
112
- assert len (trials ) == 1
113
- assert trial_obj .trial_name in trials
106
+ def validate ():
107
+ for i in range (3 ):
108
+ time .sleep (10 )
109
+ trials = trial_associated_artifact .downstream_trials (sagemaker_session = sagemaker_session )
110
+ logging .info (f'Found { len (trials )} downstream trials.' )
111
+ if len (trials ) > 0 :
112
+ break
113
+
114
+ assert len (trials ) == 1
115
+ assert trial_obj .trial_name in trials
116
+
117
+ retry (validate , num_attempts = 3 )
114
118
115
119
116
120
@pytest .mark .timeout (30 )
You can’t perform that action at this time.
0 commit comments