MCPcopy
hub / github.com/kapicorp/kapitan / get

Method get

kapitan/inputs/cache.py:75–99  ·  view source on GitHub ↗
(self, inputs_hash, lock_retries=2)

Source from the content-addressed store, hash-verified

73 return cached_path, cached_path_lock, sub_path
74
75 def get(self, inputs_hash, lock_retries=2) -> dict | None: # output_obj
76 cached_path, cached_path_lock, _ = self.hash_paths(inputs_hash)
77 if not cached_path_lock.exists():
78 for retry in range(lock_retries):
79 try:
80 with open(cached_path, "rb") as fp:
81 logger.debug(
82 "Loading cache hit: %s (try %d/%d)",
83 cached_path,
84 retry,
85 lock_retries,
86 )
87 output_obj = self.load_output(fp)
88 # load_output can return None when a kadet
89 # ModuleNotFoundError is swallowed; treat that as a
90 # miss so the caller recomputes.
91 if output_obj is None:
92 self.metrics.miss()
93 else:
94 self.metrics.hit()
95 return output_obj
96 except FileNotFoundError:
97 pass
98 self.metrics.miss()
99 return None
100
101 def set(self, inputs_hash, output_obj, lock_retries=2):
102 cached_path, cached_path_lock, sub_path = self.hash_paths(inputs_hash)

Callers 15

test_set_and_getMethod · 0.95
test_get_cache_missMethod · 0.95
refresh_oneFunction · 0.80
__init__Method · 0.80
setup_vaultMethod · 0.80
test_cli.pyFile · 0.80
omegaconf_backendFunction · 0.80

Calls 4

hash_pathsMethod · 0.95
load_outputMethod · 0.95
missMethod · 0.80
hitMethod · 0.80