@@ -28,10 +28,7 @@ class DescriptorFileCreator:
28
28
29
29
Args:
30
30
client (Client): The client object
31
- is_upsert (bool): Whether the upload is an upsert. This is a legacy parameter and should always be True because this class will only support upsert
32
31
max_chunk_size_bytes (int): The maximum size of the file in bytes
33
-
34
- TODO: Remove is_upsert parameter
35
32
"""
36
33
37
34
def __init__ (self , client : "Client" ):
@@ -56,7 +53,7 @@ def create(self,
56
53
is_upsert = True # This class will only support upsert use cases
57
54
items = self ._prepare_items_for_upload (items ,
58
55
max_attachments_per_data_row ,
59
- is_upsert )
56
+ is_upsert = is_upsert )
60
57
json_chunks = self ._chunk_down_by_bytes (items , max_chunk_size_bytes )
61
58
with ThreadPoolExecutor (FILE_UPLOAD_THREAD_COUNT ) as executor :
62
59
futures = [
@@ -66,14 +63,11 @@ def create(self,
66
63
]
67
64
return [future .result () for future in as_completed (futures )]
68
65
69
- def create_one (self ,
70
- items ,
71
- max_attachments_per_data_row = None ,
72
- is_upsert = False ) -> List [str ]:
66
+ def create_one (self , items , max_attachments_per_data_row = None ) -> List [str ]:
73
67
items = self ._prepare_items_for_upload (items ,
74
68
max_attachments_per_data_row ,
75
69
is_upsert )
76
- # Prepare and upload the desciptor file
70
+ # Prepare and upload the descriptor file
77
71
data = json .dumps (items )
78
72
return self .client .upload_data (data ,
79
73
content_type = "application/json" ,
@@ -84,8 +78,7 @@ def _prepare_items_for_upload(self,
84
78
max_attachments_per_data_row = None ,
85
79
is_upsert = False ):
86
80
"""
87
- This function is shared by `Dataset.create_data_rows`, `Dataset.create_data_rows_sync` and `Dataset.update_data_rows`.
88
- It is used to prepare the input file. The user defined input is validated, processed, and json stringified.
81
+ This function is used to prepare the input file. The user defined input is validated, processed, and json stringified.
89
82
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
90
83
91
84
Each element in `items` can be either a `str` or a `dict`. If
@@ -109,9 +102,6 @@ def _prepare_items_for_upload(self,
109
102
>>> {DataRow.row_data: {"type" : ..., 'version' : ..., 'messages' : [...]}}
110
103
>>> ])
111
104
112
- For an example showing how to upload tiled data_rows see the following notebook:
113
- https://github.com/Labelbox/labelbox-python/blob/ms/develop/model_assisted_labeling/tiled_imagery_mal.ipynb
114
-
115
105
Args:
116
106
items (iterable of (dict or str)): See above for details.
117
107
max_attachments_per_data_row (Optional[int]): Param used during attachment validation to determine
@@ -305,7 +295,7 @@ def _chunk_down_by_bytes(self, items: List[dict],
305
295
max_chunk_size : int ) -> Generator [str , None , None ]:
306
296
"""
307
297
Recursively chunks down a list of items into smaller lists until each list is less than or equal to max_chunk_size bytes
308
- NOTE: of one data row is large than max_chunk_size, it will be returned as one chunk
298
+ NOTE: if one data row is larger than max_chunk_size, it will be returned as one chunk
309
299
310
300
Returns:
311
301
Generator[str, None, None]: A generator that yields a json string
0 commit comments