Skip to content

Commit

Permalink
DMI service manager: handle request already exists; fix check_progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dale-wahl committed Aug 1, 2023
1 parent 834e8bb commit b810ccb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions common/lib/dmi_service_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def process_files(self, input_file_dir, filenames, output_file_dir, server_file_

def check_progress(self):
if self.local_or_remote == "local":
current_completed = self.count_local_files(self.path_to_results)
current_completed = self.count_local_files(self.processor.config.get("PATH_DATA").joinpath(self.path_to_results))
elif self.local_or_remote == "remote":
existing_files = self.request_folder_files(self.server_file_collection_name)
current_completed = len(existing_files.get(self.server_results_folder_name, []))
Expand Down Expand Up @@ -127,7 +127,11 @@ def send_request_and_wait_for_results(self, service_endpoint, data, wait_period=
else:
try:
resp_json = resp.json()
raise DmiServiceManagerException(f"DMI Service Manager error: {str(resp.status_code)}: {str(resp_json)}")
if resp.status_code == 400 and 'key' in resp_json and 'error' in resp_json and resp_json['error'] == f"future_key {resp_json['key']} already exists":
# Request already exists
results_url = api_endpoint + "?key=" + resp_json['key']
else:
raise DmiServiceManagerException(f"DMI Service Manager error: {str(resp.status_code)}: {str(resp_json)}")
except JSONDecodeError:
# Unexpected Error
raise DmiServiceManagerException(f"DMI Service Manager error: {str(resp.status_code)}: {str(resp.text)}")
Expand Down

0 comments on commit b810ccb

Please sign in to comment.