Skip to content

Commit

Permalink
Patches MGI curie expansions that replace the colon with a slash erro…
Browse files Browse the repository at this point in the history
…neously (#756)

Needs a real fix upstream in curies/prefixmaps (probably prefixmaps?),
but we need this fix to for immediate release
  • Loading branch information
kevinschaper committed Jul 9, 2024
1 parent 283d550 commit d89360b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion backend/src/monarch_py/utils/entity_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from monarch_py.datamodels.model import ExpandedCurie
from monarch_py.service.curie_service import converter

Expand All @@ -6,9 +7,20 @@
]


def expansion_patch(url: str):
"""Any short term patches that we need while waiting for upstream fixes"""

# This fixes MGI urls that take the form of
# https://identifiers.org/MGI/97486
# rather than https://identifiers.org/MGI:97486
pattern = r"/MGI/(\d+)$"
replacement = r"/MGI:\1"
return re.sub(pattern, replacement, url)


def get_uri(id: str) -> str:
"""Returns the URI for the given CURIE."""
return converter.expand(id)
return expansion_patch(converter.expand(id))


def get_expanded_curie(id: str) -> ExpandedCurie:
Expand Down

0 comments on commit d89360b

Please sign in to comment.