Skip to content

Commit

Permalink
Make development cache check for folder just ahead of usage
Browse files Browse the repository at this point in the history
  • Loading branch information
JHSaunders committed Apr 20, 2021
1 parent 83561f3 commit 0cee1c8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions fn_graph/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ def __init__(self, name, cache_dir):
cache_dir = ".fn_graph_cache"

self.cache_dir = Path(cache_dir)
self.cache_root = self.cache_dir / name
self.cache_root.mkdir(parents=True, exist_ok=True)

@property
def cache_root(self):
return self.cache_dir / self.name

def valid(self, composer, key):
self.cache_root.mkdir(parents=True, exist_ok=True)
pickle_file_path = self.cache_root / f"{key}.data"
info_file_path = self.cache_root / f"{key}.info.json"
fn_hash_path = self.cache_root / f"{key}.fn.hash"
Expand Down Expand Up @@ -167,8 +171,9 @@ def valid(self, composer, key):
return True

def get(self, composer, key):
log.debug("Retrieving from development cache '%s' for key '%s'", self.name, key)

log.debug("Retrieving from development cache '%s' for key '%s'", self.name, key)
self.cache_root.mkdir(parents=True, exist_ok=True)
pickle_file_path = self.cache_root / f"{key}.data"
info_file_path = self.cache_root / f"{key}.info.json"

Expand All @@ -190,6 +195,7 @@ def get(self, composer, key):
def set(self, composer, key, value):

log.debug("Writing to development cache '%s' for key '%s'", self.name, key)
self.cache_root.mkdir(parents=True, exist_ok=True)
pickle_file_path = self.cache_root / f"{key}.data"
info_file_path = self.cache_root / f"{key}.info.json"
fn_hash_path = self.cache_root / f"{key}.fn.hash"
Expand Down Expand Up @@ -223,6 +229,7 @@ def set(self, composer, key, value):

def invalidate(self, composer, key):
log.debug("Invalidation in development cache '%s' for key '%s'", self.name, key)
self.cache_root.mkdir(parents=True, exist_ok=True)
paths = [
self.cache_root / f"{key}.data",
self.cache_root / f"{key}.fn.hash",
Expand Down

0 comments on commit 0cee1c8

Please sign in to comment.