Finish first version of cache

This commit is contained in:
Justus Kuhlmann 2025-05-13 09:45:00 +00:00
parent da5ae22346
commit 2bf263679d
2 changed files with 8 additions and 9 deletions

View file

@ -1,15 +1,14 @@
# TODO
## Features
- [ ] implement import of non-datalad projects
- [ ] implement a way to use another backlog repo as a project
- implement import of non-datalad projects
- implement a way to use another backlog repo as a project
- [ ] find a way to convey the mathematical structure of what EXACTLY is the form of the correlator in a specific project
- find a way to convey the mathematical structure of what EXACTLY is the form of the correlator in a specific project
- this could e.g. be done along the lines of mandatory documentation
- [ ] keep better track of the versions the code, that was used for a specific measurement.
- keep better track of the versions of the code, that was used for a specific measurement.
- maybe let this be an input in the project file?
- git repo and commit hash/version tag
- [ ] implement local caching with pickle files
## Bugfixes
- [ ] revisit the reimport function for single files

View file

@ -139,8 +139,8 @@ def load_records(path: str, meas_paths: list[str], preloaded = {}) -> list[Union
returned_data: list = []
for file in needed_data.keys():
for key in list(needed_data[file]):
if os.path.exists(cache_path(path, file, key)):
returned_data.append(load_object(cache_path(path, file, key)))
if os.path.exists(cache_path(path, file, key) + ".p"):
returned_data.append(load_object(cache_path(path, file, key) + ".p"))
else:
if file not in preloaded:
preloaded[file] = preload(path, file)
@ -156,13 +156,13 @@ def cache_dir(path, file):
cache_path_list = [path]
cache_path_list.append(".cache")
cache_path_list.extend(file.split("/")[1:])
cache_path = os.path.join(cache_path_list)
cache_path = "/".join(cache_path_list)
return cache_path
def cache_path(path, file, key):
cache_path = os.path.join(cache_dir(path, file), key)
return cache_path + ".p"
return cache_path
def preload(path: str, file: str):