Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions darwin/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ def post_processing(
"hidden_areas": self.hidden_areas,
}

# Only put attributes in the payload if the attributes have changed this frame
last_attributes = None
for idx in sorted(output["frames"]):
attributes = output["frames"][idx].get("attributes")
if attributes is not None and attributes == last_attributes:
output["frames"][idx].pop("attributes")
last_attributes = attributes

return output


Expand Down
5 changes: 3 additions & 2 deletions tests/darwin/importer/importer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ def test__get_annotation_data_video_annotation_with_attributes_that_become_empty
assert result["frames"][4]["attributes"] == {"attributes": []}


def test__get_annotation_data_video_annotation_does_not_wipe_sub_annotations_when_keyframe_is_true() -> (
def test__get_annotation_data_video_annotation_only_stores_updates_to_sub_annotations_when_keyframe_is_true() -> (
None
):
from darwin.importer.importer import _get_annotation_data
Expand Down Expand Up @@ -785,7 +785,8 @@ def test__get_annotation_data_video_annotation_does_not_wipe_sub_annotations_whe
attributes = {"video_class_id": {"attribute_1": "id_1", "attribute_2": "id_2"}}
result = _get_annotation_data(video_annotation, "video_class_id", attributes)
assert result["frames"][1]["attributes"] == {"attributes": ["id_1", "id_2"]}
assert result["frames"][3]["attributes"] == {"attributes": ["id_1", "id_2"]}
assert 2 not in result["frames"]
assert result["frames"][3].get("attributes") is None


def __expectation_factory(i: int, slot_names: List[str]) -> dt.Annotation:
Expand Down