Skip to content

Commit 8a316e2

Browse files
authored
Remove upload_to_scale option (#407)
1 parent dc4a025 commit 8a316e2

File tree

7 files changed

+5
-93
lines changed

7 files changed

+5
-93
lines changed

nucleus/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@
150150
TYPE_KEY = "type"
151151
UPDATED_ITEMS = "updated_items"
152152
UPDATE_KEY = "update"
153-
UPLOAD_TO_SCALE_KEY = "upload_to_scale"
154153
URL_KEY = "url"
155154
VERTICES_KEY = "vertices"
156155
VIDEO_LOCATION_KEY = "video_location"

nucleus/dataset_item.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
POINTCLOUD_URL_KEY,
2020
REFERENCE_ID_KEY,
2121
TYPE_KEY,
22-
UPLOAD_TO_SCALE_KEY,
2322
URL_KEY,
2423
)
2524

@@ -112,13 +111,6 @@ class DatasetItem: # pylint: disable=R0902
112111
Shorten this once we have a guide migrated for metadata, or maybe link
113112
from other places to here.
114113
115-
upload_to_scale (Optional[bool]): Set this to false in order to use
116-
`privacy mode <https://nucleus.scale.com/docs/privacy-mode>`_.
117-
118-
Setting this to false means the actual data within the item will not be
119-
uploaded to scale meaning that you can send in links that are only accessible
120-
to certain users, and not to Scale. Skipping upload to Scale is currently only
121-
implemented for images.
122114
"""
123115

124116
image_location: Optional[str] = None
@@ -127,24 +119,19 @@ class DatasetItem: # pylint: disable=R0902
127119
)
128120
metadata: Optional[dict] = None
129121
pointcloud_location: Optional[str] = None
130-
upload_to_scale: Optional[bool] = True
131122
embedding_info: Optional[DatasetItemEmbeddingInfo] = None
132123

133124
def __post_init__(self):
134125
assert self.reference_id != "DUMMY_VALUE", "reference_id is required."
135126
assert bool(self.image_location) != bool(
136127
self.pointcloud_location
137128
), "Must specify exactly one of the image_location or pointcloud_location parameters"
129+
138130
if self.pointcloud_location and self.embedding_info:
139131
raise AssertionError(
140132
"Cannot upload embedding vector if pointcloud_location is set"
141133
)
142134

143-
if (self.pointcloud_location) and not self.upload_to_scale:
144-
raise NotImplementedError(
145-
"Skipping upload to Scale is not currently implemented for pointclouds."
146-
)
147-
148135
self.local = (
149136
is_local_path(self.image_location) if self.image_location else None
150137
)
@@ -186,7 +173,6 @@ def from_json(cls, payload: dict):
186173
pointcloud_location=pointcloud_url,
187174
reference_id=payload.get(REFERENCE_ID_KEY, None),
188175
metadata=payload.get(METADATA_KEY, {}),
189-
upload_to_scale=payload.get(UPLOAD_TO_SCALE_KEY, True),
190176
)
191177

192178
def local_file_exists(self):
@@ -217,7 +203,6 @@ def to_payload(self, is_scene=False) -> dict:
217203
self.image_location
218204
), "Must specify image_location for DatasetItems not in a LidarScene or VideoScene"
219205
payload[IMAGE_URL_KEY] = self.image_location
220-
payload[UPLOAD_TO_SCALE_KEY] = self.upload_to_scale
221206

222207
return payload
223208

nucleus/scene.py

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
POINTCLOUD_LOCATION_KEY,
1515
REFERENCE_ID_KEY,
1616
TRACKS_KEY,
17-
UPLOAD_TO_SCALE_KEY,
1817
VIDEO_LOCATION_KEY,
1918
VIDEO_URL_KEY,
2019
)
@@ -496,13 +495,6 @@ class VideoScene(ABC):
496495
Context Attachments may be provided to display the attachments side by side with the dataset
497496
item in the Detail View by specifying
498497
`{ "context_attachments": [ { "attachment": 'https://example.com/1' }, { "attachment": 'https://example.com/2' }, ... ] }`.
499-
upload_to_scale (Optional[bool]): Set this to false in order to use
500-
`privacy mode <https://nucleus.scale.com/docs/privacy-mode>`_. If using privacy mode
501-
you must upload both a video_location and items to the VideoScene.
502-
503-
Setting this to false means the actual data within the video scene will not be
504-
uploaded to scale meaning that you can send in links that are only accessible
505-
to certain users, and not to Scale.
506498
507499
Refer to our `guide to uploading video data
508500
<https://nucleus.scale.com/docs/uploading-video-data>`_ for more info!
@@ -513,7 +505,6 @@ class VideoScene(ABC):
513505
video_location: Optional[str] = None
514506
items: List[DatasetItem] = field(default_factory=list)
515507
metadata: Optional[dict] = field(default_factory=dict)
516-
upload_to_scale: Optional[bool] = True
517508
attachment_type: Optional[str] = None
518509
tracks: List[Track] = field(default_factory=list)
519510

@@ -540,34 +531,14 @@ def __eq__(self, other):
540531
@property
541532
def length(self) -> int:
542533
"""Gets number of items in the scene for videos uploaded with an array of images."""
543-
assert (
544-
not self.upload_to_scale or not self.video_location
545-
), "Only videos with items have a length"
546534
return len(self.items)
547535

548536
def validate(self):
549537
# TODO: make private
550538
assert (
551539
self.items or self.video_location
552540
), "Please upload either a video_location or an array of dataset items representing frames"
553-
if self.upload_to_scale is False:
554-
assert (
555-
self.frame_rate > 0
556-
), "When using privacy mode frame rate must be at least 1"
557-
assert (
558-
self.items and self.length > 0
559-
), "When using privacy mode scene must have a list of items of length at least 1"
560-
for item in self.items:
561-
assert isinstance(
562-
item, DatasetItem
563-
), "Each item in a scene must be a DatasetItem object"
564-
assert (
565-
item.image_location is not None
566-
), "Each item in a video scene must have an image_location"
567-
assert (
568-
item.upload_to_scale is not False
569-
), "Please specify whether to upload to scale in the VideoScene for videos"
570-
elif self.items:
541+
if self.items:
571542
assert (
572543
self.frame_rate > 0
573544
), "When uploading an array of items frame rate must be at least 1"
@@ -584,9 +555,6 @@ def validate(self):
584555
assert (
585556
item.image_location is not None
586557
), "Each item in a video scene must have an image_location"
587-
assert (
588-
item.upload_to_scale is not False
589-
), "Please specify whether to upload to scale in the VideoScene for videos"
590558
else:
591559
assert (
592560
not self.frame_rate
@@ -610,7 +578,7 @@ def add_item(
610578
exists. Default is False.
611579
"""
612580
assert (
613-
not self.upload_to_scale or not self.video_location
581+
not self.video_location
614582
), "Cannot add item to a video without items"
615583
if index is None:
616584
index = len(self.items)
@@ -631,7 +599,7 @@ def get_item(self, index: int) -> DatasetItem:
631599
Return:
632600
:class:`DatasetItem`: DatasetItem at the specified index."""
633601
assert (
634-
not self.upload_to_scale or not self.video_location
602+
not self.video_location
635603
), "Cannot add item to a video without items"
636604
if index < 0 or index > len(self.items):
637605
raise ValueError(
@@ -646,7 +614,7 @@ def get_items(self) -> List[DatasetItem]:
646614
List[:class:`DatasetItem`]: List of DatasetItems, sorted by index ascending.
647615
"""
648616
assert (
649-
not self.upload_to_scale or not self.video_location
617+
not self.video_location
650618
), "Cannot add item to a video without items"
651619
return self.items
652620

