Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of AnyVar.put_object() by eliminating unnecessary digest computation #73

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install_requires =
fastapi >= 0.95.0
python-multipart
uvicorn
ga4gh.vrs[extras] ~= 2.0.0a1
ga4gh.vrs[extras] ~= 2.0.0a2
psycopg[binary]
snowflake-connector-python ~= 3.4.1

Expand Down
5 changes: 2 additions & 3 deletions src/anyvar/anyvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import Optional
from urllib.parse import urlparse

from ga4gh.core import ga4gh_identify
from ga4gh.vrs import vrs_deref, vrs_enref

from anyvar.storage import DEFAULT_STORAGE_URI, _Storage
Expand Down Expand Up @@ -83,10 +82,10 @@ def put_object(self, variation_object: VrsObject) -> Optional[str]:
:return: Object digest if successful, None otherwise
"""
try:
v = vrs_enref(variation_object, self.object_store)
id, v = vrs_enref(variation_object, self.object_store, True)
ehclark marked this conversation as resolved.
Show resolved Hide resolved
except ValueError:
return None
return ga4gh_identify(v)
return id

def get_object(self, object_id: str, deref: bool = False) -> Optional[VrsObject]:
"""Retrieve registered variation.
Expand Down