diff --git a/darwin/importer/importer.py b/darwin/importer/importer.py index 118cae2bc..de7dade5b 100644 --- a/darwin/importer/importer.py +++ b/darwin/importer/importer.py @@ -2118,9 +2118,10 @@ def _display_slot_warnings_and_errors( If there are any warnings generated and the annotation format is not Darwin JSON 2.0 """ - # Warnings can only be generated by referring to slots, which is only supported by Darwin JSON + # Warnings can only be generated by referring to slots, which is only supported by the Darwin JSON & NiFTI formats # Therefore, stop imports of all other formats if there are any warnings - if (slot_errors or slot_warnings) and annotation_format != "darwin": + supported_formats = ["darwin", "nifti"] + if (slot_errors or slot_warnings) and annotation_format not in supported_formats: raise TypeError( "You are attempting to import annotations to multi-slotted or multi-channeled items using an annotation format that doesn't support them. To import annotations to multi-slotted or multi-channeled items, please use the Darwin JSON 2.0 format: https://docs.v7labs.com/reference/darwin-json" ) diff --git a/tests/darwin/importer/importer_test.py b/tests/darwin/importer/importer_test.py index ac4492ae8..8eb16cb67 100644 --- a/tests/darwin/importer/importer_test.py +++ b/tests/darwin/importer/importer_test.py @@ -2591,6 +2591,49 @@ def test_does_not_raise_error_for_darwin_format_with_warnings(): assert not slot_errors +def test_does_not_raise_error_for_nifti_format_with_warnings(): + bounding_box_class = dt.AnnotationClass( + name="class1", annotation_type="bounding_box" + ) + local_files = [ + dt.AnnotationFile( + path=Path("file1"), + remote_path="/", + filename="file1", + annotation_classes={bounding_box_class}, + annotations=[ + dt.Annotation( + annotation_class=bounding_box_class, + data={"x": 5, "y": 10, "w": 5, "h": 10}, + slot_names=[], + ), + dt.Annotation( + annotation_class=bounding_box_class, + data={"x": 15, "y": 20, "w": 15, "h": 20}, + slot_names=[], + ), + ], + ), + ] + remote_files = { + "/file1": { + "item_id": "123", + "slot_names": ["0", "1"], + "layout": {"type": "grid", "version": 1, "slots": ["0", "1"]}, + }, + } + + local_files, slot_errors, slot_warnings = _verify_slot_annotation_alignment( + local_files, + remote_files, + ) + + console = MagicMock() + _display_slot_warnings_and_errors(slot_errors, slot_warnings, "nifti", console) + + assert not slot_errors + + @patch("darwin.importer.importer._get_team_properties_annotation_lookup") @pytest.mark.parametrize("setup_data", ["section"], indirect=True) def test_import_existing_section_level_property_values_without_manifest(