@@ -233,7 +233,7 @@ def download(
233233 job_id : str ,
234234 filename_to_download : Optional [str ] = None ,
235235 enable_partial_downloads : bool = True ,
236- ) -> None :
236+ ) -> List [ Path ] :
237237 """
238238 Download a batch job or a specific file to `{output_dir}/{job_id}/`.
239239
@@ -254,6 +254,18 @@ def download(
254254 enable_partial_downloads : bool, default True
255255 If partially downloaded files will be resumed using range request(s).
256256
257+ Returns
258+ -------
259+ List[Path]
260+ A list of paths to the downloaded files.
261+
262+ Raises
263+ ------
264+ RuntimeError
265+ When no files were found for the batch job.
266+ ValueError
267+ When a file fails to download.
268+
257269 """
258270 output_dir = validate_path (output_dir , "output_dir" )
259271 self ._check_api_key ()
@@ -270,7 +282,7 @@ def download(
270282
271283 if not job_files :
272284 logger .error ("Cannot download batch job %s (no files found)." , job_id )
273- return
285+ raise RuntimeError ( f"no files for batch job { job_id } " )
274286
275287 if filename_to_download :
276288 # A specific file is being requested
@@ -287,12 +299,15 @@ def download(
287299 job_id ,
288300 filename_to_download ,
289301 )
290- return
302+ raise ValueError (
303+ f"{ filename_to_download } is not a file for batch job { job_id } " ,
304+ )
291305
292306 # Prepare job directory
293307 job_dir = Path (output_dir ) / job_id
294308 os .makedirs (job_dir , exist_ok = True )
295309
310+ file_paths = []
296311 for details in job_files :
297312 filename = str (details ["filename" ])
298313 output_path = job_dir / filename
@@ -320,6 +335,9 @@ def download(
320335 output_path = output_path ,
321336 enable_partial_downloads = enable_partial_downloads ,
322337 )
338+ file_paths .append (output_path )
339+
340+ return file_paths
323341
324342 def _download_file (
325343 self ,
@@ -355,7 +373,7 @@ async def download_async(
355373 job_id : str ,
356374 filename_to_download : Optional [str ] = None ,
357375 enable_partial_downloads : bool = True ,
358- ) -> None :
376+ ) -> List [ Path ] :
359377 """
360378 Asynchronously download a batch job or a specific file to
361379 `{output_dir}/{job_id}/`.
@@ -377,6 +395,18 @@ async def download_async(
377395 enable_partial_downloads : bool, default True
378396 If partially downloaded files will be resumed using range request(s).
379397
398+ Returns
399+ -------
400+ List[Path]
401+ A list of paths to the downloaded files.
402+
403+ Raises
404+ ------
405+ RuntimeError
406+ When no files were found for the batch job.
407+ ValueError
408+ When a file fails to download.
409+
380410 """
381411 output_dir = validate_path (output_dir , "output_dir" )
382412 self ._check_api_key ()
@@ -393,7 +423,7 @@ async def download_async(
393423
394424 if not job_files :
395425 logger .error ("Cannot download batch job %s (no files found)." , job_id )
396- return
426+ raise RuntimeError ( f"no files for batch job { job_id } " )
397427
398428 if filename_to_download :
399429 # A specific file is being requested
@@ -406,16 +436,19 @@ async def download_async(
406436 break
407437 if not is_file_found :
408438 logger .error (
409- "Cannot download batch job %s file " " (%s not found)" ,
439+ "Cannot download batch job %s file (%s not found)" ,
410440 job_id ,
411441 filename_to_download ,
412442 )
413- return
443+ raise ValueError (
444+ f"{ filename_to_download } is not a file for batch job { job_id } " ,
445+ )
414446
415447 # Prepare job directory
416448 job_dir = Path (output_dir ) / job_id
417449 os .makedirs (job_dir , exist_ok = True )
418450
451+ file_paths = []
419452 for details in job_files :
420453 filename = str (details ["filename" ])
421454 output_path = job_dir / filename
@@ -443,6 +476,9 @@ async def download_async(
443476 output_path = output_path ,
444477 enable_partial_downloads = enable_partial_downloads ,
445478 )
479+ file_paths .append (output_path )
480+
481+ return file_paths
446482
447483 async def _download_file_async (
448484 self ,
0 commit comments