Skip to content

Commit bfe7c07

Browse files
revisions for rc1
1 parent 7e56444 commit bfe7c07

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pymatgen/io/validation/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def from_paths(
292292
}
293293
potcar_enmax = None
294294
for file_name, file_cls in to_obj.items():
295-
if (path := _vars.get(file_name)) and Path(path).exists():
295+
if (path := _vars.get(file_name)) and Path(path).exists() and os.path.getsize(path) > 0:
296296
if file_name == "poscar":
297297
config["user_input"]["structure"] = Poscar.from_file(path).structure
298298
elif hasattr(file_cls, "from_file"):
@@ -417,7 +417,7 @@ def valid_input_set(self) -> VaspInputSafe:
417417
set_name = "MPNMRSet"
418418
elif self.run_type == "md":
419419
set_name = None
420-
else:
420+
elif self.run_type in ("relax", "static"):
421421
set_name = f"MP{self.run_type.capitalize()}Set"
422422
elif self.functional in ("pbesol", "scan", "r2scan", "hse06"):
423423
if self.functional == "pbesol":

pymatgen/io/validation/validation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
DEFAULT_CHECKS = [CheckStructureProperties, CheckPotcar, CheckCommonErrors, CheckKpointsKspacing, CheckIncar]
23+
REQUIRED_VASP_FILES: set[str] = {"INCAR", "KPOINTS", "POSCAR", "POTCAR", "OUTCAR", "vasprun.xml"}
2324

2425
# TODO: check for surface/slab calculations. Especially necessary for external calcs.
2526
# TODO: implement check to make sure calcs are within some amount (e.g. 250 meV) of the convex hull in the MPDB
@@ -128,6 +129,8 @@ def from_vasp_input(
128129
vf: VaspFiles = vasp_files
129130
elif vasp_file_paths:
130131
vf = VaspFiles.from_paths(**vasp_file_paths)
132+
else:
133+
raise ValueError("You must specify either a VaspFiles object or a dict of paths.")
131134

132135
config: dict[str, list[str]] = {
133136
"reasons": [],
@@ -167,7 +170,9 @@ def from_directory(cls, dir_name: str | Path, **kwargs) -> Self:
167170
"""
168171
dir_name = Path(dir_name)
169172
vasp_file_paths = {}
170-
for file_name in ("INCAR", "KPOINTS", "POSCAR", "POTCAR", "OUTCAR", "vasprun.xml"):
173+
for file_name in REQUIRED_VASP_FILES:
171174
if (file_path := Path(zpath(str(dir_name / file_name)))).exists():
172175
vasp_file_paths[file_name.lower().split(".")[0]] = file_path
176+
if not vasp_file_paths:
177+
raise ValueError("No valid VASP files were found.")
173178
return cls.from_vasp_input(vasp_file_paths=vasp_file_paths, **kwargs)

0 commit comments

Comments
 (0)