Skip to content

Commit 8895409

Browse files
author
Diego Ardila
committed
Minor changes to make privacy mode upload possible
1 parent e52488e commit 8895409

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

nucleus/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
TYPE_KEY = "type"
8787
UPDATED_ITEMS = "updated_items"
8888
UPDATE_KEY = "update"
89+
UPLOAD_TO_SCALE_KEY = "uploadToScale"
8990
URL_KEY = "url"
9091
VERTICES_KEY = "vertices"
9192
WIDTH_KEY = "width"

nucleus/dataset_item.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
IMAGE_URL_KEY,
1212
METADATA_KEY,
1313
ORIGINAL_IMAGE_URL_KEY,
14+
UPLOAD_TO_SCALE_KEY,
1415
REFERENCE_ID_KEY,
1516
TYPE_KEY,
1617
URL_KEY,
@@ -94,11 +95,16 @@ class DatasetItem: # pylint: disable=R0902
9495
item_id: Optional[str] = None
9596
metadata: Optional[dict] = None
9697
pointcloud_location: Optional[str] = None
98+
upload_to_scale: Optional[bool] = True
9799

98100
def __post_init__(self):
99101
assert bool(self.image_location) != bool(
100102
self.pointcloud_location
101103
), "Must specify exactly one of the image_location, pointcloud_location parameters"
104+
if self.pointcloud_location and not self.upload_to_scale:
105+
raise NotImplementedError(
106+
"Skipping upload to Scale is not currently implemented for pointclouds."
107+
)
102108
self.local = (
103109
is_local_path(self.image_location) if self.image_location else None
104110
)
@@ -136,6 +142,7 @@ def from_json(cls, payload: dict, is_scene=False):
136142
reference_id=payload.get(REFERENCE_ID_KEY, None),
137143
item_id=payload.get(DATASET_ITEM_ID_KEY, None),
138144
metadata=payload.get(METADATA_KEY, {}),
145+
upload_to_scale=payload.get(UPLOAD_TO_SCALE_KEY, None),
139146
)
140147

141148
def local_file_exists(self):
@@ -163,6 +170,7 @@ def to_payload(self, is_scene=False) -> dict:
163170
self.image_location
164171
), "Must specify image_location for DatasetItems not in a LidarScene"
165172
payload[IMAGE_URL_KEY] = self.image_location
173+
payload[UPLOAD_TO_SCALE_KEY] = self.upload_to_scale
166174

167175
return payload
168176

tests/test_dataset.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import copy
22
import math
3+
from nucleus.model import Model
4+
from nucleus.prediction import BoxPrediction
35
import os
46

57
import pytest
@@ -176,8 +178,11 @@ def check_is_expected_response(response):
176178

177179
# Plain image upload
178180
ds_items_plain = []
179-
for url in TEST_IMG_URLS:
180-
ds_items_plain.append(DatasetItem(image_location=url))
181+
for i, url in enumerate(TEST_IMG_URLS):
182+
upload_to_scale = i == 0
183+
ds_items_plain.append(
184+
DatasetItem(image_location=url, upload_to_scale=upload_to_scale)
185+
)
181186
response = dataset.append(ds_items_plain)
182187
check_is_expected_response(response)
183188

0 commit comments

Comments
 (0)