fix/uv-setup #21
1 changed files with 11 additions and 6 deletions
fix when files are unlocked or saved
commit
96731baeb9
|
|
@ -34,22 +34,28 @@ def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str,
|
|||
"""
|
||||
db_file = get_db_file(path)
|
||||
db = os.path.join(path, db_file)
|
||||
|
||||
files_to_save = []
|
||||
|
||||
get(path, db_file)
|
||||
unlock(path, db_file)
|
||||
files_to_save.append(db_file)
|
||||
|
||||
conn = sqlite3.connect(db)
|
||||
c = conn.cursor()
|
||||
files = []
|
||||
for corr in measurement.keys():
|
||||
file_in_archive = os.path.join('.', 'archive', ensemble, corr, uuid + '.json.gz')
|
||||
file = os.path.join(path, file_in_archive)
|
||||
files.append(file)
|
||||
known_meas = {}
|
||||
if not os.path.exists(os.path.join(path, '.', 'archive', ensemble, corr)):
|
||||
os.makedirs(os.path.join(path, '.', 'archive', ensemble, corr))
|
||||
files_to_save.append(file_in_archive)
|
||||
else:
|
||||
if os.path.exists(file):
|
||||
unlock(path, file_in_archive)
|
||||
known_meas = pj.load_json_dict(file)
|
||||
if file not in files_to_save:
|
||||
unlock(path, file_in_archive)
|
||||
files_to_save.append(file_in_archive)
|
||||
known_meas = pj.load_json_dict(file, verbose=False)
|
||||
if code == "sfcf":
|
||||
parameters = sfcf.read_param(path, uuid, parameter_file)
|
||||
pars = {}
|
||||
|
|
@ -98,9 +104,8 @@ def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str,
|
|||
(corr, ensemble, code, meas_path, uuid, pars[subkey], parameter_file))
|
||||
conn.commit()
|
||||
pj.dump_dict_to_json(known_meas, file)
|
||||
files.append(os.path.join(path, db_file))
|
||||
conn.close()
|
||||
save(path, message="Add measurements to database", files=files)
|
||||
save(path, message="Add measurements to database", files=files_to_save)
|
||||
return
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue