Finish first version of cache
This commit is contained in:
parent
da5ae22346
commit
2bf263679d
2 changed files with 8 additions and 9 deletions
9
TODO.md
9
TODO.md
|
@ -1,15 +1,14 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- [ ] implement import of non-datalad projects
|
- implement import of non-datalad projects
|
||||||
- [ ] implement a way to use another backlog repo as a project
|
- 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
|
- 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?
|
- maybe let this be an input in the project file?
|
||||||
- git repo and commit hash/version tag
|
- git repo and commit hash/version tag
|
||||||
- [ ] implement local caching with pickle files
|
|
||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
- [ ] revisit the reimport function for single files
|
- [ ] revisit the reimport function for single files
|
||||||
|
|
|
@ -139,8 +139,8 @@ def load_records(path: str, meas_paths: list[str], preloaded = {}) -> list[Union
|
||||||
returned_data: list = []
|
returned_data: list = []
|
||||||
for file in needed_data.keys():
|
for file in needed_data.keys():
|
||||||
for key in list(needed_data[file]):
|
for key in list(needed_data[file]):
|
||||||
if os.path.exists(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)))
|
returned_data.append(load_object(cache_path(path, file, key) + ".p"))
|
||||||
else:
|
else:
|
||||||
if file not in preloaded:
|
if file not in preloaded:
|
||||||
preloaded[file] = preload(path, file)
|
preloaded[file] = preload(path, file)
|
||||||
|
@ -156,13 +156,13 @@ def cache_dir(path, file):
|
||||||
cache_path_list = [path]
|
cache_path_list = [path]
|
||||||
cache_path_list.append(".cache")
|
cache_path_list.append(".cache")
|
||||||
cache_path_list.extend(file.split("/")[1:])
|
cache_path_list.extend(file.split("/")[1:])
|
||||||
cache_path = os.path.join(cache_path_list)
|
cache_path = "/".join(cache_path_list)
|
||||||
return cache_path
|
return cache_path
|
||||||
|
|
||||||
|
|
||||||
def cache_path(path, file, key):
|
def cache_path(path, file, key):
|
||||||
cache_path = os.path.join(cache_dir(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):
|
def preload(path: str, file: str):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue