@@ -33,26 +33,10 @@ class DescriptorFileCreator:
33
33
34
34
def __init__ (self , client : "Client" ):
35
35
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
40
36
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 ]:
52
38
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 )
56
40
json_chunks = self ._chunk_down_by_bytes (items , max_chunk_size_bytes )
57
41
with ThreadPoolExecutor (FILE_UPLOAD_THREAD_COUNT ) as executor :
58
42
futures = [
@@ -62,19 +46,15 @@ def create(self,
62
46
]
63
47
return [future .result () for future in as_completed (futures )]
64
48
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 ,)
68
51
# Prepare and upload the descriptor file
69
52
data = json .dumps (items )
70
53
return self .client .upload_data (data ,
71
54
content_type = "application/json" ,
72
55
filename = "json_import.json" )
73
56
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 ):
78
58
"""
79
59
This function is used to prepare the input file. The user defined input is validated, processed, and json stringified.
80
60
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,
102
82
103
83
Args:
104
84
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.
107
85
108
86
Returns:
109
87
uri (string): A reference to the uploaded json data.
@@ -137,12 +115,6 @@ def validate_attachments(item):
137
115
attachments = item .get ('attachments' )
138
116
if attachments :
139
117
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
- )
146
118
for attachment in attachments :
147
119
AssetAttachment .validate_attachment_json (attachment )
148
120
else :
0 commit comments