Skip to content

Commit

Permalink
rm old files when performing dp model-devi (#1332)
Browse files Browse the repository at this point in the history
`dp model-devi` appends output into the existing file instead of
overwriting it, so if there is an existing file (maybe caused by
restart), there might be errors in reading it.

`rm -f` does not check if the file exists and always returns exit code
0.

Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz authored Sep 14, 2023
1 parent 9a76b01 commit a714d79
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dpgen/simplify/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def run_model_devi(iter_index, jdata, mdata):
labeled=False,
).to_deepmd_hdf5(system_path + ".hdf5")
system_file_name += ".hdf5"
command = "{dp} model-devi -m {model} -s {system} -o {detail_file}".format(
command = "rm -f {detail_file} && {dp} model-devi -m {model} -s {system} -o {detail_file}".format(
dp=mdata.get("model_devi_command", "dp"),
model=" ".join(task_model_list),
system=system_file_name,
Expand All @@ -242,7 +242,7 @@ def run_model_devi(iter_index, jdata, mdata):
f_trust_lo_err = jdata.get("true_error_f_trust_lo", float("inf"))
e_trust_lo_err = jdata.get("true_error_e_trust_lo", float("inf"))
if f_trust_lo_err < float("inf") or e_trust_lo_err < float("inf"):
command_true_error = "{dp} model-devi -m {model} -s {system} -o {detail_file} --real_error".format(
command_true_error = "rm -f {detail_file} && {dp} model-devi -m {model} -s {system} -o {detail_file} --real_error".format(
dp=mdata.get("model_devi_command", "dp"),
model=" ".join(task_model_list),
system=system_file_name,
Expand Down

0 comments on commit a714d79

Please sign in to comment.