@@ -119,49 +119,6 @@ def get_invites(client):
119119 return invites
120120
121121
122- def wait_for_data_row_processing (client , data_row ):
123- """
124- Do not use. Only for testing.
125-
126- Returns DataRow after waiting for it to finish processing media_attributes.
127- Some tests, specifically ones that rely on label export, rely on
128- DataRow be fully processed with media_attributes
129- """
130- data_row_id = data_row .uid
131- timeout_seconds = 60
132- while True :
133- data_row = client .get_data_row (data_row_id )
134- if data_row .media_attributes :
135- return data_row
136- timeout_seconds -= 2
137- if timeout_seconds <= 0 :
138- raise TimeoutError (
139- f"Timed out waiting for DataRow '{ data_row_id } ' to finish processing media_attributes"
140- )
141- time .sleep (2 )
142-
143-
144- def wait_for_label_processing (project ):
145- """
146- Do not use. Only for testing.
147-
148- Returns Label after waiting for it to finish processing.
149- If `project.labels()` is called before label is fully processed,
150- it may return an empty set
151- """
152- timeout_seconds = 10
153- while True :
154- label = project .labels ().get_one ()
155- if label is not None :
156- return label
157- timeout_seconds -= 2
158- if timeout_seconds <= 0 :
159- raise TimeoutError (
160- f"Timed out waiting for label for project '{ project .uid } ' to finish processing"
161- )
162- time .sleep (2 )
163-
164-
165122@pytest .fixture
166123def queries ():
167124 return SimpleNamespace (cancel_invite = cancel_invite ,
@@ -347,7 +304,7 @@ def configured_project(project, client, rand_gen, image_url):
347304
348305@pytest .fixture
349306def configured_project_with_label (client , rand_gen , image_url , project , dataset ,
350- datarow ):
307+ datarow , wait_for_label_processing ):
351308 """Project with a connected dataset, having one datarow
352309 Project contains an ontology with 1 bbox tool
353310 Additionally includes a create_label method for any needed extra labels
@@ -450,3 +407,58 @@ def configured_project_with_complex_ontology(client, rand_gen, image_url):
450407 yield [project , data_row ]
451408 dataset .delete ()
452409 project .delete ()
410+
411+
412+ @pytest .fixture
413+ def wait_for_data_row_processing ():
414+ """
415+ Do not use. Only for testing.
416+
417+ Returns DataRow after waiting for it to finish processing media_attributes.
418+ Some tests, specifically ones that rely on label export, rely on
419+ DataRow be fully processed with media_attributes
420+ """
421+
422+ def func (client , data_row ):
423+ data_row_id = data_row .uid
424+ timeout_seconds = 60
425+ while True :
426+ data_row = client .get_data_row (data_row_id )
427+ print (f"dr { data_row } " )
428+ if data_row .media_attributes :
429+ return data_row
430+ timeout_seconds -= 2
431+ if timeout_seconds <= 0 :
432+ raise TimeoutError (
433+ f"Timed out waiting for DataRow '{ data_row_id } ' to finish processing media_attributes"
434+ )
435+ time .sleep (2 )
436+
437+ return func
438+
439+
440+ @pytest .fixture
441+ def wait_for_label_processing ():
442+ """
443+ Do not use. Only for testing.
444+
445+ Returns Label after waiting for it to finish processing.
446+ If `project.labels()` is called before label is fully processed,
447+ it may return an empty set
448+ """
449+
450+ def func (project ):
451+ timeout_seconds = 10
452+ while True :
453+ label = project .labels ().get_one ()
454+ print (f"LABEL: { label } " )
455+ if label is not None :
456+ return label
457+ timeout_seconds -= 2
458+ if timeout_seconds <= 0 :
459+ raise TimeoutError (
460+ f"Timed out waiting for label for project '{ project .uid } ' to finish processing"
461+ )
462+ time .sleep (2 )
463+
464+ return func
0 commit comments