refactor/data_backend #12

Merged
jkuhl merged 36 commits from refactor/data_backend into develop 2025-12-04 15:47:45 +01:00
3 changed files with 26 additions and 7 deletions
Showing only changes of commit 15fd97af8e - Show all commits

rename getter method

Justus Kuhlmann 2025-12-04 11:09:03 +01:00
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6

View file

@ -8,7 +8,7 @@ from typing import Union
from pyerrors import Obs, Corr, dump_object, load_object
from hashlib import sha256
from .tools import cached
from .tracker import get_file
from .tracker import get
import shutil
@ -29,7 +29,7 @@ def write_measurement(path, ensemble, measurement, uuid, code, parameter_file=No
The uuid of the project.
"""
db = os.path.join(path, 'backlogger.db')
get_file(path, "backlogger.db")
get(path, "backlogger.db")
dl.unlock(db, dataset=path)
conn = sqlite3.connect(db)
c = conn.cursor()
@ -169,7 +169,7 @@ def cache_path(path, file, key):
def preload(path: str, file: str):
get_file(path, file)
get(path, file)
filedict = pj.load_json_dict(os.path.join(path, file))
print("> read file")
return filedict
@ -179,7 +179,7 @@ def drop_record(path: str, meas_path: str):
file_in_archive = meas_path.split("::")[0]
file = os.path.join(path, file_in_archive)
db = os.path.join(path, 'backlogger.db')
get_file(path, 'backlogger.db')
get(path, 'backlogger.db')
sub_key = meas_path.split("::")[1]
dl.unlock(db, dataset=path)
conn = sqlite3.connect(db)

View file

@ -1,5 +1,5 @@
import os
import datalad.api as dl
from configparser import ConfigParser
def str2list(string):
@ -17,4 +17,16 @@ def m2k(m):
def k2m(k):
return (1/(2*k))-4
def set_config(path, section, option, value):
config_path = os.path.join(path, '.corrlib')
config = ConfigParser()
if os.path.exists(config_path):
config.read(config_path)
if not config.has_section(section):
config.add_section(section)
config.set(section, option, value)
with open(config_path, 'w') as configfile:
config.write(configfile)
return

View file

@ -12,7 +12,7 @@ def get_tracker(path):
return tracker
def get_file(path, file):
def get(path, file):
tracker = get_tracker(path)
if tracker == 'datalad':
dl.get_file(path, file)
@ -20,3 +20,10 @@ def get_file(path, file):
raise ValueError(f"Tracker {tracker} is not supported.")
return
def save(path, message, files):
tracker = get_tracker(path)
if tracker == 'datalad':
dl.save(files, message=message, dataset=path)
else:
raise ValueError(f"Tracker {tracker} is not supported.")