Skip to content

Commit 2413465

Browse files
Drew KaulDrew Kaul
authored andcommitted
cleanup DatasetItem methods
1 parent 9247aa9 commit 2413465

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

nucleus/dataset_item.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,12 @@ class DatasetItem: # pylint: disable=R0902
9696
pointcloud_location: Optional[str] = None
9797

9898
def __post_init__(self):
99-
self.local = is_local_path(self.image_location)
10099
assert bool(self.image_location) != bool(
101100
self.pointcloud_location
102101
), "Must specify exactly one of the image_location, pointcloud_location parameters"
102+
self.local = (
103+
is_local_path(self.image_location) if self.image_location else None
104+
)
103105
self.type = (
104106
DatasetItemType.IMAGE
105107
if self.image_location
@@ -143,26 +145,25 @@ def to_payload(self, is_scene=False) -> dict:
143145
payload: Dict[str, Any] = {
144146
METADATA_KEY: self.metadata or {},
145147
}
148+
if self.reference_id:
149+
payload[REFERENCE_ID_KEY] = self.reference_id
150+
if self.item_id:
151+
payload[DATASET_ITEM_ID_KEY] = self.item_id
146152

147153
if is_scene:
148154
if self.image_location:
149155
payload[URL_KEY] = self.image_location
150156
elif self.pointcloud_location:
151157
payload[URL_KEY] = self.pointcloud_location
152158
payload[TYPE_KEY] = self.type.value
159+
if self.camera_params:
160+
payload[CAMERA_PARAMS_KEY] = self.camera_params.to_payload()
153161
else:
154162
assert (
155163
self.image_location
156-
), "Must specify image_location for DatasetItems not in a Scene"
164+
), "Must specify image_location for DatasetItems not in a LidarScene"
157165
payload[IMAGE_URL_KEY] = self.image_location
158166

159-
if self.reference_id:
160-
payload[REFERENCE_ID_KEY] = self.reference_id
161-
if self.item_id:
162-
payload[DATASET_ITEM_ID_KEY] = self.item_id
163-
if self.camera_params:
164-
payload[CAMERA_PARAMS_KEY] = self.camera_params.to_payload()
165-
166167
return payload
167168

168169
def to_json(self) -> str:

0 commit comments

Comments
 (0)