Closed zxenia closed 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?
Hi @sitag , I can add the caching here (memory or sqlite db). Thanks!
@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)
Hello @zxenia @sitag @dbujold ,
This PR has been lingering for a while now, what is its status? Is it urgent?
Cheers,
Daniel
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.
Changes with this PR:
python validateHub.py --json=example_v2.0.json --version=2.0