refactor/data_backend #12
6 changed files with 40 additions and 3 deletions
add tracker module, moularize tracking system
commit
3963b07c5f
|
|
@ -21,3 +21,4 @@ from .initialization import *
|
|||
from .meas_io import *
|
||||
from .find import *
|
||||
from .version import __version__
|
||||
from .config import *
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import json
|
|||
import pandas as pd
|
||||
import numpy as np
|
||||
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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import os
|
|||
from .git_tools import move_submodule
|
||||
import shutil
|
||||
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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import json
|
|||
from typing import Union
|
||||
from pyerrors import Obs, Corr, dump_object, load_object
|
||||
from hashlib import sha256
|
||||
from .tools import cached, get_file
|
||||
from .tools import cached
|
||||
from .tracker import get_file
|
||||
import shutil
|
||||
|
||||
|
||||
|
|
|
|||
22
corrlib/tracker.py
Normal file
22
corrlib/tracker.py
Normal 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
|
||||
|
||||
11
corrlib/trackers/datalad.py
Normal file
11
corrlib/trackers/datalad.py
Normal 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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue