File tree 2 files changed +28
-8
lines changed
tests/integ/sagemaker/lineage
2 files changed +28
-8
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
+ from tests .integ .sagemaker .lineage .helpers import retry
23
24
24
25
25
26
def test_create_delete (artifact_obj ):
@@ -103,14 +104,20 @@ def test_list_by_type(artifact_objs, sagemaker_session):
103
104
104
105
def test_downstream_trials (trial_associated_artifact , trial_obj , sagemaker_session ):
105
106
# 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
107
+ def validate ():
108
+ for i in range (3 ):
109
+ time .sleep (10 )
110
+ trials = trial_associated_artifact .downstream_trials (
111
+ sagemaker_session = sagemaker_session
112
+ )
113
+ logging .info (f"Found { len (trials )} downstream trials." )
114
+ if len (trials ) > 0 :
115
+ break
116
+
117
+ assert len (trials ) == 1
118
+ assert trial_obj .trial_name in trials
111
119
112
- assert len (trials ) == 1
113
- assert trial_obj .trial_name in trials
120
+ retry (validate , num_attempts = 3 )
114
121
115
122
116
123
@pytest .mark .timeout (30 )
You can’t perform that action at this time.
0 commit comments