Compare commits
No commits in common. "4b57ea581b4fced47d81b7738b7ea0e63eaa1a55" and "6419df8b15b61ececcd7bb8159ffc9671a4546ce" have entirely different histories.
4b57ea581b
...
6419df8b15
4 changed files with 10 additions and 18 deletions
|
|
@ -143,7 +143,8 @@ def find_record(path, ensemble, correlator_name, code, project=None, parameters=
|
||||||
db = path + '/backlogger.db'
|
db = path + '/backlogger.db'
|
||||||
if code not in codes:
|
if code not in codes:
|
||||||
raise ValueError("Code " + code + "unknown, take one of the following:" + ", ".join(codes))
|
raise ValueError("Code " + code + "unknown, take one of the following:" + ", ".join(codes))
|
||||||
dl.get(db, dataset=path)
|
if os.path.exists(db):
|
||||||
|
dl.get(db, dataset=path)
|
||||||
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, revision=revision)
|
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, revision=revision)
|
||||||
if code == "sfcf":
|
if code == "sfcf":
|
||||||
results = sfcf_filter(results, **kwargs)
|
results = sfcf_filter(results, **kwargs)
|
||||||
|
|
@ -151,14 +152,12 @@ def find_record(path, ensemble, correlator_name, code, project=None, parameters=
|
||||||
return results.reset_index()
|
return results.reset_index()
|
||||||
|
|
||||||
|
|
||||||
def find_project(path, db, name):
|
def find_project(db, name):
|
||||||
dl.get(db, dataset=path)
|
|
||||||
return _project_lookup_by_alias(db, name)
|
return _project_lookup_by_alias(db, name)
|
||||||
|
|
||||||
|
|
||||||
def list_projects(path):
|
def list_projects(path):
|
||||||
db = path + '/backlogger.db'
|
db = path + '/backlogger.db'
|
||||||
dl.get(db, dataset=path)
|
|
||||||
conn = sqlite3.connect(db)
|
conn = sqlite3.connect(db)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute("SELECT id,aliases FROM projects")
|
c.execute("SELECT id,aliases FROM projects")
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,13 @@ def create_project(path: str, uuid: str, owner: Union[str, None]=None, tags: Uni
|
||||||
code: str (optional)
|
code: str (optional)
|
||||||
The code that was used to create the measurements.
|
The code that was used to create the measurements.
|
||||||
"""
|
"""
|
||||||
db = path + "/backlogger.db"
|
conn = sqlite3.connect(path + "/backlogger.db")
|
||||||
dl.get(db, dataset=path)
|
|
||||||
conn = sqlite3.connect(db)
|
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
known_projects = c.execute("SELECT * FROM projects WHERE id=?", (uuid,))
|
known_projects = c.execute("SELECT * FROM projects WHERE id=?", (uuid,))
|
||||||
if known_projects.fetchone():
|
if known_projects.fetchone():
|
||||||
raise ValueError("Project already imported, use update_project() instead.")
|
raise ValueError("Project already imported, use update_project() instead.")
|
||||||
|
|
||||||
dl.unlock(db, dataset=path)
|
dl.unlock(path + "/backlogger.db", dataset=path)
|
||||||
alias_str = None
|
alias_str = None
|
||||||
if aliases is not None:
|
if aliases is not None:
|
||||||
alias_str = list2str(aliases)
|
alias_str = list2str(aliases)
|
||||||
|
|
@ -42,11 +40,10 @@ def create_project(path: str, uuid: str, owner: Union[str, None]=None, tags: Uni
|
||||||
c.execute("INSERT INTO projects (id, aliases, customTags, owner, code, created_at, updated_at) VALUES (?, ?, ?, ?, ?, datetime('now'), datetime('now'))", (uuid, alias_str, tag_str, owner, code))
|
c.execute("INSERT INTO projects (id, aliases, customTags, owner, code, created_at, updated_at) VALUES (?, ?, ?, ?, ?, datetime('now'), datetime('now'))", (uuid, alias_str, tag_str, owner, code))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
dl.save(db, message="Added entry for project " + uuid + " to database", dataset=path)
|
dl.save(path + "/backlogger.db", message="Added entry for project " + uuid + " to database", dataset=path)
|
||||||
|
|
||||||
|
|
||||||
def update_project_data(path, db, uuid, prop, value = None):
|
def update_project_data(db, uuid, prop, value = None):
|
||||||
dl.get(db, dataset=path)
|
|
||||||
conn = sqlite3.connect(db)
|
conn = sqlite3.connect(db)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute(f"UPDATE projects SET '{prop}' = '{value}' WHERE id == '{uuid}'")
|
c.execute(f"UPDATE projects SET '{prop}' = '{value}' WHERE id == '{uuid}'")
|
||||||
|
|
@ -57,7 +54,6 @@ def update_project_data(path, db, uuid, prop, value = None):
|
||||||
|
|
||||||
def update_aliases(path: str, uuid: str, aliases: list[str]):
|
def update_aliases(path: str, uuid: str, aliases: list[str]):
|
||||||
db = os.path.join(path, "backlogger.db")
|
db = os.path.join(path, "backlogger.db")
|
||||||
dl.get(db, dataset=path)
|
|
||||||
known_data = _project_lookup_by_id(db, uuid)[0]
|
known_data = _project_lookup_by_id(db, uuid)[0]
|
||||||
known_aliases = known_data[1]
|
known_aliases = known_data[1]
|
||||||
|
|
||||||
|
|
@ -121,13 +117,11 @@ def import_project(path: str, url: str, owner: Union[str, None]=None, tags: Unio
|
||||||
if not uuid:
|
if not uuid:
|
||||||
raise ValueError("The dataset does not have a uuid!")
|
raise ValueError("The dataset does not have a uuid!")
|
||||||
if not os.path.exists(path + "/projects/" + uuid):
|
if not os.path.exists(path + "/projects/" + uuid):
|
||||||
db = path + "/backlogger.db"
|
dl.unlock(path + "/backlogger.db", dataset=path)
|
||||||
dl.get(db, ds=path)
|
|
||||||
dl.unlock(db, dataset=path)
|
|
||||||
create_project(path, uuid, owner, tags, aliases, code)
|
create_project(path, uuid, owner, tags, aliases, code)
|
||||||
move_submodule(path, 'projects/tmp', 'projects/' + uuid)
|
move_submodule(path, 'projects/tmp', 'projects/' + uuid)
|
||||||
os.mkdir(path + '/import_scripts/' + uuid)
|
os.mkdir(path + '/import_scripts/' + uuid)
|
||||||
dl.save([db, path + '/projects/' + uuid], message="Import project from " + url, dataset=path)
|
dl.save([path + "/backlogger.db", path + '/projects/' + uuid], message="Import project from " + url, dataset=path)
|
||||||
else:
|
else:
|
||||||
dl.drop(tmp_path, reckless='kill')
|
dl.drop(tmp_path, reckless='kill')
|
||||||
shutil.rmtree(tmp_path)
|
shutil.rmtree(tmp_path)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ def write_measurement(path, ensemble, measurement, uuid, code, parameter_file=No
|
||||||
The uuid of the project.
|
The uuid of the project.
|
||||||
"""
|
"""
|
||||||
db = os.path.join(path, 'backlogger.db')
|
db = os.path.join(path, 'backlogger.db')
|
||||||
dl.get(db, ds=path)
|
|
||||||
dl.unlock(db, dataset=path)
|
dl.unlock(db, dataset=path)
|
||||||
conn = sqlite3.connect(db)
|
conn = sqlite3.connect(db)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
@ -177,7 +176,6 @@ def drop_record(path: str, meas_path: str):
|
||||||
file_in_archive = meas_path.split("::")[0]
|
file_in_archive = meas_path.split("::")[0]
|
||||||
file = os.path.join(path, file_in_archive)
|
file = os.path.join(path, file_in_archive)
|
||||||
db = os.path.join(path, 'backlogger.db')
|
db = os.path.join(path, 'backlogger.db')
|
||||||
dl.get(db, ds=path)
|
|
||||||
sub_key = meas_path.split("::")[1]
|
sub_key = meas_path.split("::")[1]
|
||||||
dl.unlock(db, dataset=path)
|
dl.unlock(db, dataset=path)
|
||||||
conn = sqlite3.connect(db)
|
conn = sqlite3.connect(db)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def str2list(string):
|
def str2list(string):
|
||||||
return string.split(",")
|
return string.split(",")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue