implement dynamic db name from config
This commit is contained in:
parent
4b55227642
commit
0626b34337
5 changed files with 60 additions and 27 deletions
|
|
@ -7,7 +7,7 @@ import json
|
|||
from typing import Union
|
||||
from pyerrors import Obs, Corr, dump_object, load_object
|
||||
from hashlib import sha256
|
||||
from .tools import cached
|
||||
from .tools import get_db_file, cache_enabled
|
||||
from .tracker import get, save
|
||||
import shutil
|
||||
from typing import Any
|
||||
|
|
@ -29,8 +29,9 @@ def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str,
|
|||
uuid: str
|
||||
The uuid of the project.
|
||||
"""
|
||||
db = os.path.join(path, 'backlogger.db')
|
||||
get(path, "backlogger.db")
|
||||
db_file = get_db_file(path)
|
||||
db = os.path.join(path, db_file)
|
||||
get(path, db_file)
|
||||
dl.unlock(db, dataset=path)
|
||||
conn = sqlite3.connect(db)
|
||||
c = conn.cursor()
|
||||
|
|
@ -94,7 +95,7 @@ def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str,
|
|||
(corr, ensemble, code, meas_path, uuid, pars[subkey], parameter_file))
|
||||
conn.commit()
|
||||
pj.dump_dict_to_json(known_meas, file)
|
||||
files.append(path + '/backlogger.db')
|
||||
files.append(os.path.join(path, db_file))
|
||||
conn.close()
|
||||
save(path, message="Add measurements to database", files=files)
|
||||
|
||||
|
|
@ -149,7 +150,7 @@ def load_records(path: str, meas_paths: list[str], preloaded: dict[str, Any] = {
|
|||
if file not in preloaded:
|
||||
preloaded[file] = preload(path, file)
|
||||
returned_data.append(preloaded[file][key])
|
||||
if cached:
|
||||
if cache_enabled(path):
|
||||
if not os.path.exists(cache_dir(path, file)):
|
||||
os.makedirs(cache_dir(path, file))
|
||||
dump_object(preloaded[file][key], cache_path(path, file, key))
|
||||
|
|
@ -179,8 +180,9 @@ def preload(path: str, file: str) -> dict[str, Any]:
|
|||
def drop_record(path: str, meas_path: str) -> None:
|
||||
file_in_archive = meas_path.split("::")[0]
|
||||
file = os.path.join(path, file_in_archive)
|
||||
db = os.path.join(path, 'backlogger.db')
|
||||
get(path, 'backlogger.db')
|
||||
db_file = get_db_file(path)
|
||||
db = os.path.join(path, db_file)
|
||||
get(path, db_file)
|
||||
sub_key = meas_path.split("::")[1]
|
||||
dl.unlock(db, dataset=path)
|
||||
conn = sqlite3.connect(db)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue