Skip to content

Commit ce029be

Browse files
committed
Rework ClinGen LDH Access Endpoint Environment Variable
1 parent f3c4a77 commit ce029be

File tree

7 files changed

+40
-16
lines changed

7 files changed

+40
-16
lines changed

settings/.env.template

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,12 @@ HGVS_SEQREPO_DIR=/usr/local/share/seqrepo/2024-12-20
6060
MAVEDB_BASE_URL=http://app:8000
6161
MAVEDB_API_KEY=secret
6262
DCD_MAPPING_URL=http://dcd-mapping:8000
63+
64+
####################################################################################################
65+
# Environment variables for ClinGen
66+
####################################################################################################
67+
68+
GENBOREE_ACCOUNT_NAME=
69+
GENBOREE_ACCOUNT_PASSWORD=
70+
CLIN_GEN_TENANT=
71+
CLIN_GEN_SUBMISSION_ENABLED=
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import os
22

3-
CLIN_GEN_SUBMISSION_ENABLED = os.getenv("SUBMISSION_ENABLED", "false").lower() == "true"
3+
CLIN_GEN_SUBMISSION_ENABLED = os.getenv("CLIN_GEN_SUBMISSION_ENABLED", "false").lower() == "true"
44

55
GENBOREE_ACCOUNT_NAME = os.getenv("GENBOREE_ACCOUNT_NAME")
66
GENBOREE_ACCOUNT_PASSWORD = os.getenv("GENBOREE_ACCOUNT_PASSWORD")
77

88
CLIN_GEN_TENANT = os.getenv("CLIN_GEN_TENANT")
9-
LDH_TENANT = os.getenv("LDH_TENANT")
109

1110
LDH_SUBMISSION_TYPE = "cg-ldh-ld-submission"
1211
LDH_ENTITY_NAME = "MaveDBMapping"
1312
LDH_ENTITY_ENDPOINT = "maveDb" # for some reason, not the same :/
1413

1514
DEFAULT_LDH_SUBMISSION_BATCH_SIZE = 100
16-
LDH_SUBMISSION_URL = f"https://genboree.org/mq/brdg/pulsar/{CLIN_GEN_TENANT}/ldh/submissions/{LDH_ENTITY_ENDPOINT}"
17-
LDH_LINKED_DATA_URL = f"https://genboree.org/{LDH_TENANT}/{LDH_ENTITY_NAME}/id"
15+
LDH_SUBMISSION_ENDPOINT = f"https://genboree.org/mq/brdg/pulsar/{CLIN_GEN_TENANT}/ldh/submissions/{LDH_ENTITY_ENDPOINT}"
16+
LDH_ACCESS_ENDPOINT = os.getenv("LDH_ACCESS_ENDPOINT", "https://genboree.org/ldh")
17+
LDH_MAVE_ACCESS_ENDPOINT = f"{LDH_ACCESS_ENDPOINT}/{LDH_ENTITY_NAME}/id"
1818

1919
LINKED_DATA_RETRY_THRESHOLD = 0.95

src/mavedb/lib/clingen/linked_data_hub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from jose import jwt
1010

1111
from mavedb.lib.logging.context import logging_context, save_to_logging_context, format_raised_exception_info_as_dict
12-
from mavedb.lib.clingen.constants import GENBOREE_ACCOUNT_NAME, GENBOREE_ACCOUNT_PASSWORD, LDH_LINKED_DATA_URL
12+
from mavedb.lib.clingen.constants import GENBOREE_ACCOUNT_NAME, GENBOREE_ACCOUNT_PASSWORD, LDH_MAVE_ACCESS_ENDPOINT
1313

