Skip to content

Commit

Permalink
Improve performance of AnyVar.put_object() by eliminating unnecessary…
Browse files Browse the repository at this point in the history
… digest computation (#73)

* Return digest from vrs_enref instead of recomputing

* Removed unused import

* Bump ga4gh.vrs dependency version to 2.0.0a2

* Change unused var name to "_"

Co-authored-by: Kori Kuzma <korikuzma@gmail.com>

---------

Co-authored-by: Kori Kuzma <korikuzma@gmail.com>
  • Loading branch information
ehclark and korikuzma authored Jan 16, 2024
1 parent 4a93706 commit db6964b
Showing 1 changed file with 2 additions and 3 deletions.
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, _ = vrs_enref(variation_object, self.object_store, True)
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

0 comments on commit db6964b

Please sign in to comment.