@@ -672,9 +640,6 @@ def info(self):
672640
payload[VIDEO_URL_KEY] = self.video_location
673641
if self.items:
674642
payload[LENGTH_KEY] = self.length
675-
if self.upload_to_scale:
676-
payload[UPLOAD_TO_SCALE_KEY] = self.upload_to_scale
677-
678643
return payload
679644

680645
@classmethod
@@ -699,7 +664,6 @@ def from_json(
699664
items=items,
700665
metadata=payload.get(METADATA_KEY, {}),
701666
video_location=payload.get(VIDEO_URL_KEY, None),
702-
upload_to_scale=payload.get(UPLOAD_TO_SCALE_KEY, True),
703667
tracks=tracks,
704668
)
705669

@@ -720,8 +684,6 @@ def to_payload(self) -> dict:
720684
item.to_payload(is_scene=True) for item in self.items
721685
]
722686
payload[FRAMES_KEY] = items_payload
723-
if self.upload_to_scale is not None:
724-
payload[UPLOAD_TO_SCALE_KEY] = self.upload_to_scale
725687
if self.tracks:
726688
payload[TRACKS_KEY] = [track.to_payload() for track in self.tracks]
727689
return payload

scripts/load_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from absl import app, flags
66

77
import nucleus
8-
from nucleus import annotation
98
from nucleus.async_job import JobError
109
from nucleus.dataset import Dataset
1110

