@@ -140,25 +140,18 @@ def create_data_row(self, items=None, **kwargs) -> "DataRow":
140
140
any of the field names given in `kwargs`.
141
141
ResourceCreationError: If data row creation failed on the server side.
142
142
"""
143
- file_upload_thread_count = 1
144
- args = items if items is not None else kwargs
143
+ invalid_argument_error = "Argument to create_data_row() must be either a dictionary, or kwargs containing `row_data` at minimum"
145
144
146
- upload_items = self ._separate_and_process_items ([args ])
147
- specs = DataRowCreateItem .build (self .uid , upload_items )
148
- task : DataUpsertTask = self ._exec_upsert_data_rows (
149
- specs , file_upload_thread_count )
145
+ if items is not None and len (kwargs ) > 0 :
146
+ raise InvalidQueryError (invalid_argument_error )
150
147
151
- task . wait_till_done ()
148
+ args = items if items is not None else kwargs
152
149
153
- if task .has_errors ():
154
- raise ResourceCreationError (
155
- f"Data row upload errors: { task .errors } " , cause = task .uid )
156
- if task .status != "COMPLETE" :
157
- raise ResourceCreationError (
158
- f"Data row upload did not complete, task status { task .status } task id { task .uid } "
159
- )
150
+ file_upload_thread_count = 1
151
+ completed_task = self ._create_data_rows_sync (
152
+ [args ], file_upload_thread_count = file_upload_thread_count )
160
153
161
- res = task .result
154
+ res = completed_task .result
162
155
if res is None or len (res ) == 0 :
163
156
raise ResourceCreationError (
164
157
f"Data row upload did not complete, task status { task .status } task id { task .uid } "
@@ -190,8 +183,17 @@ def create_data_rows_sync(
190
183
a DataRow.
191
184
ValueError: When the upload parameters are invalid
192
185
"""
193
- max_data_rows_supported = 1000
194
186
max_attachments_per_data_row = 5
187
+ self ._create_data_rows_sync (
188
+ items , file_upload_thread_count = file_upload_thread_count )
189
+
190
+ return None # Return None if no exception is raised
191
+
192
+ def _create_data_rows_sync (self ,
193
+ items ,
194
+ file_upload_thread_count = FILE_UPLOAD_THREAD_COUNT
195
+ ) -> "DataUpsertTask" :
196
+ max_data_rows_supported = 1000
195
197
if len (items ) > max_data_rows_supported :
196
198
raise ValueError (
197
199
f"Dataset.create_data_rows_sync() supports a max of { max_data_rows_supported } data rows."
@@ -215,7 +217,7 @@ def create_data_rows_sync(
215
217
f"Data row upload did not complete, task status { task .status } task id { task .uid } "
216
218
)
217
219
218
- return None
220
+ return task
219
221
220
222
def create_data_rows (self ,
221
223
items ,
0 commit comments