Skip to content

Commit 289a9e5

Browse files
Drew KaulDrew Kaul
authored andcommitted
add separate sync upload test and nits
1 parent 18c42c3 commit 289a9e5

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

nucleus/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
ERROR_CODES = "error_codes"
3030
ERROR_ITEMS = "upload_errors"
3131
ERROR_PAYLOAD = "error_payload"
32+
FRAMES = "frames"
3233
GEOMETRY_KEY = "geometry"
3334
HEIGHT_KEY = "height"
3435
IGNORED_ITEMS = "ignored_items"

nucleus/dataset.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
DATASET_SLICES_KEY,
2424
DEFAULT_ANNOTATION_UPDATE_MODE,
2525
EXPORTED_ROWS,
26+
FRAMES,
2627
JOB_ID_KEY,
2728
NAME_KEY,
2829
REFERENCE_IDS_KEY,
@@ -253,9 +254,23 @@ def upload_scene(
253254
update: Optional[bool] = False,
254255
asynchronous: bool = False,
255256
) -> Union[dict, AsyncJob]:
256-
"""TODO: add docstring here"""
257+
"""
258+
Uploads scene with given frames to the dataset
259+
260+
Parameters:
261+
:param payload: dictionary containing frames to be uploaded as a scene
262+
:param update: if True, overwrite scene on collision
263+
:param aynchronous: if True, return a job object representing asynchronous ingestion job
264+
:return:
265+
{
266+
'dataset_id': str,
267+
'new_items': int,
268+
'updated_items': int,
269+
'ignored_items': int,
270+
}
271+
"""
257272
if asynchronous:
258-
check_all_frame_paths_remote(payload["frames"])
273+
check_all_frame_paths_remote(payload[FRAMES])
259274
request_id = serialize_and_write_to_presigned_url(
260275
[payload], self.id, self._client
261276
)

tests/test_scene.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def dataset(CLIENT):
2121
assert response == {"message": "Beginning dataset deletion..."}
2222

2323

24-
@pytest.mark.integration
2524
def test_scene_upload_sync(dataset):
2625
payload = TEST_LIDAR_FRAMES
2726
response = dataset.upload_scene(payload)
@@ -31,6 +30,17 @@ def test_scene_upload_sync(dataset):
3130
assert response["updated_items"] == 0
3231
assert response["ignored_items"] == 0
3332

33+
34+
@pytest.mark.integration
35+
def test_scene_and_cuboid_upload_sync(dataset):
36+
payload = TEST_LIDAR_FRAMES
37+
response = dataset.upload_scene(payload)
38+
39+
assert response["dataset_id"] == dataset.id
40+
assert response["new_items"] == 1
41+
assert response["updated_items"] == 0
42+
assert response["ignored_items"] == 0
43+
3444
TEST_CUBOID_ANNOTATIONS[0]["dataset_item_id"] = dataset.items[0].item_id
3545
annotation = CuboidAnnotation.from_json(TEST_CUBOID_ANNOTATIONS[0])
3646
response = dataset.annotate(annotations=[annotation])

0 commit comments

Comments
 (0)