Skip to content

Commit

Permalink
fix CP2K TaskDocument (#900)
Browse files Browse the repository at this point in the history
* bugfix for task document schema

* lint
  • Loading branch information
lory-w authored Jul 18, 2024
1 parent 1118986 commit 47d5acc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/atomate2/cp2k/schemas/calc_types/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path

from monty.serialization import loadfn
from pymatgen.io.cp2k.inputs import Cp2kInput, Keyword, KeywordList
from pymatgen.io.cp2k.inputs import Keyword, KeywordList

from atomate2.cp2k.schemas.calc_types import CalcType, RunType, TaskType

Expand Down Expand Up @@ -71,7 +71,7 @@ def task_type(inputs: dict) -> TaskType:
"""
calc_type = []
cp2k_run_type = inputs.get("cp2k_global", {}).get("Run_type", "")
ci = Cp2kInput.from_dict(inputs["cp2k_input"])
ci = inputs["cp2k_input"]

if cp2k_run_type.upper() in (
"ENERGY",
Expand Down
8 changes: 5 additions & 3 deletions src/atomate2/cp2k/schemas/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pymatgen.electronic_structure.bandstructure import BandStructure
from pymatgen.electronic_structure.dos import Dos
from pymatgen.io.common import VolumetricData
from pymatgen.io.cp2k.inputs import BasisFile, DataFile, PotentialFile
from pymatgen.io.cp2k.inputs import BasisFile, Cp2kInput, DataFile, PotentialFile
from pymatgen.io.cp2k.outputs import Cp2kOutput, parse_energy_file
from typing_extensions import Self

Expand Down Expand Up @@ -71,7 +71,9 @@ class CalculationInput(BaseModel):
None, description="Description of parameters used for each atomic kind"
)

cp2k_input: dict = Field(None, description="The cp2k input used for this task")
cp2k_input: Union[dict, Cp2kInput] = Field(
None, description="The cp2k input used for this task"
)

dft: dict = Field(
None,
Expand Down Expand Up @@ -170,7 +172,7 @@ class CalculationOutput(BaseModel):
ionic_steps: list[dict[str, Any]] = Field(
None, description="Energy, forces, and structure for each ionic step"
)
locpot: dict[int, list[float]] = Field(
locpot: Union[dict[int, list[float]], None] = Field(
None, description="Average of the local potential along the crystal axes"
)
run_stats: RunStatistics = Field(
Expand Down

0 comments on commit 47d5acc

Please sign in to comment.