@@ -39,20 +39,43 @@ def test_create_from_objects(model_run_with_model_run_data_rows,
3939
4040
4141def test_create_from_objects_all_project_labels (
42- model_run_with_model_run_all_project_data_rows , object_predictions ,
42+ model_run_with_all_project_labels , object_predictions ,
4343 annotation_import_test_helpers ):
4444 name = str (uuid .uuid4 ())
4545
46- annotation_import = model_run_with_model_run_all_project_data_rows .add_predictions (
46+ annotation_import = model_run_with_all_project_labels .add_predictions (
4747 name = name , predictions = object_predictions )
4848
49- assert annotation_import .model_run_id == model_run_with_model_run_all_project_data_rows .uid
49+ assert annotation_import .model_run_id == model_run_with_all_project_labels .uid
5050 annotation_import_test_helpers .check_running_state (annotation_import , name )
5151 annotation_import_test_helpers .assert_file_content (
5252 annotation_import .input_file_url , object_predictions )
5353 annotation_import .wait_until_done ()
5454
5555
56+ def test_model_run_project_labels (model_run_with_all_project_labels ,
57+ model_run_predictions ):
58+ model_run = model_run_with_all_project_labels
59+ model_run_exported_labels = model_run .export_labels (download = True )
60+ labels_indexed_by_schema_id = {}
61+ for label in model_run_exported_labels :
62+ # assuming exported array of label 'objects' has only one label per data row... as usually is when there are no label revisions
63+ schema_id = label ['Label' ]['objects' ][0 ]['schemaId' ]
64+ labels_indexed_by_schema_id [schema_id ] = label
65+
66+ assert (len (
67+ labels_indexed_by_schema_id .keys ())) == len (model_run_predictions )
68+
69+ # making sure the labels are in this model run are all labels uploaded to the project
70+ # by comparing some 'immutable' attributes
71+ for expected_label in model_run_predictions :
72+ schema_id = expected_label ['schemaId' ]
73+ actual_label = labels_indexed_by_schema_id [schema_id ]
74+ assert actual_label ['Label' ]['objects' ][0 ]['title' ] == expected_label [
75+ 'name' ]
76+ assert actual_label ['DataRow ID' ] == expected_label ['dataRow' ]['id' ]
77+
78+
5679def test_create_from_label_objects (model_run_with_model_run_data_rows ,
5780 object_predictions ,
5881 annotation_import_test_helpers ):
0 commit comments