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

cicd: add DB check script #543

Merged
merged 4 commits into from
Nov 27, 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
49 changes: 49 additions & 0 deletions scripts/check_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Perform basic checks on database to verify import success."""
import psycopg

# figures from 2024-11-27 dump
expected_values = {
"gene_claims": 81019,
"genes": 12062,
"drug_claims": 130616,
"drugs": 39581,
"interaction_claims": 98920,
"interactions": 69907,
"sources": 45,
"gene_category_claims": 33066,
"gene_categorizations": 20137,
"drug_approval_ratings": 13332,
"publications": 13142
}


def handle_warn(name, actual_value):
"""Just because a value drops below that of a previous release doesn't mean something's wrong;
but it'd be good to know.
"""
if expected_values[name] > actual_value:
print(f"WARNING: {name} value is {actual_value}, expected {expected_values[name]}")


def check_value(name, query):
cur.execute(query)
value = cur.fetchone()[0]
print(f"# {name}: {value}")
handle_warn(name, value)

with psycopg.connect("dbname=dgidb user=postgres") as conn:
with conn.cursor() as cur:
check_value("gene_claims", "SELECT COUNT(*) FROM gene_claims;")
check_value("genes", "SELECT COUNT(*) FROM genes;")
check_value("drug_claims", "SELECT COUNT(*) FROM drug_claims;")
check_value("drugs", "SELECT COUNT(*) FROM drugs;")
check_value("interaction_claims", "SELECT COUNT(*) FROM interaction_claims;")
check_value("interactions", "SELECT COUNT(*) FROM interactions;")

check_value("sources", "SELECT COUNT(*) FROM sources;")

check_value("gene_category_claims", "SELECT COUNT(*) FROM gene_claim_categories_gene_claims;")
check_value("gene_categorizations", "SELECT COUNT(*) FROM gene_categories_genes;")

check_value("drug_approval_ratings", "SELECT COUNT(*) FROM drug_approval_ratings;")
check_value("publications", "SELECT COUNT(*) FROM publications;")
3 changes: 3 additions & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
psycopg==3.2.3
psycopg-binary==3.2.3
typing_extensions==4.12.2