@@ -291,10 +291,22 @@ def upload_files(
291
291
response = self ._upload_file (fp , attach_to = attach_to )
292
292
responses .append (response )
293
293
else :
294
+
295
+ # Disable the auto attach to avoid race condition
294
296
responses = self ._upload_files_parallel (
295
- files , n = n , attach_to = attach_to , progress = progress
297
+ files , n = n , attach_to = None , progress = progress
296
298
)
297
299
300
+ if attach_to :
301
+
302
+ file_ids = list ()
303
+
304
+ for response in responses :
305
+ file_id = response .get ("data" ).get ("files" )[0 ].get ("file" )
306
+ file_ids .append (file_id )
307
+
308
+ self .attach_files_to_model_output (id = attach_to , files = file_ids )
309
+
298
310
return mu .ensure_list (responses )
299
311
300
312
def _upload_file (
@@ -503,3 +515,19 @@ def success(self) -> bool:
503
515
True if successful, False otherwise.
504
516
"""
505
517
return self .last_response .status_code in mcc .HTTP_STATUS_SUCCESS_RANGE
518
+
519
+ def is_initialised (self , dev : bool = False ) -> bool :
520
+ """Check if the client is initialised.
521
+ NOTE: This does not check the login actually works.
522
+ Parameters
523
+ ----------
524
+ dev : bool, optional
525
+ Use dev credentials, by default False
526
+ Returns
527
+ -------
528
+ bool
529
+ True if initialised, False otherwise.
530
+ """
531
+ cred_filename = "credentials.json" if not dev else "credentials-dev.json"
532
+ cred_filepath = mu .get_user_data_filepath (cred_filename )
533
+ return cred_filepath .exists ()
0 commit comments