Skip to content
Open
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
9 changes: 8 additions & 1 deletion src/atomate2/jdftx/schemas/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ def from_jdftxoutput(
if kwargs.get("store_trajectory", True)
else None
),
parameters=jdftxoutput.as_dict(),
# Without "@module"/"@class" (newer pymatgen-core has them in as_dict):
# when a later job takes this output as input, jobflow would decode
# this dict back into a JDFTXOutfile, which this dict field rejects.
parameters={
key: value
for key, value in jdftxoutput.as_dict().items()
if not key.startswith("@")
},
)


Expand Down
17 changes: 17 additions & 0 deletions tests/jdftx/jobs/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,20 @@ def test_latticemin_maker(mock_jdftx, si_structure, mock_filenames, clean_dir):
responses = run_locally(job, create_folders=True, ensure_success=True)
output1 = responses[job.uuid][1].output
assert isinstance(output1, TaskDoc)


def test_output_loads_from_store(
mock_jdftx, si_structure, mock_filenames, clean_dir, memory_jobstore
):
"""A later job gets this output through its reference, decoded by MontyDecoder."""
mock_jdftx({"single_point": "sp_test"}, {})

maker = SinglePointMaker(input_set_generator=SinglePointSetGenerator())
maker.input_set_generator.user_settings["coords-type"] = "Lattice"

job = maker.make(si_structure)
run_locally(job, store=memory_jobstore, create_folders=True, ensure_success=True)

output = job.output.resolve(memory_jobstore)
assert isinstance(output, TaskDoc)
assert isinstance(output.calc_outputs.parameters, dict)
9 changes: 7 additions & 2 deletions tests/jdftx/sets/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
)


def _first(value):
"""Newer pymatgen-core reads repeatable tags such as fluid-cation as a list."""
return value[0] if isinstance(value, list) else value


@pytest.fixture
def basis_and_potential():
return {
Expand All @@ -21,15 +26,15 @@ def test_singlepoint_generator(si_structure, basis_and_potential):
gen = SinglePointSetGenerator(user_settings=basis_and_potential)
input_set = gen.get_input_set(si_structure)
jdftx_input = input_set.jdftxinput
assert jdftx_input["fluid-cation"]["concentration"] == 1.0
assert _first(jdftx_input["fluid-cation"])["concentration"] == 1.0
assert jdftx_input["lattice-minimize"]["nIterations"] == 0


def test_default_generator(si_structure, basis_and_potential):
gen = JdftxInputGenerator(user_settings=basis_and_potential)
input_set = gen.get_input_set(si_structure)
jdftx_input = input_set.jdftxinput
assert jdftx_input["fluid-cation"]["concentration"] == 1.0
assert _first(jdftx_input["fluid-cation"])["concentration"] == 1.0


def test_ionicmin_generator(si_structure, basis_and_potential):
Expand Down