From 2b58a3b50c74c956678a21fc61909c8a13fb1098 Mon Sep 17 00:00:00 2001 From: AndiMajore <andi.majore@googlemail.com> Date: Mon, 5 Dec 2022 10:51:49 +0100 Subject: [PATCH] added env variable to toggle startup update Former-commit-id: da8017732756d3bd9956f1da010b3187b34c4d16 [formerly ea203bffa93fcb1941bc3ceb7221bcb85b5dd4e8] Former-commit-id: 57f29f748fe0ecb1b857be59a827eab886e2c0d8 --- docker-django.env | 3 ++- docker-django.env.dev | 3 ++- drugstone/management/commands/populate_db.py | 22 ++++++++++---------- drugstone/settings/celery_schedule.py | 2 +- scripts/docker-entrypoint.sh | 10 ++++++--- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/docker-django.env b/docker-django.env index 9bf4bf3..defd3e7 100755 --- a/docker-django.env +++ b/docker-django.env @@ -12,4 +12,5 @@ REDIS_HOST=redis REDIS_PORT=6379 GT_THREADS=16 DJANGO_SETTINGS_MODULE=drugstone.settings -CELERY_BROKER_URL=redis://redis:6379/0 \ No newline at end of file +CELERY_BROKER_URL=redis://redis:6379/0 +DB_UPDATE_ON_START=0 \ No newline at end of file diff --git a/docker-django.env.dev b/docker-django.env.dev index 1f3d65d..91d6c04 100644 --- a/docker-django.env.dev +++ b/docker-django.env.dev @@ -14,4 +14,5 @@ DJANGO_SETTINGS_MODULE=drugstone.settings CELERY_BROKER_URL=redis://redis:6379/0 FLOWER_PORT=8888 FLOWER_BASIC_AUTH=drugstone:test -GT_THREADS=2 \ No newline at end of file +GT_THREADS=2 +DB_UPDATE_ON_START=0 \ No newline at end of file diff --git a/drugstone/management/commands/populate_db.py b/drugstone/management/commands/populate_db.py index 497b3d1..690ec3b 100755 --- a/drugstone/management/commands/populate_db.py +++ b/drugstone/management/commands/populate_db.py @@ -150,20 +150,20 @@ def populate(kwargs): print(f'Populated {n} Expressions.') if kwargs['protein_drug']: - print('Importing PDIs from unlicenced NeDRexDB...') + print('Importing PDIs from unlicensed NeDRexDB...') n = NedrexImporter.import_drug_target_interactions(importer, DatasetLoader.get_drug_target_nedrex(nedrex_api_url_open, False), update) total_n += n - print(f'Imported {n} PDIs from unlicenced NeDRexDB') + print(f'Imported {n} PDIs from unlicensed NeDRexDB') - print('Importing PDIs from licenced NeDRexDB...') + print('Importing PDIs from licensed NeDRexDB...') n = NedrexImporter.import_drug_target_interactions(importer, DatasetLoader.get_drug_target_nedrex(nedrex_api_url_licensed, True), update) total_n += n nedrex_update = True - print(f'Imported {n} PDIs from licenced NeDRexDB') + print(f'Imported {n} PDIs from licensed NeDRexDB') print('Populating PDIs from Chembl...') n = DataPopulator.populate_pdi_chembl(populator, DatasetLoader.get_drug_target_chembl(), update) @@ -176,13 +176,13 @@ def populate(kwargs): print(f'Populated {n} PDIs from DGIdb.') if kwargs['protein_disorder']: - print('Importing PDis from unlicenced NeDRexDB...') + print('Importing PDis from unlicensed NeDRexDB...') n = NedrexImporter.import_protein_disorder_associations(importer, DatasetLoader.get_protein_disorder_nedrex( nedrex_api_url_open, False), update) total_n += n - print(f'Imported {n} PDis from unlicenced NeDRexDB') + print(f'Imported {n} PDis from unlicensed NeDRexDB') print('Importing PDis from licenced NeDRexDB...') n = NedrexImporter.import_protein_disorder_associations(importer, @@ -194,12 +194,12 @@ def populate(kwargs): print(f'Imported {n} PDis from licenced NeDRexDB') if kwargs['drug_disorder']: - print('Importing DrDis from unlicenced NeDRexDB...') + print('Importing DrDis from unlicensed NeDRexDB...') n = NedrexImporter.import_drug_disorder_indications(importer, DatasetLoader.get_drug_disorder_nedrex(nedrex_api_url_open, False), update) total_n += n - print(f'Imported {n} DrDis from unlicenced NeDRexDB') + print(f'Imported {n} DrDis from unlicensed NeDRexDB') print('Importing DrDis from licenced NeDRexDB...') n = NedrexImporter.import_drug_disorder_indications(importer, @@ -215,12 +215,12 @@ def populate(kwargs): print(f'Populated {n} DrDi associations from DrugBank.') if kwargs['protein_protein']: - print('Importing PPIs from unlicenced NeDRexDB...') + print('Importing PPIs from unlicensed NeDRexDB...') n = NedrexImporter.import_protein_protein_interactions(importer, DatasetLoader.get_ppi_nedrex(nedrex_api_url_open, False), update) total_n += n - print(f'Imported {n} PPIs from unlicended NeDRexDB') + print(f'Imported {n} PPIs from unlicensed NeDRexDB') print('Importing PPIs from licenced NeDRexDB...') n = NedrexImporter.import_protein_protein_interactions(importer, DatasetLoader.get_ppi_nedrex(nedrex_api_url_licensed, @@ -228,7 +228,7 @@ def populate(kwargs): update) total_n += n nedrex_update = True - print(f'Imported {n} PPIs from licended NeDRexDB') + print(f'Imported {n} PPIs from licensed NeDRexDB') print('Populating PPIs from STRING...') n = DataPopulator.populate_ppi_string(populator, DatasetLoader.get_ppi_string(), update) total_n += n diff --git a/drugstone/settings/celery_schedule.py b/drugstone/settings/celery_schedule.py index d33a3a0..6c06894 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=1, hour=5, minute=0), + 'schedule': crontab(day_of_week=2, hour=3, minute=0), # 'schedule': crontab(minute='*/1'), }, } diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 43bf32d..8ce3250 100755 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -4,7 +4,11 @@ python3 manage.py makemigrations drugstone python3 manage.py migrate python3 manage.py createfixtures python3 manage.py cleanuptasks -python3 manage.py populate_db --update -a -python3 manage.py make_graphs - +if [[ -z "$DB_UPDATE_ON_START" ]] || [[ "$DB_UPDATE_ON_START" = "0" ]] +then +echo "Update on startup disabled!" +else + python3 manage.py populate_db --update -a + python3 manage.py make_graphs +fi /usr/bin/supervisord -c "/etc/supervisor/conf.d/supervisord.conf" -- GitLab