Skip to content

Commit

Permalink
Annotation import E2E test for multiple instance ID value warning
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Oct 10, 2024
1 parent 0cab936 commit 55ba27b
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 2 deletions.
1 change: 1 addition & 0 deletions darwin/importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 13 additions & 2 deletions e2e_tests/cli/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


from e2e_tests.helpers import (
assert_cli,
run_cli_command,
export_and_download_annotations,
delete_annotation_uuids,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
)
Original file line number Diff line number Diff line change
@@ -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": []
}

0 comments on commit 55ba27b

Please sign in to comment.