6565]
6666
6767
68- def test_import_data_types_by_global_key (client , configured_project ,
69- initial_dataset , rand_gen ,
70- data_row_json_by_data_type ,
71- annotations_by_data_type ,
72- create_data_row_for_project ):
68+ def create_data_row_for_project (project , dataset , data_row_ndjson , batch_name ):
69+ data_row = dataset .create_data_row (data_row_ndjson )
70+
71+ project .create_batch (
72+ batch_name ,
73+ [data_row .uid ], # sample of data row objects
74+ 5 , # priority between 1(Highest) - 5(lowest)
75+ )
76+ project .data_row_ids .append (data_row .uid )
77+
78+ return data_row
79+
80+
81+ def test_import_data_types_by_global_key (
82+ client ,
83+ configured_project ,
84+ initial_dataset ,
85+ rand_gen ,
86+ data_row_json_by_data_type ,
87+ annotations_by_data_type ,
88+ export_v2_test_helpers ,
89+ ):
7390 project = configured_project
7491 project_id = project .uid
7592 dataset = initial_dataset
@@ -93,17 +110,27 @@ def test_import_data_types_by_global_key(client, configured_project,
93110 ) for annotations in annotations_list
94111 ]
95112
113+ def find_data_row (dr ):
114+ return dr ['data_row' ]['id' ] == data_row .uid
115+
96116 label_import = lb .LabelImport .create_from_objects (client , project_id ,
97117 f"test-import-image" ,
98118 labels )
99119 label_import .wait_until_done ()
100120
101121 assert label_import .state == AnnotationImportState .FINISHED
102122 assert len (label_import .errors ) == 0
103- exported_labels = project .export_labels (download = True )
104- objects = exported_labels [0 ]["Label" ]["objects" ]
105- classifications = exported_labels [0 ]["Label" ]["classifications" ]
123+
124+ result = export_v2_test_helpers .run_project_export_v2_task (project )
125+ exported_data = list (filter (find_data_row , result ))[0 ]
126+ assert exported_data
127+
128+ label = exported_data ['projects' ][project .uid ]['labels' ][0 ]
129+ annotations = label ['annotations' ]
130+ objects = annotations ['objects' ]
131+ classifications = annotations ['classifications' ]
106132 assert len (objects ) + len (classifications ) == len (labels )
133+
107134 data_row .delete ()
108135
109136
@@ -151,11 +178,18 @@ def set_project_media_type_from_data_type(project, data_type_class):
151178 LlmResponseCreationData ,
152179 ],
153180)
154- def test_import_data_types_v2 (client , configured_project , initial_dataset ,
155- data_row_json_by_data_type ,
156- annotations_by_data_type_v2 , data_type_class ,
157- exports_v2_by_data_type , export_v2_test_helpers ,
158- rand_gen , helpers , create_data_row_for_project ):
181+ def test_import_data_types_v2 (
182+ client ,
183+ configured_project ,
184+ initial_dataset ,
185+ data_row_json_by_data_type ,
186+ annotations_by_data_type_v2 ,
187+ data_type_class ,
188+ exports_v2_by_data_type ,
189+ export_v2_test_helpers ,
190+ rand_gen ,
191+ helpers ,
192+ ):
159193 project = configured_project
160194 dataset = initial_dataset
161195 project_id = project .uid
0 commit comments