Skip to content

Commit d3ee877

Browse files
author
Vinjai Vale
committed
Merge remote-tracking branch 'origin/master' into vinjai/autocurate
2 parents 26bbb4f + 4de8dca commit d3ee877

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
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 = "upload_to_scale"
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
@@ -10,6 +10,7 @@
1010
IMAGE_URL_KEY,
1111
METADATA_KEY,
1212
ORIGINAL_IMAGE_URL_KEY,
13+
UPLOAD_TO_SCALE_KEY,
1314
REFERENCE_ID_KEY,
1415
TYPE_KEY,
1516
URL_KEY,
@@ -92,12 +93,17 @@ class DatasetItem: # pylint: disable=R0902
9293
reference_id: Optional[str] = None
9394
metadata: Optional[dict] = None
9495
pointcloud_location: Optional[str] = None
96+
upload_to_scale: Optional[bool] = True
9597

9698
def __post_init__(self):
9799
assert self.reference_id is not None, "reference_id is required."
98100
assert bool(self.image_location) != bool(
99101
self.pointcloud_location
100102
), "Must specify exactly one of the image_location, pointcloud_location parameters"
103+
if self.pointcloud_location and not self.upload_to_scale:
104+
raise NotImplementedError(
105+
"Skipping upload to Scale is not currently implemented for pointclouds."
106+
)
101107
self.local = (
102108
is_local_path(self.image_location) if self.image_location else None
103109
)
@@ -133,6 +139,7 @@ def from_json(cls, payload: dict, is_scene=False):
133139
image_location=image_url,
134140
reference_id=payload.get(REFERENCE_ID_KEY, None),
135141
metadata=payload.get(METADATA_KEY, {}),
142+
upload_to_scale=payload.get(UPLOAD_TO_SCALE_KEY, None),
136143
)
137144

138145
def local_file_exists(self):
@@ -158,6 +165,7 @@ def to_payload(self, is_scene=False) -> dict:
158165
self.image_location
159166
), "Must specify image_location for DatasetItems not in a LidarScene"
160167
payload[IMAGE_URL_KEY] = self.image_location
168+
payload[UPLOAD_TO_SCALE_KEY] = self.upload_to_scale
161169

162170
return payload
163171

tests/test_dataset.py

Lines changed: 11 additions & 4 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,12 +178,17 @@ def check_is_expected_response(response):
176178

177179
# Plain image upload
178180
ds_items_plain = []
179-
for url in TEST_IMG_URLS:
181+
for i, url in enumerate(TEST_IMG_URLS):
182+
# Upload just the first item in privacy mode
183+
upload_to_scale = i == 0
180184
ds_items_plain.append(
181185
DatasetItem(
182-
image_location=url, reference_id=url.split("/")[-1] + "_plain"
186+
image_location=url,
187+
upload_to_scale=upload_to_scale,
188+
reference_id=url.split("/")[-1] + "_plain",
183189
)
184190
)
191+
185192
response = dataset.append(ds_items_plain)
186193
check_is_expected_response(response)
187194

@@ -289,8 +296,8 @@ def test_dataset_append_async_with_1_bad_url(dataset: Dataset):
289296
"started_image_processing": f"Dataset: {dataset.id}, Job: {job.job_id}",
290297
},
291298
"job_progress": "1.00",
292-
"completed_steps": 1,
293-
"total_steps": 1,
299+
"completed_steps": 4,
300+
"total_steps": 4,
294301
}
295302
# The error is fairly detailed and subject to change. What's important is we surface which URLs failed.
296303
assert (

0 commit comments

Comments
 (0)