From 13e3db3c060faa5c0d630a536b2daa4f94064b94 Mon Sep 17 00:00:00 2001 From: AndiMajore <andi.majore@googlemail.com> Date: Tue, 14 Mar 2023 16:33:43 +0100 Subject: [PATCH] security patch; fixing update issues Former-commit-id: bc6d68252e9f71e99ffa7c5f9fcbcee9e069eae9 [formerly db4cfd0d69a4a31b86b68901e80c30f6233a189e] Former-commit-id: 12cb75353e319d4f01f72e209ef395f0cbee3bbc --- Dockerfile | 2 +- drugstone/management/commands/import_from_nedrex.py | 11 +++++++---- drugstone/management/commands/populate_db.py | 1 + drugstone/management/includes/DataPopulator.py | 3 +++ drugstone/settings/celery_schedule.py | 2 +- requirements.txt | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 924a5c6..e68733e 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM andimajore/miniconda3_kinetic +FROM andimajore/miniconda3_lunar WORKDIR /usr/src/drugstone/ diff --git a/drugstone/management/commands/import_from_nedrex.py b/drugstone/management/commands/import_from_nedrex.py index dd8a434..472bca8 100644 --- a/drugstone/management/commands/import_from_nedrex.py +++ b/drugstone/management/commands/import_from_nedrex.py @@ -116,10 +116,13 @@ class NedrexImporter: proteins[id] = models.Protein(uniprot_code=id, protein_name=name, gene=gene) def add_edges(edge): - id = to_id(edge['sourceDomainId']) - protein = proteins[id] - protein.entrez = to_id(edge['targetDomainId']) - gene_to_prots[protein.entrez].add(id) + try: + id = to_id(edge['sourceDomainId']) + protein = proteins[id] + protein.entrez = to_id(edge['targetDomainId']) + gene_to_prots[protein.entrez].add(id) + except: + print(f'Edge could not be saved: {edge["sourceDomainId"]} - {edge["targetDomainId"]}') def add_genes(node): id = to_id(node['primaryDomainId']) diff --git a/drugstone/management/commands/populate_db.py b/drugstone/management/commands/populate_db.py index 5bc37ed..0c2ec75 100755 --- a/drugstone/management/commands/populate_db.py +++ b/drugstone/management/commands/populate_db.py @@ -118,6 +118,7 @@ def populate(kwargs): total_n = 0 nedrex_update = False + if 'all' in kwargs and kwargs['all']: kwargs['drugs'] = True kwargs['disorders'] = True diff --git a/drugstone/management/includes/DataPopulator.py b/drugstone/management/includes/DataPopulator.py index 01715b4..4a4a570 100755 --- a/drugstone/management/includes/DataPopulator.py +++ b/drugstone/management/includes/DataPopulator.py @@ -22,6 +22,9 @@ class DataPopulator: bulk = set() uniq = set() + if update: + uniq = {hash(expr) for expr in models.ExpressionLevel.objects.all()} + size = 0 for _, row in df.iterrows(): gene_name = row['Description'] diff --git a/drugstone/settings/celery_schedule.py b/drugstone/settings/celery_schedule.py index 6c06894..0e52106 100644 --- a/drugstone/settings/celery_schedule.py +++ b/drugstone/settings/celery_schedule.py @@ -3,7 +3,7 @@ from celery.schedules import crontab CELERY_BEAT_SCHEDULE = { 'update_db': { 'task': 'drugstone.tasks.task_update_db_from_nedrex', - 'schedule': crontab(day_of_week=2, hour=3, minute=0), + 'schedule': crontab(day_of_week=1, hour=22, minute=0), # 'schedule': crontab(minute='*/1'), }, } diff --git a/requirements.txt b/requirements.txt index 499918e..eafb7ef 100755 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ chardet==3.0.4 click==8.1.3 cryptography==39.0.1 decorator==4.4.2 -Django==3.2.17 +Django==3.2.18 django-cors-headers==3.4.0 django-redis==4.11.0 django-rq-dashboard==0.3.3 -- GitLab