Skip to content

Commit

Permalink
Resolved legacy NifTI annotation import blocker
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Aug 27, 2024
1 parent ad35478 commit 492342a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit 492342a

Please sign in to comment.