diff --git a/darwin/importer/importer.py b/darwin/importer/importer.py index f28c87db7..d56a3eedd 100644 --- a/darwin/importer/importer.py +++ b/darwin/importer/importer.py @@ -1518,6 +1518,9 @@ def _get_annotation_format( annotation_format : str The annotation format of the importer used to parse local files """ + # This `if` block is temporary, but necessary while we migrate NifTI imports between the legacy method & the new method + if isinstance(importer, partial): + return importer.func.__module__.split(".")[3] return importer.__module__.split(".")[3] diff --git a/tests/darwin/importer/importer_test.py b/tests/darwin/importer/importer_test.py index a290a0203..70cf197df 100644 --- a/tests/darwin/importer/importer_test.py +++ b/tests/darwin/importer/importer_test.py @@ -1,5 +1,6 @@ import json import tempfile +from functools import partial from pathlib import Path from typing import List, Tuple from unittest.mock import MagicMock, Mock, _patch, patch @@ -929,6 +930,12 @@ def test__get_annotation_format(): assert _get_annotation_format(get_importer("superannotate")) == "superannotate" +def test__get_annotation_format_with_partial(): + nifti_importer = get_importer("nifti") + legacy_nifti_importer = partial(nifti_importer, legacy=True) + assert _get_annotation_format(legacy_nifti_importer) == "nifti" + + def test_no_verify_warning_for_single_slotted_items(): bounding_box_class = dt.AnnotationClass( name="class1", annotation_type="bounding_box"