implement dynamic db name from config
Some checks failed
Ruff / ruff (push) Waiting to run
Mypy / mypy (push) Failing after 44s
Pytest / pytest (3.12) (push) Successful in 50s
Pytest / pytest (3.13) (push) Has been cancelled
Pytest / pytest (3.14) (push) Has been cancelled

This commit is contained in:
Justus Kuhlmann 2025-12-04 14:31:53 +01:00
commit 0626b34337
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
5 changed files with 60 additions and 27 deletions

View file

@ -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)