Skip to content

Commit 82a6cee

Browse files
Drew KaulDrew Kaul
authored andcommitted
fix item_id bug in CuboidAnnotation class
1 parent 0fd7dd8 commit 82a6cee

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

nucleus/annotation.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,23 @@ def from_json(cls, payload: dict):
295295
)
296296

297297
def to_payload(self) -> dict:
298-
return {
298+
payload = {
299299
LABEL_KEY: self.label,
300300
TYPE_KEY: CUBOID_TYPE,
301301
GEOMETRY_KEY: {
302302
POSITION_KEY: self.position.to_payload(),
303303
DIMENSIONS_KEY: self.dimensions.to_payload(),
304304
YAW_KEY: self.yaw,
305305
},
306-
REFERENCE_ID_KEY: self.reference_id,
307-
ITEM_ID_KEY: self.item_id,
308-
ANNOTATION_ID_KEY: self.annotation_id,
309-
METADATA_KEY: self.metadata,
310306
}
307+
if self.reference_id:
308+
payload[REFERENCE_ID_KEY] = self.reference_id
309+
if self.annotation_id:
310+
payload[ANNOTATION_ID_KEY] = self.annotation_id
311+
if self.metadata:
312+
payload[METADATA_KEY] = self.metadata
313+
314+
return payload
311315

312316

313317
def is_local_path(path: str) -> bool:

tests/test_scene.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ def test_scene_and_cuboid_upload_sync(dataset):
8787
lidar_item_ref = payload[SCENES_KEY][0][FRAMES_KEY][0]["lidar"][
8888
REFERENCE_ID_KEY
8989
]
90-
lidar_item = dataset.refloc(lidar_item_ref)[ITEM_KEY]
91-
TEST_CUBOID_ANNOTATIONS[0][DATASET_ITEM_ID_KEY] = lidar_item.item_id
90+
TEST_CUBOID_ANNOTATIONS[0][REFERENCE_ID_KEY] = lidar_item_ref
9291

9392
annotations = [CuboidAnnotation.from_json(TEST_CUBOID_ANNOTATIONS[0])]
9493
response = dataset.annotate(annotations)
@@ -97,12 +96,10 @@ def test_scene_and_cuboid_upload_sync(dataset):
9796
assert response["annotations_processed"] == len(annotations)
9897
assert response["annotations_ignored"] == 0
9998

100-
response = dataset.loc(annotations[0].item_id)[ANNOTATIONS_KEY]["cuboid"]
101-
assert len(response) == 1
102-
response_annotation = response[0]
99+
response_annotations = dataset.refloc(lidar_item_ref)[ANNOTATIONS_KEY][
100+
"cuboid"
101+
]
102+
assert len(response_annotations) == 1
103103
assert_cuboid_annotation_matches_dict(
104-
response_annotation, TEST_CUBOID_ANNOTATIONS[0]
104+
response_annotations[0], TEST_CUBOID_ANNOTATIONS[0]
105105
)
106-
107-
lidar_item_ann = dataset.refloc(lidar_item_ref)[ANNOTATIONS_KEY]["cuboid"]
108-
assert annotations == lidar_item_ann

0 commit comments

Comments
 (0)