Skip to content

Commit 4106f8e

Browse files
author
Ubuntu
committed
Big refactor to make things cleaner + enable retries properly on infra flakes for local upload
1 parent cd942e4 commit 4106f8e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

nucleus/dataset_item_uploader.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,22 @@ def get_form_data_and_file_pointers_fn(
150150
"""Constructs a function that will generate form data on each retry."""
151151

152152
def fn():
153-
payload = construct_append_payload(items, update)
153+
154+
# For some reason, our backend only accepts this reformatting of items when
155+
# doing local upload.
156+
# TODO: make it just accept the same exact format as a normal append request
157+
# i.e. the output of construct_append_payload(items, update)
158+
json_data = []
159+
for item in items:
160+
item_payload = item.to_payload()
161+
item_payload[UPDATE_KEY] = update
162+
json_data.append(item_payload)
163+
154164
form_data = [
155165
FileFormField(
156166
name=ITEMS_KEY,
157167
filename=None,
158-
value=json.dumps(payload, allow_nan=False),
168+
value=json.dumps(json_data, allow_nan=False),
159169
content_type="application/json",
160170
)
161171
]

nucleus/segmentation_uploader.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,8 @@
112112
# (MASK_TYPE, (filename, mask_fp, "image/png"))
113113
# )
114114
# return request_payload, file_pointers
115+
116+
117+
# {"items": [{"metadata": {"test": 0}, "reference_id": "test_img.jpg", "image_url": "tests/test_img.jpg", "upload_to_scale": true}]
118+
119+
# [{"metadata": {"test": 0}, "reference_id": "test_img.jpg", "image_url": "tests/test_img.jpg", "upload_to_scale": true, "update": false}]

0 commit comments

Comments
 (0)