MCPcopy Create free account
hub / github.com/TonyLianLong/LLM-groundedDiffusion / init_cache

Function init_cache

utils/cache.py:25–40  ·  view source on GitHub ↗
(allow_nonexist=True)

Source from the content-addressed store, hash-verified

23 return sum(global_cache_index.values())
24
25def init_cache(allow_nonexist=True):
26 global global_cache
27 assert cache_path, "Need to set cache path"
28
29 print(f"Cache path: {cache_path}")
30
31 if not allow_nonexist:
32 assert os.path.exists(cache_path), f"{cache_path} does not exist"
33
34 if os.path.exists(cache_path):
35 if cache_format == "pickle":
36 with open(cache_path, 'rb') as f:
37 global_cache = pickle.load(f)
38 elif cache_format == "json":
39 with open(cache_path, 'r') as f:
40 global_cache = json.load(f)
41
42def get_cache(key):
43 if key not in global_cache:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected