Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions dpgen/generator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4437,16 +4437,19 @@ def post_fp_cp2k(iter_index, jdata, rfailed=None):
sys_output = glob.glob(os.path.join(work_path, "task.%s.*/output" % ss))
Comment thread
dulinhan marked this conversation as resolved.
Outdated
sys_output.sort()
tcount += len(sys_output)
all_sys = None
log_file_path = os.path.join(work_path, f"{ss}.fp-fail.log")
all_sys = dpdata.MultiSystems(type_map=jdata["type_map"])
for oo in sys_output:
_sys = dpdata.LabeledSystem(oo, fmt="cp2k/output")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this fmt revert back?

dpgen/dpgen/generator/run.py

Lines 4483 to 4489 in 54e48c6

for oo in sys_output:
_sys = dpdata.LabeledSystem(
oo, fmt="cp2kdata/e_f", type_map=jdata["type_map"]
)
all_sys.append(_sys)
icount += 1

# _sys.check_type_map(type_map = jdata['type_map'])
if all_sys is None:
all_sys = _sys
else:
all_sys.append(_sys)
with open(oo, 'r') as file:
content = file.read()
if 'SCF run NOT converged' in content:
Comment thread
dulinhan marked this conversation as resolved.
Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp2kdata already checks the convergence.
if the scf is not converged, dpdata will return empty object.
https://github.com/robinzyb/cp2kdata/blob/d74c14cbf7470451af443c706d8479c8b486a68d/cp2kdata/dpdata_plugin.py#L24-L43

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will. But when using MultiSystems, the empty object will be added into that, for example create an empty "C0H0O0". This will raise error when save the MultiSystems to data.xxx. Maybe we should change the subroutine which you mentioned to skip instead of creating empty object.

with open(log_file_path, 'a') as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue
Comment on lines +4503 to +4508
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move these lines after _sys=dpdata.LabeledSystem

Suggested change
with open(oo) as file:
content = file.read()
if "SCF run NOT converged" in content:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue
if len(_sys) == 0:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue

Comment on lines +4505 to +4508
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move SCF check and logging after _sys instantiation

To ensure _sys is only instantiated if SCF converges, move these lines after _sys=dpdata.LabeledSystem.

-            if "SCF run NOT converged" in content:
-                with open(log_file_path, "a") as log_file:
-                    log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
-                continue
            _sys = dpdata.LabeledSystem(
                oo, fmt="cp2kdata/e_f", type_map=jdata["type_map"]
            )
+            if "SCF run NOT converged" in content:
+                with open(log_file_path, "a") as log_file:
+                    log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
+                continue
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if "SCF run NOT converged" in content:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue
_sys = dpdata.LabeledSystem(
oo, fmt="cp2kdata/e_f", type_map=jdata["type_map"]
)
if "SCF run NOT converged" in content:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue

_sys = dpdata.LabeledSystem(oo, fmt="cp2kdata/e_f", type_map=jdata["type_map"])
all_sys.append(_sys)
icount += 1

icount += len(all_sys)
if (all_sys is not None) and (len(all_sys) > 0):
sys_data_path = os.path.join(work_path, "data.%s" % ss)
all_sys.to_deepmd_raw(sys_data_path)
Expand Down