davanstrien HF staff commited on
Commit
206a7be
β€’
1 Parent(s): 1eb4ea3

make cache time global variable

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -11,14 +11,14 @@ import os
11
  os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
12
  is_macos = platform.system() == "Darwin"
13
  LIMIT = None
 
14
 
15
-
16
- @cached(cache=TTLCache(maxsize=100, ttl=60 * 30))
17
  def get_models():
18
  return list(iter(list_models(full=True, limit=LIMIT)))
19
 
20
 
21
- @cached(cache=TTLCache(maxsize=100, ttl=60 * 30))
22
  def get_datasets():
23
  return list(iter(list_datasets(full=True, limit=LIMIT)))
24
 
@@ -42,7 +42,7 @@ def extract_arxiv_id(input_string: str) -> str:
42
  return match[1] if match else None
43
 
44
 
45
- @cached(cache=TTLCache(maxsize=100, ttl=60 * 30))
46
  def create_model_to_arxiv_id_dict():
47
  models = get_models()
48
  model_to_arxiv_id = {}
@@ -56,7 +56,7 @@ def create_model_to_arxiv_id_dict():
56
  return model_to_arxiv_id
57
 
58
 
59
- @cached(cache=TTLCache(maxsize=100, ttl=60 * 30))
60
  def create_dataset_to_arxiv_id_dict():
61
  datasets = get_datasets()
62
  dataset_to_arxiv_id = {}
 
11
  os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
12
  is_macos = platform.system() == "Darwin"
13
  LIMIT = None
14
+ CACHE_TIME = 60 * 5
15
 
16
+ @cached(cache=TTLCache(maxsize=100, ttl=CACHE_TIME))
 
17
  def get_models():
18
  return list(iter(list_models(full=True, limit=LIMIT)))
19
 
20
 
21
+ @cached(cache=TTLCache(maxsize=100, ttl=CACHE_TIME))
22
  def get_datasets():
23
  return list(iter(list_datasets(full=True, limit=LIMIT)))
24
 
 
42
  return match[1] if match else None
43
 
44
 
45
+ @cached(cache=TTLCache(maxsize=100, ttl=CACHE_TIME))
46
  def create_model_to_arxiv_id_dict():
47
  models = get_models()
48
  model_to_arxiv_id = {}
 
56
  return model_to_arxiv_id
57
 
58
 
59
+ @cached(cache=TTLCache(maxsize=100, ttl=CACHE_TIME))
60
  def create_dataset_to_arxiv_id_dict():
61
  datasets = get_datasets()
62
  dataset_to_arxiv_id = {}