IHEC / ihec-ecosystems

This repo is for code and documentation associated with the ihec-ecosystems working group
Apache License 2.0
5 stars 6 forks source link

Add version argument for validateHub #111

Closed zxenia closed 3 years ago

zxenia commented 3 years ago

Changes with this PR:

sitag commented 3 years ago

@zxenia you are making too many api calls that are redundant. e.g. there are ~1000 datasets for ~100 references, but you end up making 1000 api calls, and the calls are slow. the calls should be cached. are you familiar with memoization pattern and can you apply it here?

zxenia commented 3 years ago

Hi @sitag , I can add the caching here (memory or sqlite db). Thanks!

sitag commented 3 years ago

@zxenia You just need to memoize - just simply do this:

def api_call(x):
    return ...

class APIWithCache:
    def __init__(self):
        self.cache = dict()
    def __call__(self, x):
        if not x in self.cache: 
           self.cache[x] = api_call(x)
        return self.cache[x]

api_call2 = APIWithCache()

api_call2(x)
dzerbino commented 3 years ago

Hello @zxenia @sitag @dbujold ,

This PR has been lingering for a while now, what is its status? Is it urgent?

Cheers,

Daniel

zxenia commented 3 years ago

Hi @dzerbino , the issue is done and can be merged. But I prefer to cross-check with @dbujold first, and I will merge it after that.