Closed DavidPeleg6 closed 1 year ago
what what is this referring to @DavidPeleg6
def cache_dec(filename: str):
# the function which is decorated should have a 'time' variable, preferabbly with a default value of 'None'.
def decorator(func):
def wrapper(*args, **kwargs):
if "time" not in kwargs:
raise Exception(f"Invalid use of the cache_dec decorator. {func} must have a time variable")
cachedata_fname = filename
if "predgoal" in kwargs:
cachedata_fname = cachedata_fname + "_" + kwargs["predgoal"]
time = _checkIfCacheUpdate(cachedata_fname)
result = func(*args, time = time, **kwargs)
return result
return wrapper
return decorator
Here, if time is added as one of the kwargs - we get an exception because theres double definition of time (when we call the result= ... line) if we dont add it, we get an exception for invalid use. in the meantime, I used st.cache_data(ttl=606024) as the caching mechanism
ye I think just using the built in cache instead of my nonesense decorator is for the better
this line throws an exception (probably went unnoticed because it was only a print there):
if "time" not in kwargs: raise Exception(f"Invalid use of the cache_dec decorator. {func} must have a time variable")
in dataloader.py