Skip to content

Commit

Permalink
Do not require input to continue import
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Sep 24, 2024
1 parent b0e8d35 commit f956341
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 3 additions & 5 deletions darwin/importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,8 +1705,8 @@ def _warn_for_annotations_with_multiple_instance_ids(
Warns the user if any video annotations have multiple unique instance IDs.
This function checks each video annotation in the provided list of local annotation
files for multiple instance IDs. If any are found, a warning is printed to the console.
The user is then prompted to confirm if they want to proceed with the import.
files for multiple instance ID values. A warning is printed to the console for each
instance of this occurrence.
Parameters
----------
Expand Down Expand Up @@ -1737,12 +1737,10 @@ def _warn_for_annotations_with_multiple_instance_ids(

if files_with_multi_instance_id_annotations:
console.print(
"The following files have at least one annotation with multiple instance IDs. Your team has static instance IDs enabled, so only the first instance ID of each annotation will be imported:",
"The following files have annotation(s) with multiple instance ID values. Only the first instance ID of each annotation will be imported:",
style="warning",
)
for file in files_with_multi_instance_id_annotations:
console.print(
f"- File: {file} has {files_with_multi_instance_id_annotations[file]} annotation(s) with multiple instance IDs"
)
if not secure_continue_request():
raise SystemExit("Execution stopped by user.")
7 changes: 2 additions & 5 deletions tests/darwin/importer/importer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ def test_no_instance_id_warning_with_no_video_annotations():
console.print.assert_not_called()


def test_warning_with_multiple_files_with_multi_instance_id_annotations(monkeypatch):
def test_warning_with_multiple_files_with_multi_instance_id_annotations():
bounding_box_class = dt.AnnotationClass(
name="class1", annotation_type="bounding_box"
)
Expand Down Expand Up @@ -1931,10 +1931,7 @@ def test_warning_with_multiple_files_with_multi_instance_id_annotations(monkeypa
),
]
console = MagicMock()
# Simulate the user stopping the export at the warning
monkeypatch.setattr("builtins.input", lambda _: "n")
with pytest.raises(SystemExit):
_warn_for_annotations_with_multiple_instance_ids(local_files, console)
_warn_for_annotations_with_multiple_instance_ids(local_files, console)
console.print.assert_called()
assert (
console.print.call_count == 3
Expand Down

0 comments on commit f956341

Please sign in to comment.