Skip to content

Commit 87506e7

Browse files
committed
Add scheduled task to update biolink mapping cache nightly
1 parent 016a9e7 commit 87506e7

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

cohd/biolink_mapper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def prefetch_mappings():
150150
mapping_rows = cur.fetchall()
151151
BiolinkConceptMapper._map_omop = {r['omop_id']:r for r in mapping_rows}
152152
BiolinkConceptMapper._map_biolink = {r['biolink_id']:r for r in mapping_rows if r['preferred']}
153+
logging.info('Biolink mappings prefetch completed')
153154

154155
@staticmethod
155156
def map_to_omop(curies: List[str]) -> Optional[Tuple[Dict[str, Optional[OmopBiolinkMapping]], Dict[str, Optional[NormalizedNode]]]]:

cohd/scheduled_tasks.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ def task_build_cache():
1010
print('Running scheduled task to build cache')
1111
BiolinkConceptMapper.build_mappings()
1212

13+
# Schedule a task to update the Biolink Mapping cache nightly (all environments)
14+
scheduler = BackgroundScheduler()
15+
scheduler.add_job(func=BiolinkConceptMapper.prefetch_mappings, trigger='cron', hour=6)
1316

1417
# Schedule a task to build the cache every first Saturday of the month (in ITRB-CI and Dev only)
1518
deployment_env = app.config.get('DEPLOYMENT_ENV', 'dev').lower()
16-
if deployment_env in ('itrb-ci', 'dev'):
17-
scheduler = BackgroundScheduler()
18-
scheduler.add_job(func=task_build_cache, trigger='cron', day='1st sat', hour=0)
19-
scheduler.start()
19+
if False:
20+
scheduler.add_job(func=task_build_cache, trigger='cron', day='1st sat', hour=0)
2021
logging.info(f'Background task scheduled to build Biolink mappings (env: {deployment_env})')
2122
else:
2223
logging.info(f'Background task NOT scheduled to build Biolink mappings (env: {deployment_env})')
2324

25+
scheduler.start()
26+
2427

2528
# Registering a shutdown seems to cause UWSGI to have issues shutting down COHD, even with the wait=False option.
2629
# Since the default job store does not persist jobs anyway, remove this line for now

0 commit comments

Comments
 (0)