Skip to content

Commit

Permalink
Merge pull request #670 from oda-hub/return-progress-dedicated-output…
Browse files Browse the repository at this point in the history
…-file

read and store return-progress output on a dedicated output file
  • Loading branch information
burnout87 authored Apr 23, 2024
2 parents 7331d28 + 53dd71a commit 8d519bf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cdci_data_analysis/flask_app/dispatcher_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,9 +1466,6 @@ def build_dispatcher_response(self,
out_dict['job_monitor'] = job_monitor
out_dict['job_status'] = job_monitor['status']

if job_monitor is not None:
out_dict['job_monitor'] = job_monitor

out_dict['session_id'] = self.par_dic['session_id']

if status_code is not None:
Expand Down Expand Up @@ -1817,16 +1814,20 @@ def request_query_out(self, overwrite=False):
def store_response(self, query_out, job_monitor):
self.logger.info("storing query output: %s, %s",
self.response_filename, self.response_log_filename)

if os.path.exists(self.response_filename):
if not os.path.exists(self.query_log_dir):
os.makedirs(self.query_log_dir)
# if not self.return_progress:
os.rename(self.response_filename, self.response_log_filename)
self.logger.info("renamed query log log %s => %s",
self.response_filename, self.response_log_filename)

if self.return_progress:
json.dump(job_monitor, open(self.response_filename + ".return-progress-job-monitor", "w"))
else:
json.dump(job_monitor, open(self.response_filename + ".job-monitor", "w"))
query_out.serialize(open(self.response_filename, "w"))
json.dump(job_monitor, open(
self.response_filename + ".job-monitor", "w"))

def load_config(self):
try:
Expand Down Expand Up @@ -2286,8 +2287,8 @@ def run_query(self, off_line=False, disp_conf=None):
else:
query_new_status = 'failed'
job.set_failed()

job.write_dataserver_status()
if not self.return_progress:
job.write_dataserver_status()

print('-----------------> query status update for done/ready: ',
query_new_status)
Expand Down Expand Up @@ -2346,7 +2347,7 @@ def run_query(self, off_line=False, disp_conf=None):
self.logger.info(
'==============================> query done <==============================')

if not job_is_aliased and query_status != query_new_status:
if not job_is_aliased and query_status != query_new_status and not self.return_progress:
job.write_dataserver_status()

if not self.async_dispatcher:
Expand Down

0 comments on commit 8d519bf

Please sign in to comment.