implement dynamic db name from config
This commit is contained in:
parent
4b55227642
commit
0626b34337
5 changed files with 60 additions and 27 deletions
|
|
@ -4,9 +4,10 @@ import json
|
|||
import pandas as pd
|
||||
import numpy as np
|
||||
from .input.implementations import codes
|
||||
from .tools import k2m
|
||||
from .tools import k2m, get_db_file
|
||||
from .tracker import get
|
||||
from typing import Any, Optional
|
||||
|
||||
# this will implement the search functionality
|
||||
|
||||
|
||||
|
|
@ -143,10 +144,11 @@ def sfcf_filter(results: pd.DataFrame, **kwargs: Any) -> pd.DataFrame:
|
|||
|
||||
def find_record(path: str, ensemble: str, correlator_name: str, code: str, project: Optional[str]=None, parameters: Optional[str]=None,
|
||||
created_before: Optional[str]=None, created_after: Optional[str]=None, updated_before: Optional[str]=None, updated_after: Optional[str]=None, revision: Optional[str]=None, **kwargs: Any) -> pd.DataFrame:
|
||||
db = path + '/backlogger.db'
|
||||
db_file = get_db_file(path)
|
||||
db = os.path.join(path, db_file)
|
||||
if code not in codes:
|
||||
raise ValueError("Code " + code + "unknown, take one of the following:" + ", ".join(codes))
|
||||
get(path, "backlogger.db")
|
||||
get(path, db_file)
|
||||
results = _db_lookup(db, ensemble, correlator_name,code, project, parameters=parameters, created_before=created_before, created_after=created_after, updated_before=updated_before, updated_after=updated_after)
|
||||
if code == "sfcf":
|
||||
results = sfcf_filter(results, **kwargs)
|
||||
|
|
@ -155,14 +157,15 @@ def find_record(path: str, ensemble: str, correlator_name: str, code: str, proje
|
|||
|
||||
|
||||
def find_project(path: str, name: str) -> str:
|
||||
get(path, "backlogger.db")
|
||||
return _project_lookup_by_alias(os.path.join(path, "backlogger.db"), name)
|
||||
db_file = get_db_file(path)
|
||||
get(path, db_file)
|
||||
return _project_lookup_by_alias(os.path.join(path, db_file), name)
|
||||
|
||||
|
||||
def list_projects(path: str) -> list[tuple[str, str]]:
|
||||
db = path + '/backlogger.db'
|
||||
get(path, "backlogger.db")
|
||||
conn = sqlite3.connect(db)
|
||||
db_file = get_db_file(path)
|
||||
get(path, db_file)
|
||||
conn = sqlite3.connect(os.path.join(path, db_file))
|
||||
c = conn.cursor()
|
||||
c.execute("SELECT id,aliases FROM projects")
|
||||
results = c.fetchall()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue