From 55ba27b0069150053af595a154d2a77255fda02c Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Fri, 11 Oct 2024 00:21:46 +0100 Subject: [PATCH] Annotation import E2E test for multiple instance ID value warning --- darwin/importer/importer.py | 1 + e2e_tests/cli/test_import.py | 15 +- .../mini_uct.json | 133 ++++++++++++++++++ 3 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 e2e_tests/data/import/video_annotation_with_multiple_instance_ids/mini_uct.json diff --git a/darwin/importer/importer.py b/darwin/importer/importer.py index 21de45e2e..94910ce18 100644 --- a/darwin/importer/importer.py +++ b/darwin/importer/importer.py @@ -2170,6 +2170,7 @@ def _warn_for_annotations_with_multiple_instance_ids( unique_instance_ids = [] for frame_idx in annotation.frames: # type: ignore for subannotation in annotation.frames[frame_idx].subs: # type: ignore + print(subannotation) if subannotation.annotation_type == "instance_id": instance_id = subannotation.data if instance_id not in unique_instance_ids: diff --git a/e2e_tests/cli/test_import.py b/e2e_tests/cli/test_import.py index afd6fa082..0f0fcc6e9 100644 --- a/e2e_tests/cli/test_import.py +++ b/e2e_tests/cli/test_import.py @@ -2,7 +2,6 @@ from e2e_tests.helpers import ( - assert_cli, run_cli_command, export_and_download_annotations, delete_annotation_uuids, @@ -238,7 +237,6 @@ def run_import_test( result = run_cli_command( f"darwin dataset import {local_dataset.name} darwin {expected_annotations_dir} {additional_flags}" ) - assert_cli(result, exit_code) if expect_warning: assert expect_warning in result.stdout @@ -465,3 +463,16 @@ def test_import_annotations_with_subtypes_to_videos( item_type="single_slotted_video", annotations_subdir="video_annotations_with_subtypes", ) + + +# For this test to succeed, the `e2e-testing` Darwin team must have the `STATIC_INSTANCE_ID` feature flag enabled +def test_importing_multiple_instance_id_values_per_annotation_generates_a_warning( + local_dataset: E2EDataset, config_values: ConfigValues +) -> None: + run_import_test( + local_dataset, + config_values, + item_type="single_slotted_video", + annotations_subdir="video_annotation_with_multiple_instance_ids", + expect_error="multiple instance ID values", + ) diff --git a/e2e_tests/data/import/video_annotation_with_multiple_instance_ids/mini_uct.json b/e2e_tests/data/import/video_annotation_with_multiple_instance_ids/mini_uct.json new file mode 100644 index 000000000..9641de88a --- /dev/null +++ b/e2e_tests/data/import/video_annotation_with_multiple_instance_ids/mini_uct.json @@ -0,0 +1,133 @@ +{ + "version": "2.0", + "schema_ref": "https://darwin-public.s3.eu-west-1.amazonaws.com/darwin_json/2.0/schema.json", + "item": { + "name": "mini_uct.mp4", + "path": "/", + "source_info": { + "item_id": "0192788d-f84c-3e47-3ed9-5801e3073ae1", + "dataset": { + "name": "test_dataset_50ea2a66-d526-4212-928a-eac3745da30a", + "slug": "test_dataset_50ea2a66-d526-4212-928a-eac3745da30a", + "dataset_management_url": "https://staging.v7labs.com/datasets/386274/dataset-management" + }, + "team": { + "name": "E2E Testing", + "slug": "e2e-testing" + }, + "workview_url": "https://staging.v7labs.com/workview?dataset=386274&item=0192788d-f84c-3e47-3ed9-5801e3073ae1" + }, + "slots": [ + { + "type": "video", + "slot_name": "0", + "width": 1920, + "height": 1080, + "fps": 1, + "thumbnail_url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/thumbnail", + "source_files": [ + { + "file_name": "mini_uct.mp4", + "storage_key": "darwin-py/videos/mini_uct.mp4", + "url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/uploads/78f2a1ac-210d-43f9-bb48-d0d0c9ca17b8" + } + ], + "frame_count": 10, + "frame_urls": [ + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/0", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/1", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/2", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/3", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/4", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/5", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/6", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/7", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/8", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/65750b55-ccfc-4a01-b9a5-ab3f1d6a0a64/sections/9" + ] + } + ] + }, + "annotations": [ + { + "frames": { + "0": { + "bounding_box": { + "h": 3.8235, + "w": 6.1275, + "x": 7.9412, + "y": 8.6765 + }, + "instance_id": { + "value": 20 + }, + "keyframe": true + }, + "1": { + "bounding_box": { + "h": 3.8235, + "w": 6.1275, + "x": 7.9412, + "y": 8.6765 + }, + "instance_id": { + "value": 21 + }, + "keyframe": false + }, + "2": { + "bounding_box": { + "h": 3.8235, + "w": 6.1275, + "x": 7.9412, + "y": 8.6765 + }, + "instance_id": { + "value": 22 + }, + "keyframe": false + }, + "3": { + "bounding_box": { + "h": 3.8235, + "w": 6.1275, + "x": 7.9412, + "y": 8.6765 + }, + "instance_id": { + "value": 23 + }, + "keyframe": false + }, + "4": { + "bounding_box": { + "h": 3.8235, + "w": 6.1275, + "x": 7.9412, + "y": 8.6765 + }, + "instance_id": { + "value": 24 + }, + "keyframe": true + } + }, + "global_sub_types": {}, + "id": "c92972c6-41a5-48b6-8c4a-9e8062d06d61", + "interpolate_algorithm": "linear-1.1", + "interpolated": true, + "name": "test_bounding_box_with_subtypes_and_properties", + "properties": [], + "ranges": [ + [ + 0, + 5 + ] + ], + "slot_names": [ + "0" + ] + } + ], + "properties": [] +} \ No newline at end of file