Skip to content

Commit

Permalink
Merge pull request #773 from populationgenomics/dev
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
illusional authored May 14, 2024
2 parents 5d88504 + 46a5cf5 commit 698a4de
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ It comprises three key components:

As of Jan 15, 2024 this schema should reflect the data structure on the tables:

![Database Structure](resources/schemav7.7.png.png)
![Database Structure](resources/schemav7.7.png)

You can also find this at [DbDiagram](https://dbdiagram.io/d/Metamist-Schema-v7-7-6600c875ae072629ced6a1fc).

Expand Down
9 changes: 5 additions & 4 deletions db/python/layers/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,13 +765,14 @@ async def get_seqr_individual_template(
set_headers.update(set(row.keys()))

rows = [{h: r.get(h) for h in set_headers if h in r} for r in rows]
headers = [] # get ordered headers if we have data for it
for h in SeqrMetadataKeys.get_ordered_headers():
if header := lheader_to_json.get(h.value.lower()) in set_headers:
headers.append(header)

return {
'rows': rows,
# get ordered headers if we have data for it
'headers': [
h for h in SeqrMetadataKeys.get_ordered_headers() if h in set_headers
],
'headers': headers,
'header_map': json_header_map,
}

Expand Down
2 changes: 2 additions & 0 deletions db/python/layers/seqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import aiohttp
import slack_sdk
import slack_sdk.errors
from backoff import expo, on_exception
from cloudpathlib import AnyPath

from cpg_utils.cloud import get_google_identity_token
Expand Down Expand Up @@ -498,6 +499,7 @@ async def update_es_index(
messages.extend(await asyncio.gather(*requests))
return messages

@on_exception(expo, aiohttp.ClientResponseError, max_tries=3)
async def update_saved_variants(
self,
session: aiohttp.ClientSession,
Expand Down
5 changes: 4 additions & 1 deletion etl/load/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def process_rows(
else:
status = ParsingStatus.FAILED
parsing_result = f'Error: {err_msg} when parsing record with id: {request_id}'
# TODO: should we log to error log table as well?

if delivery_attempt == 1:
# log only at the first attempt,
Expand Down Expand Up @@ -167,6 +166,10 @@ def process_rows(
# publish to notification pubsub
msg_title = 'Metamist ETL Load Failed'
try:
# limit result to max 100 characters, to avoid spamming slack
# sometimes the details can be huge, the whole stacktrace
log_details['result'] = str(parsing_result)[:100]
log_record['details'] = json.dumps(log_details)
pubsub_client = _get_pubsub_client()
pubsub_client.publish(
NOTIFICATION_PUBSUB_TOPIC,
Expand Down
12 changes: 10 additions & 2 deletions etl/notification/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ def etl_notify(request: flask.Request):
'message': f'Missing or empty message: {jbody_str}',
}, 400

# TODO: format message to slack message
message_blocks = format_slack(message)
# format message to slack message
try:
message_blocks = format_slack(message)
except Exception as e: # pylint: disable=broad-exception-caught
logging.error(f'Failed to format message: {e}, message: {message}')
return {
'success': False,
'message': f'Failed to format message: {e}',
}, 500

success = None
try:
client = WebClient(token=SLACK_BOT_TOKEN)
Expand Down
5 changes: 4 additions & 1 deletion metamist_infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ We want to package it up in a way that cpg-infrastructure deployment can consume
using [entry points](https://amir.rachum.com/python-entry-points/). Hence, this python package
contains all files required to deploy:

- Metamist ETL framework (cloud function, bigquery, pubsub), with currently no consumer
- Metamist ETL framework (cloud function, bigquery, pubsub), with currently no consumer:

![Database Structure](../resources/metamist-etl.drawio.png)


## Installation

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# requirements are for running the server
# fix boto3/core version to prevent pip downloading all the versions caused by cloudpathlib
backoff>=2.2.1
boto3==1.28.56
botocore==1.31.56
cpg-utils>=5.0.5
Expand Down
Binary file added resources/metamist-etl.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 698a4de

Please sign in to comment.