Skip to content

Commit 9d91941

Browse files
author
Val Brodsky
committed
Removed max_attachments_per_data_row, not needed any more
1 parent 34a5f92 commit 9d91941

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

libs/labelbox/src/labelbox/schema/dataset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def create_data_row(self, items=None, **kwargs) -> "DataRow":
154154
res = completed_task.result
155155
if res is None or len(res) == 0:
156156
raise ResourceCreationError(
157-
f"Data row upload did not complete, task status {task.status} task id {task.uid}"
157+
f"Data row upload did not complete, task status {completed_task.status} task id {completed_task.uid}"
158158
)
159159

160160
return self.client.get_data_row(res[0]['id'])
@@ -183,7 +183,6 @@ def create_data_rows_sync(
183183
a DataRow.
184184
ValueError: When the upload parameters are invalid
185185
"""
186-
max_attachments_per_data_row = 5
187186
self._create_data_rows_sync(
188187
items, file_upload_thread_count=file_upload_thread_count)
189188

libs/labelbox/src/labelbox/schema/internal/descriptor_file_creator.py

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,10 @@ class DescriptorFileCreator:
3333

3434
def __init__(self, client: "Client"):
3535
self.client = client
36-
""""
37-
This method is used to convert a list to json and upload it in a file to gcs.
38-
It will create multiple files if the size of upload is greater than max_chunk_size_bytes in bytes,
39-
It uploads the files to gcs in parallel, and return a list of urls
4036

41-
Args:
42-
items: The list to upload
43-
is_upsert (bool): Whether the upload is an upsert
44-
max_attachments_per_data_row (int): The maximum number of attachments per data row
45-
max_chunk_size_bytes (int): The maximum size of the file in bytes
46-
"""
47-
48-
def create(self,
49-
items,
50-
max_attachments_per_data_row=None,
51-
max_chunk_size_bytes=None) -> List[str]:
37+
def create(self, items, max_chunk_size_bytes=None) -> List[str]:
5238
is_upsert = True # This class will only support upsert use cases
53-
items = self._prepare_items_for_upload(items,
54-
max_attachments_per_data_row,
55-
is_upsert=is_upsert)
39+
items = self._prepare_items_for_upload(items, is_upsert=is_upsert)
5640
json_chunks = self._chunk_down_by_bytes(items, max_chunk_size_bytes)
5741
with ThreadPoolExecutor(FILE_UPLOAD_THREAD_COUNT) as executor:
5842
futures = [
@@ -62,19 +46,15 @@ def create(self,
6246
]
6347
return [future.result() for future in as_completed(futures)]
6448

65-
def create_one(self, items, max_attachments_per_data_row=None) -> List[str]:
66-
items = self._prepare_items_for_upload(items,
67-
max_attachments_per_data_row)
49+
def create_one(self, items) -> List[str]:
50+
items = self._prepare_items_for_upload(items,)
6851
# Prepare and upload the descriptor file
6952
data = json.dumps(items)
7053
return self.client.upload_data(data,
7154
content_type="application/json",
7255
filename="json_import.json")
7356

74-
def _prepare_items_for_upload(self,
75-
items,
76-
max_attachments_per_data_row=None,
77-
is_upsert=False):
57+
def _prepare_items_for_upload(self, items, is_upsert=False):
7858
"""
7959
This function is used to prepare the input file. The user defined input is validated, processed, and json stringified.
8060
Finally the json data is uploaded to gcs and a uri is returned. This uri can be passed as a parameter to a mutation that uploads data rows
@@ -102,8 +82,6 @@ def _prepare_items_for_upload(self,
10282
10383
Args:
10484
items (iterable of (dict or str)): See above for details.
105-
max_attachments_per_data_row (Optional[int]): Param used during attachment validation to determine
106-
if the user has provided too many attachments.
10785
10886
Returns:
10987
uri (string): A reference to the uploaded json data.
@@ -137,12 +115,6 @@ def validate_attachments(item):
137115
attachments = item.get('attachments')
138116
if attachments:
139117
if isinstance(attachments, list):
140-
if max_attachments_per_data_row and len(
141-
attachments) > max_attachments_per_data_row:
142-
raise ValueError(
143-
f"Max attachments number of supported attachments per data row is {max_attachments_per_data_row}."
144-
f" Found {len(attachments)}. Condense multiple attachments into one with the HTML attachment type if necessary."
145-
)
146118
for attachment in attachments:
147119
AssetAttachment.validate_attachment_json(attachment)
148120
else:

0 commit comments

Comments
 (0)