Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions darwin/importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
7 changes: 7 additions & 0 deletions tests/darwin/importer/importer_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down