25
25
"""
26
26
27
27
28
- def test_create_from_url (configured_project ):
28
+ def test_create_from_url (project ):
29
29
name = str (uuid .uuid4 ())
30
30
url = "https://storage.googleapis.com/labelbox-public-bucket/predictions_test_v2.ndjson"
31
31
32
- bulk_import_request = configured_project .upload_annotations (name = name ,
33
- annotations = url ,
34
- validate = False )
32
+ bulk_import_request = project .upload_annotations (name = name ,
33
+ annotations = url ,
34
+ validate = False )
35
35
36
- assert bulk_import_request .project () == configured_project
36
+ assert bulk_import_request .project () == project
37
37
assert bulk_import_request .name == name
38
38
assert bulk_import_request .input_file_url == url
39
39
assert bulk_import_request .error_file_url is None
40
40
assert bulk_import_request .status_file_url is None
41
41
assert bulk_import_request .state == BulkImportRequestState .RUNNING
42
42
43
43
44
- def test_validate_file (configured_project ):
44
+ def test_validate_file (project_with_empty_ontology ):
45
45
name = str (uuid .uuid4 ())
46
46
url = "https://storage.googleapis.com/labelbox-public-bucket/predictions_test_v2.ndjson"
47
47
with pytest .raises (MALValidationError ):
48
- configured_project .upload_annotations (name = name ,
49
- annotations = url ,
50
- validate = True )
48
+ project_with_empty_ontology .upload_annotations (name = name ,
49
+ annotations = url ,
50
+ validate = True )
51
51
#Schema ids shouldn't match
52
52
53
53
54
- def test_create_from_objects (configured_project , predictions ,
54
+ def test_create_from_objects (configured_project_with_one_data_row , predictions ,
55
55
annotation_import_test_helpers ):
56
56
name = str (uuid .uuid4 ())
57
57
58
- bulk_import_request = configured_project .upload_annotations (
58
+ bulk_import_request = configured_project_with_one_data_row .upload_annotations (
59
59
name = name , annotations = predictions )
60
60
61
- assert bulk_import_request .project () == configured_project
61
+ assert bulk_import_request .project () == configured_project_with_one_data_row
62
62
assert bulk_import_request .name == name
63
63
assert bulk_import_request .error_file_url is None
64
64
assert bulk_import_request .status_file_url is None
@@ -105,34 +105,33 @@ def test_create_from_local_file(tmp_path, predictions, configured_project,
105
105
bulk_import_request .input_file_url , predictions )
106
106
107
107
108
- def test_get (client , configured_project ):
108
+ def test_get (client , configured_project_with_one_data_row ):
109
109
name = str (uuid .uuid4 ())
110
110
url = "https://storage.googleapis.com/labelbox-public-bucket/predictions_test_v2.ndjson"
111
- configured_project .upload_annotations (name = name ,
112
- annotations = url ,
113
- validate = False )
111
+ configured_project_with_one_data_row .upload_annotations (name = name ,
112
+ annotations = url ,
113
+ validate = False )
114
114
115
115
bulk_import_request = BulkImportRequest .from_name (
116
- client , project_id = configured_project .uid , name = name )
116
+ client , project_id = configured_project_with_one_data_row .uid , name = name )
117
117
118
- assert bulk_import_request .project () == configured_project
118
+ assert bulk_import_request .project () == configured_project_with_one_data_row
119
119
assert bulk_import_request .name == name
120
120
assert bulk_import_request .input_file_url == url
121
121
assert bulk_import_request .error_file_url is None
122
122
assert bulk_import_request .status_file_url is None
123
123
assert bulk_import_request .state == BulkImportRequestState .RUNNING
124
124
125
125
126
- def test_validate_ndjson (tmp_path , configured_project ):
126
+ def test_validate_ndjson (tmp_path , configured_project_with_one_data_row ):
127
127
file_name = f"broken.ndjson"
128
128
file_path = tmp_path / file_name
129
129
with file_path .open ("w" ) as f :
130
130
f .write ("test" )
131
131
132
132
with pytest .raises (ValueError ):
133
- configured_project .upload_annotations (name = "name" ,
134
- validate = True ,
135
- annotations = str (file_path ))
133
+ configured_project_with_one_data_row .upload_annotations (
134
+ name = "name" , validate = True , annotations = str (file_path ))
136
135
137
136
138
137
def test_validate_ndjson_uuid (tmp_path , configured_project , predictions ):
@@ -158,14 +157,13 @@ def test_validate_ndjson_uuid(tmp_path, configured_project, predictions):
158
157
159
158
160
159
@pytest .mark .slow
161
- def test_wait_till_done (rectangle_inference , configured_project ):
160
+ def test_wait_till_done (rectangle_inference ,
161
+ configured_project_with_one_data_row ):
162
162
name = str (uuid .uuid4 ())
163
- url = configured_project .client .upload_data (content = parser .dumps (
164
- [rectangle_inference ]),
165
- sign = True )
166
- bulk_import_request = configured_project .upload_annotations (name = name ,
167
- annotations = url ,
168
- validate = False )
163
+ url = configured_project_with_one_data_row .client .upload_data (
164
+ content = parser .dumps ([rectangle_inference ]), sign = True )
165
+ bulk_import_request = configured_project_with_one_data_row .upload_annotations (
166
+ name = name , annotations = url , validate = False )
169
167
170
168
assert len (bulk_import_request .inputs ) == 1
171
169
bulk_import_request .wait_until_done ()
@@ -299,7 +297,7 @@ def test_pdf_mal_bbox(client, configured_project_pdf):
299
297
assert import_annotations .errors == []
300
298
301
299
302
- def test_pdf_document_entity (client , configured_project_without_data_rows ,
300
+ def test_pdf_document_entity (client , configured_project_with_one_data_row ,
303
301
dataset_pdf_entity , rand_gen ):
304
302
# for content "Metal-insulator (MI) transitions have been one of the" in OCR JSON extract tests/assets/arxiv-pdf_data_99-word-token-pdfs_0801.3483-lb-textlayer.json
305
303
document_text_selection = DocumentTextSelection (
@@ -323,7 +321,7 @@ def test_pdf_document_entity(client, configured_project_without_data_rows,
323
321
324
322
labels = []
325
323
_ , data_row_uids = dataset_pdf_entity
326
- configured_project_without_data_rows .create_batch (
324
+ configured_project_with_one_data_row .create_batch (
327
325
rand_gen (str ),
328
326
data_row_uids , # sample of data row objects
329
327
5 # priority between 1(Highest) - 5(lowest)
@@ -338,7 +336,7 @@ def test_pdf_document_entity(client, configured_project_without_data_rows,
338
336
339
337
import_annotations = MALPredictionImport .create_from_objects (
340
338
client = client ,
341
- project_id = configured_project_without_data_rows .uid ,
339
+ project_id = configured_project_with_one_data_row .uid ,
342
340
name = f"import { str (uuid .uuid4 ())} " ,
343
341
predictions = labels )
344
342
import_annotations .wait_until_done ()
@@ -347,14 +345,14 @@ def test_pdf_document_entity(client, configured_project_without_data_rows,
347
345
348
346
349
347
def test_nested_video_object_annotations (client ,
350
- configured_project_without_data_rows ,
348
+ configured_project_with_one_data_row ,
351
349
video_data ,
352
350
bbox_video_annotation_objects ,
353
351
rand_gen ):
354
352
labels = []
355
353
_ , data_row_uids = video_data
356
- configured_project_without_data_rows .update (media_type = MediaType .Video )
357
- configured_project_without_data_rows .create_batch (
354
+ configured_project_with_one_data_row .update (media_type = MediaType .Video )
355
+ configured_project_with_one_data_row .create_batch (
358
356
rand_gen (str ),
359
357
data_row_uids , # sample of data row objects
360
358
5 # priority between 1(Highest) - 5(lowest)
@@ -366,7 +364,7 @@ def test_nested_video_object_annotations(client,
366
364
annotations = bbox_video_annotation_objects ))
367
365
import_annotations = MALPredictionImport .create_from_objects (
368
366
client = client ,
369
- project_id = configured_project_without_data_rows .uid ,
367
+ project_id = configured_project_with_one_data_row .uid ,
370
368
name = f"import { str (uuid .uuid4 ())} " ,
371
369
predictions = labels )
372
370
import_annotations .wait_until_done ()
0 commit comments