Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
12 changes: 5 additions & 7 deletions dpgen/auto_test/VASP.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,11 @@ def forward_files(self, property_type="relaxation"):
return ["INCAR", "POSCAR", "KPOINTS", "POTCAR"]

def forward_common_files(self, property_type="relaxation"):
potcar_not_link_list = ["vacancy", "interstitial"]
if property_type == "elastic":
return ["INCAR", "KPOINTS", "POTCAR"]
elif property_type in potcar_not_link_list:
return ["INCAR"]
else:
return ["INCAR", "POTCAR"]
# VASP creates INCAR and POTCAR files per-task in subdirectories and symlinks them,
# rather than having true common files in the work_path.
# Return empty list to avoid upload errors when dispatcher looks for these files
# in the work_path directory.
return []

def backward_files(self, property_type="relaxation"):
return ["OUTCAR", "outlog", "CONTCAR", "OSZICAR", "XDATCAR"]
9 changes: 0 additions & 9 deletions tests/auto_test/confs/std-fcc/POSCAR

This file was deleted.

84 changes: 84 additions & 0 deletions tests/auto_test/test_forward_common_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import os
import sys
import unittest

# Add the parent directory to sys.path to ensure imports work
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
__package__ = "auto_test"

from dpgen.auto_test.ABACUS import ABACUS
from dpgen.auto_test.VASP import VASP

from .context import setUpModule # noqa: F401


class TestForwardCommonFiles(unittest.TestCase):
"""Test that forward_common_files returns appropriate files for different calculators."""

def test_vasp_forward_common_files_empty(self):
"""Test that VASP forward_common_files returns empty list.

This test ensures that VASP doesn't return INCAR/POTCAR as common files
since they are created per-task and symlinked, not as true common files
in the work_path. This prevents upload errors in dpdispatcher.
"""
inter_parameter = {
"type": "vasp",
"incar": "vasp_input/INCAR.rlx",
"potcar_prefix": ".",
"potcars": {"Li": "vasp_input/POTCAR"},
}

vasp_calc = VASP(inter_parameter, "POSCAR")

# Test different property types
property_types = ["relaxation", "static", "elastic", "vacancy", "interstitial"]

for prop_type in property_types:
with self.subTest(property_type=prop_type):
common_files = vasp_calc.forward_common_files(prop_type)
self.assertEqual(
common_files,
[],
f"VASP forward_common_files should return empty list for {prop_type}",
)

def test_abacus_forward_common_files_consistency(self):
"""Test that ABACUS also returns empty list, showing consistency."""
inter_parameter = {
"type": "abacus",
"potcar_prefix": ".",
"potcars": {"Al": "POT_Al"},
"orb_files": {"Al": "Al_gga_7au_60Ry_2s2p1d.orb"},
"dpks_descriptor": "jle.dat",
}

abacus_calc = ABACUS(inter_parameter, "POSCAR")
common_files = abacus_calc.forward_common_files("relaxation")

self.assertEqual(
common_files, [], "ABACUS forward_common_files should return empty list"
)

def test_vasp_forward_files_still_works(self):
"""Test that forward_files still returns required files for each task."""
inter_parameter = {
"type": "vasp",
"incar": "vasp_input/INCAR.rlx",
"potcar_prefix": ".",
"potcars": {"Li": "vasp_input/POTCAR"},
}

vasp_calc = VASP(inter_parameter, "POSCAR")
forward_files = vasp_calc.forward_files("relaxation")

expected_files = ["INCAR", "POSCAR", "KPOINTS", "POTCAR"]
self.assertEqual(
forward_files,
expected_files,
"VASP forward_files should still return task-specific files",
)


if __name__ == "__main__":
unittest.main()