add tracker module, moularize tracking system

This commit is contained in:
Justus Kuhlmann 2025-12-04 10:47:53 +01:00
commit 3963b07c5f
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
6 changed files with 40 additions and 3 deletions

View file

@ -21,3 +21,4 @@ from .initialization import *
from .meas_io import * from .meas_io import *
from .find import * from .find import *
from .version import __version__ from .version import __version__
from .config import *

View file

@ -5,7 +5,8 @@ import json
import pandas as pd import pandas as pd
import numpy as np import numpy as np
from .input.implementations import codes from .input.implementations import codes
from .tools import k2m, get_file from .tools import k2m
from .tracker import get_file
# this will implement the search functionality # this will implement the search functionality

View file

@ -5,7 +5,8 @@ import os
from .git_tools import move_submodule from .git_tools import move_submodule
import shutil import shutil
from .find import _project_lookup_by_id from .find import _project_lookup_by_id
from .tools import list2str, str2list, get_file from .tools import list2str, str2list
from .tracker import get_file
from typing import Union from typing import Union

View file

@ -7,7 +7,8 @@ import json
from typing import Union from typing import Union
from pyerrors import Obs, Corr, dump_object, load_object from pyerrors import Obs, Corr, dump_object, load_object
from hashlib import sha256 from hashlib import sha256
from .tools import cached, get_file from .tools import cached
from .tracker import get_file
import shutil import shutil

22
corrlib/tracker.py Normal file
View file

@ -0,0 +1,22 @@
import os
from configparser import ConfigParser
from .trackers import datalad as dl
def get_tracker(path):
config_path = os.path.join(path, '.corrlib')
config = ConfigParser()
if os.path.exists(config_path):
config.read(config_path)
tracker = config.get('core', 'tracker', fallback='datalad')
return tracker
def get_file(path, file):
tracker = get_tracker(path)
if tracker == 'datalad':
dl.get_file(path, file)
else:
raise ValueError(f"Tracker {tracker} is not supported.")
return

View file

@ -0,0 +1,11 @@
import datalad.api as dl
import os
def get_file(path, file):
if file == "backlogger.db":
print("Downloading database...")
else:
print("Downloading data...")
dl.get(os.path.join(path, file), dataset=path)
print("> downloaded file")