Skip to content

Commit

Permalink
fix redis
Browse files Browse the repository at this point in the history
  • Loading branch information
uhbrar committed Sep 6, 2024
1 parent 6374abb commit 35004d8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/pathfinder/get_cooccurrence.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
"""Get more than pairwise literature cooccurence for a given list of curies."""
import json
import gzip
import os
import redis
import time
from typing import List

REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
REDIS_PORT = os.environ.get("REDIS_PORT", 6379)
PMIDS_DB = os.environ.get("PMIDS_DB", 1)
CURIES_DB = os.environ.get("CURIES_DB", 2)
REDIS_PASSWORD = os.environ.get("REDIS_PASSWORD")

def get_the_pmids(curies: List[str]):
r = redis.Redis(
host="localhost",
port=6379,
db=0
host=REDIS_HOST,
port=REDIS_PORT,
db=PMIDS_DB,
password=REDIS_PASSWORD
)
curie_pmids = []
for curie in curies:
Expand All @@ -25,9 +32,10 @@ def get_the_pmids(curies: List[str]):

def get_the_curies(pmid: str):
r = redis.Redis(
host="localhost",
port=6379,
db=1
host=REDIS_HOST,
port=REDIS_PORT,
db=CURIES_DB,
password=REDIS_PASSWORD
)
curies = r.get(pmid)
if curies is None:
Expand Down

0 comments on commit 35004d8

Please sign in to comment.