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: tweaks to htsget ingest, respawn daemon #127

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
until python daemon.py; do
echo "Daemon crashed with exit code $?. Respawning.." >&2
sleep 1
done
19 changes: 17 additions & 2 deletions htsget_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
def link_genomic_data(sample, do_not_index=False):
url = f"{HTSGET_URL}/ga4gh/drs/v1/objects"
result = {
"errors": []
"errors": [],
"to_index": []
}

# Use service token to authenticate this with htsget
Expand Down Expand Up @@ -137,7 +138,7 @@ def link_genomic_data(sample, do_not_index=False):
# flag the genomic_drs_object for indexing:
logger.debug(f"Are we indexing? do_not_index = {do_not_index}")
url =f"{HTSGET_URL}/htsget/v1/{sample['metadata']['data_type']}s/{genomic_drs_obj['id']}/index"
response = requests.get(url, headers=headers, params={"do_not_index": do_not_index})
result["to_index"].append(url)
return result


Expand Down Expand Up @@ -223,6 +224,7 @@ def htsget_ingest(ingest_json, do_not_index=False):
"errors": {},
"results": {}
}
to_index = []
status_code = 200
for sample in ingest_json:
logger.debug(f"Ingesting {sample['genomic_file_id']}, do_not_index = {do_not_index}")
Expand All @@ -240,8 +242,21 @@ def htsget_ingest(ingest_json, do_not_index=False):
if len(result["errors"][sample["genomic_file_id"]]) == 0:
result["errors"].pop(sample["genomic_file_id"])
response.pop("errors")
to_index.extend(response["to_index"])
if len(response) > 0:
result["results"][sample["genomic_file_id"]] = response
# Use service token to authenticate this with htsget
headers = {}
if not IS_TESTING:
headers = {
"X-Service-Token": create_service_token(),
"Content-Type": "application/json"
}

# send off index calls
for url in to_index:
response = requests.get(url, headers=headers, params={"do_not_index": do_not_index})

return result, status_code


Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
mkdir -p $DAEMON_PATH/to_ingest
mkdir -p $DAEMON_PATH/results
python /ingest_app/daemon.py &
bash /ingest_app/daemon.sh &

gunicorn server:app