1414
from mavedb.lib.types.clingen import LdhSubmission
1515
from mavedb.lib.utils import batched
@@ -212,7 +212,7 @@ def get_clingen_variation(urn: str) -> Optional[dict]:
212212
or None if the request fails.
213213
"""
214214
response = requests.get(
215-
f"{LDH_LINKED_DATA_URL}/{parse.quote_plus(urn)}",
215+
f"{LDH_MAVE_ACCESS_ENDPOINT}/{parse.quote_plus(urn)}",
216216
headers={"Accept": "application/json"},
217217
)
218218

src/mavedb/scripts/clingen_ldh_submission.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
from mavedb.models.mapped_variant import MappedVariant
1111
from mavedb.scripts.environment import with_database_session
1212
from mavedb.lib.clingen.linked_data_hub import ClinGenLdhService
13-
from mavedb.lib.clingen.constants import DEFAULT_LDH_SUBMISSION_BATCH_SIZE, LDH_SUBMISSION_URL
13+
from mavedb.lib.clingen.constants import DEFAULT_LDH_SUBMISSION_BATCH_SIZE, LDH_SUBMISSION_ENDPOINT
1414
from mavedb.lib.clingen.content_constructors import construct_ldh_submission
1515
from mavedb.lib.variants import hgvs_from_mapped_variant
1616

1717
logger = logging.getLogger(__name__)
1818

1919

2020
def submit_urns_to_clingen(db: Session, urns: Sequence[str], debug: bool) -> list[str]:
21-
ldh_service = ClinGenLdhService(url=LDH_SUBMISSION_URL)
21+
ldh_service = ClinGenLdhService(url=LDH_SUBMISSION_ENDPOINT)
2222
ldh_service.authenticate()
2323

2424
submitted_entities = []

src/mavedb/worker/jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from mavedb.db.view import refresh_all_mat_views
1818
from mavedb.lib.clingen.constants import (
1919
DEFAULT_LDH_SUBMISSION_BATCH_SIZE,
20-
LDH_SUBMISSION_URL,
20+
LDH_SUBMISSION_ENDPOINT,
2121
LINKED_DATA_RETRY_THRESHOLD,
2222
CLIN_GEN_SUBMISSION_ENABLED,
2323
)
@@ -792,7 +792,7 @@ async def submit_score_set_mappings_to_ldh(ctx: dict, correlation_id: str, score
792792
return {"success": False, "retried": False, "enqueued_job": None}
793793

794794
try:
795-
ldh_service = ClinGenLdhService(url=LDH_SUBMISSION_URL)
795+
ldh_service = ClinGenLdhService(url=LDH_SUBMISSION_ENDPOINT)
796796
ldh_service.authenticate()
797797
except Exception as e:
798798
send_slack_error(e)

tests/lib/clingen/test_linked_data_hub.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
cdot = pytest.importorskip("cdot")
1212
fastapi = pytest.importorskip("fastapi")
1313

14-
from mavedb.lib.clingen.constants import LDH_LINKED_DATA_URL, GENBOREE_ACCOUNT_NAME, GENBOREE_ACCOUNT_PASSWORD
14+
from mavedb.lib.clingen.constants import LDH_MAVE_ACCESS_ENDPOINT, GENBOREE_ACCOUNT_NAME, GENBOREE_ACCOUNT_PASSWORD
1515
from mavedb.lib.utils import batched
1616
from mavedb.lib.clingen.linked_data_hub import (
1717
ClinGenLdhService,
@@ -225,7 +225,7 @@ def test_get_clingen_variation_success(mock_get):
225225

226226
assert result == mocked_response_json
227227
mock_get.assert_called_once_with(
228-
f"{LDH_LINKED_DATA_URL}/{parse.quote_plus(urn)}",
228+
f"{LDH_MAVE_ACCESS_ENDPOINT}/{parse.quote_plus(urn)}",
229229
headers={"Accept": "application/json"},
230230
)
231231

@@ -242,7 +242,7 @@ def test_get_clingen_variation_failure(mock_get):
242242

243243
assert result is None
244244
mock_get.assert_called_once_with(
245-
f"{LDH_LINKED_DATA_URL}/{parse.quote_plus(urn)}",
245+
f"{LDH_MAVE_ACCESS_ENDPOINT}/{parse.quote_plus(urn)}",
246246
headers={"Accept": "application/json"},
247247
)
248248

tests/worker/test_jobs.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,11 +2027,26 @@ async def test_link_score_set_mappings_to_ldh_objects_exception_while_parsing_li
20272027
standalone_worker_context,
20282028
)
20292029

2030+
async def dummy_linking_job():
2031+
return [
2032+
(variant_urn, TEST_CLINGEN_LDH_LINKING_RESPONSE)
2033+
for variant_urn in session.scalars(
2034+
select(Variant.urn).join(ScoreSetDbModel).where(ScoreSetDbModel.urn == score_set.urn)
2035+
).all()
2036+
]
2037+
20302038
# We are unable to mock requests via requests_mock that occur inside another event loop. Instead, patch the return
20312039
# value of the EventLoop itself, which would have made the request.
2032-
with patch(
2033-
"mavedb.lib.clingen.linked_data_hub.clingen_allele_id_from_ldh_variation",
2034-
side_effect=Exception(),
2040+
with (
2041+
patch.object(
2042+
_UnixSelectorEventLoop,
2043+
"run_in_executor",
2044+
return_value=dummy_linking_job(),
2045+
),
2046+
patch(
2047+
"mavedb.worker.jobs.clingen_allele_id_from_ldh_variation",
2048+
side_effect=Exception(),
2049+
),
20352050
):
20362051
result = await link_clingen_variants(standalone_worker_context, uuid4().hex, score_set.id, 1)
20372052

0 commit comments

Comments
 (0)