@@ -313,7 +313,8 @@ def get_job_response(self) -> bool:
313313 Returns
314314 -------
315315 bool
316- True if the get request was successful. An Exception otherwise.
316+ True if the get request was successful. False for FAILED jobs
317+ and an Exception for unexpected HTTP codes.
317318
318319 Raises
319320 ------
@@ -349,6 +350,7 @@ def get_job_response(self) -> bool:
349350 self .job_response .errors = response_data ['errors' ]
350351 for err in self .job_response .errors :
351352 self .__log .error (f"JobError: [{ err ['title' ]} ] { err ['detail' ]} " )
353+ return False
352354 elif response .status_code == 404 :
353355 raise ValueError ('Job ID does not exist for the provided user key.' )
354356 elif response .status_code == 400 :
@@ -433,7 +435,7 @@ def download_files(self, path=None):
433435 else :
434436 print ("Job has not yet been submitted" )
435437 self .__log .info ('download_files end' )
436- return False
438+ return False
437439
438440
439441 @log .factiva_logger
@@ -445,13 +447,14 @@ def process_job(self, path=None): # TODO: Implement Retries if a 500 or timeout
445447 Returns
446448 -------
447449 bool
448- True if the extraction processing was successful. An Exception
449- otherwise.
450+ True if the extraction processing was successful. False if the job
451+ execution failed. An Exception otherwise.
450452
451453 """
454+ ret_val = True
452455 self .__log .info ('process_job Start' )
453456 self .submit_job ()
454- self .get_job_response ()
457+ ret_val = self .get_job_response ()
455458
456459 while not (self .job_response .job_state in
457460 [const .API_JOB_DONE_STATE ,
@@ -460,14 +463,15 @@ def process_job(self, path=None): # TODO: Implement Retries if a 500 or timeout
460463 if self .job_response .job_state not in const .API_JOB_EXPECTED_STATES :
461464 raise RuntimeError ('Unexpected job state' )
462465 time .sleep (const .API_JOB_ACTIVE_WAIT_SPACING )
463- self .get_job_response ()
466+ if (not self .get_job_response ()):
467+ ret_val = False
464468
465469 if len (self .job_response .files ) > 0 :
466470 self .download_files (path = path )
467471 else :
468472 self .__log .info ('No files to download. Check for error messages.' )
469473 self .__log .info ('process_job End' )
470- return True
474+ return ret_val
471475
472476
473477 def __repr__ (self ):
0 commit comments