Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix: daemon should write out the error in the results #144

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@ def ingest_file(file_path):
try:
with open(file_path) as f:
json_data = json.load(f)
if json_data is not None:
logger.info(f"Ingesting {file_path}")
if "katsu" in json_data:
json_data = json_data["katsu"]
programs = list(json_data.keys())
for program_id in programs:
try:
ingest_results, status_code = ingest_schemas(json_data[program_id]["schemas"])
results[program_id] = ingest_results
except Exception as e:
results[program_id] = f"Exception: {type(e)} {str(e)}"
elif "htsget" in json_data:
do_not_index = False
if "do_not_index" in json_data:
do_not_index = json_data["do_not_index"]
json_data = json_data["htsget"]
programs = list(json_data.keys())
for program_id in programs:
try:
ingest_results, status_code = htsget_ingest(json_data[program_id], do_not_index)
results[program_id] = ingest_results
except Exception as e:
results[program_id] = f"Exception: {type(e)} {str(e)}"
os.remove(file_path)
except Exception as e:
message = f"Couldn't load data from {file_path}: {type(e)} {str(e)}"
logger.error(message)
results["error"] = message
if json_data is not None:
logger.info(f"Ingesting {file_path}")
if "katsu" in json_data:
json_data = json_data["katsu"]
programs = list(json_data.keys())
for program_id in programs:
try:
ingest_results, status_code = ingest_schemas(json_data[program_id]["schemas"])
results[program_id] = ingest_results
except Exception as e:
results[program_id] = f"Exception: {type(e)} {str(e)}"
elif "htsget" in json_data:
do_not_index = False
if "do_not_index" in json_data:
do_not_index = json_data["do_not_index"]
json_data = json_data["htsget"]
programs = list(json_data.keys())
for program_id in programs:
try:
ingest_results, status_code = htsget_ingest(json_data[program_id], do_not_index)
results[program_id] = ingest_results
except Exception as e:
results[program_id] = f"Exception: {type(e)} {str(e)}"
with open(results_path, "w") as f:
json.dump(results, f)
os.remove(file_path)
return results, status_code
return {"error": f"No such file {file_path}"}, 404
status_code = 500
with open(results_path, "w") as f:
json.dump(results, f)
return results, status_code


class DaemonHandler(watchdog.events.FileSystemEventHandler):
Expand Down