|
7 | 7 | from labelbox import DataSplit, ModelRun |
8 | 8 |
|
9 | 9 |
|
10 | | -def _model_run_export_v2_results(model_run, task_name, params, num_retries=5): |
11 | | - """Export model run results and retry if no results are returned.""" |
12 | | - while (num_retries > 0): |
13 | | - task = model_run.export_v2(task_name, params=params) |
14 | | - assert task.name == task_name |
15 | | - task.wait_till_done() |
16 | | - assert task.status == "COMPLETE" |
17 | | - assert task.errors is None |
18 | | - task_results = task.result |
19 | | - if len(task_results) == 0: |
20 | | - num_retries -= 1 |
21 | | - time.sleep(5) |
22 | | - else: |
23 | | - return task_results |
24 | | - return [] |
25 | | - |
26 | | - |
27 | 10 | def test_model_run(client, configured_project_with_label, data_row, rand_gen): |
28 | 11 | project, _, _, label = configured_project_with_label |
29 | 12 | label_id = label.uid |
@@ -182,38 +165,6 @@ def get_model_run_status(): |
182 | 165 | errorMessage) |
183 | 166 |
|
184 | 167 |
|
185 | | -def test_model_run_export_v2(model_run_with_data_rows, configured_project): |
186 | | - task_name = "test_task" |
187 | | - media_attributes = True |
188 | | - params = {"media_attributes": media_attributes, "predictions": True} |
189 | | - task_results = _model_run_export_v2_results(model_run_with_data_rows, |
190 | | - task_name, params) |
191 | | - label_ids = [label.uid for label in configured_project.labels()] |
192 | | - label_ids_set = set(label_ids) |
193 | | - |
194 | | - assert len(task_results) == len(label_ids) |
195 | | - |
196 | | - for task_result in task_results: |
197 | | - # Check export param handling |
198 | | - if media_attributes: |
199 | | - assert 'media_attributes' in task_result and task_result[ |
200 | | - 'media_attributes'] is not None |
201 | | - else: |
202 | | - assert 'media_attributes' not in task_result or task_result[ |
203 | | - 'media_attributes'] is None |
204 | | - model_run = task_result['experiments'][ |
205 | | - model_run_with_data_rows.model_id]['runs'][ |
206 | | - model_run_with_data_rows.uid] |
207 | | - task_label_ids_set = set( |
208 | | - map(lambda label: label['id'], model_run['labels'])) |
209 | | - task_prediction_ids_set = set( |
210 | | - map(lambda prediction: prediction['id'], model_run['predictions'])) |
211 | | - for label_id in task_label_ids_set: |
212 | | - assert label_id in label_ids_set |
213 | | - for prediction_id in task_prediction_ids_set: |
214 | | - assert prediction_id in label_ids_set |
215 | | - |
216 | | - |
217 | 168 | def test_model_run_split_assignment_by_data_row_ids(model_run, dataset, |
218 | 169 | image_url): |
219 | 170 | n_data_rows = 10 |
|
0 commit comments