Skip to content

Commit 091c99c

Browse files
committed
Merge branch 'dev' of github.com:dowjones/factiva-analytics-python into dev
2 parents b32f55e + 99337b5 commit 091c99c

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/factiva/analytics/common/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
API_JOB_DONE_STATE, API_JOB_FAILED_STATE, API_JOB_CANCELLED_STATE
9797
]
9898

99-
API_JOB_ACTIVE_WAIT_SPACING = 10
99+
API_JOB_ACTIVE_WAIT_SPACING = 15
100100

101101
# SNAPSHOT FILES
102102
SNAPSHOT_FILE_STATS_FIELDS = [

src/factiva/analytics/integration/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class SnapshotFiles(object):
88

99

10-
def read_file(self, filepath, stats_only=False, merge_body=False, all_fields=False) -> pd.DataFrame:
10+
def read_avro_file(self, filepath, stats_only=False, merge_body=False, all_fields=False) -> pd.DataFrame:
1111
"""Reads a single Dow Jones snapshot datafile
1212
Parameters
1313
----------

src/factiva/analytics/snapshots/extraction.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)