@@ -89,7 +88,6 @@ def dataset_item_generator():
8988
image_location=IMAGE_URL,
9089
reference_id=str(i),
9190
metadata=generate_fake_metadata(i),
92-
upload_to_scale=False,
9391
)
9492

9593

tests/helpers.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,6 @@
121121
"video_url": TEST_VIDEO_URL,
122122
"metadata": {"timestamp": "1234", "weather": "rainy"},
123123
},
124-
{
125-
"reference_id": "scene_3",
126-
"video_url": TEST_INACCESSIBLE_VIDEO_URL,
127-
"frame_rate": 15,
128-
"frames": [
129-
{
130-
"image_url": TEST_INACCESSIBLE_IMG_URLS[0],
131-
"type": "image",
132-
"reference_id": "video_frame_2",
133-
"metadata": {"time": 123, "foo": "bar"},
134-
},
135-
{
136-
"image_url": TEST_INACCESSIBLE_IMG_URLS[1],
137-
"type": "image",
138-
"reference_id": "video_frame_3",
139-
"metadata": {"time": 124, "foo": "bar_2"},
140-
},
141-
],
142-
"metadata": {"timestamp": "1234", "weather": "rainy"},
143-
"upload_to_scale": False,
144-
},
145124
],
146125
"update": False,
147126
}
@@ -251,21 +230,18 @@ def reference_id_from_url(url):
251230
reference_id_from_url(TEST_IMG_URLS[0]),
252231
None,
253232
None,
254-
True,
255233
),
256234
DatasetItem(
257235
TEST_IMG_URLS[1],
258236
reference_id_from_url(TEST_IMG_URLS[1]),
259237
None,
260238
None,
261-
True,
262239
),
263240
DatasetItem(
264241
TEST_IMG_URLS[2],
265242
reference_id_from_url(TEST_IMG_URLS[2]),
266243
None,
267244
None,
268-
True,
269245
),
270246
]
271247

tests/test_dataset.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,9 @@ def check_is_expected_response(response):
197197
# Plain image upload
198198
ds_items_plain = []
199199
for i, url in enumerate(TEST_IMG_URLS):
200-
# Upload just the first item in privacy mode
201-
upload_to_scale = i == 0
202200
ds_items_plain.append(
203201
DatasetItem(
204202
image_location=url,
205-
upload_to_scale=upload_to_scale,
206203
reference_id=url.split("/")[-1] + "_plain",
207204
)
208205
)
@@ -220,12 +217,9 @@ def test_scene_dataset_append(dataset_scene):
220217
# Plain image upload
221218
ds_items_plain = []
222219
for i, url in enumerate(TEST_IMG_URLS):
223-
# Upload just the first item in privacy mode
224-
upload_to_scale = i == 0
225220
ds_items_plain.append(
226221
DatasetItem(
227222
image_location=url,
228-
upload_to_scale=upload_to_scale,
229223
reference_id=url.split("/")[-1] + "_plain",
230224
)
231225
)

tests/test_video_scene.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
REFERENCE_ID_KEY,
1313
SCENES_KEY,
1414
TYPE_KEY,
15-
UPLOAD_TO_SCALE_KEY,
1615
URL_KEY,
1716
VIDEO_URL_KEY,
1817
)
@@ -121,7 +120,6 @@ def test_video_scene_add_item():
121120
METADATA_KEY: TEST_VIDEO_ITEMS[1].metadata or {},
122121
},
123122
],
124-
UPLOAD_TO_SCALE_KEY: True,
125123
}
126124

127125

0 commit comments

Comments
 (0)