feat: better state_handler
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
from .dice_config import DiceConfig
|
||||
from .gaussian_config import GaussianConfig
|
||||
from .player_config import PlayerConfig
|
||||
|
||||
|
||||
__all__ = [
|
||||
"DiceConfig",
|
||||
"GaussianConfig",
|
||||
"PlayerConfig",
|
||||
]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
from typing_extensions import List, Literal
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ class DiceConfig(BaseModel):
|
||||
"""
|
||||
Data Transfer Object for the Dice configuration.
|
||||
"""
|
||||
model_config = ConfigDict(
|
||||
frozen=True,
|
||||
)
|
||||
|
||||
ljname: str = Field(..., description="Name of the Lennard-Jones potential file")
|
||||
outname: str = Field(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
from typing_extensions import Literal
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ class GaussianConfig(BaseModel):
|
||||
"""
|
||||
Data Transfer Object for the Gaussian configuration.
|
||||
"""
|
||||
model_config = ConfigDict(
|
||||
frozen=True,
|
||||
)
|
||||
|
||||
level: str = Field(..., description="Level of theory for the QM calculations")
|
||||
qmprog: Literal["g03", "g09", "g16"] = Field(
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
from diceplayer.config.dice_config import DiceConfig
|
||||
from diceplayer.config.gaussian_config import GaussianConfig
|
||||
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
from typing_extensions import Self
|
||||
from pydantic import BaseModel, Field, model_validator, ConfigDict
|
||||
from typing_extensions import Self, Any
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
MIN_STEP = 20000
|
||||
STEP_INCREMENT = 1000
|
||||
|
||||
|
||||
class PlayerConfig(BaseModel):
|
||||
"""
|
||||
Data Transfer Object for the player configuration.
|
||||
"""
|
||||
model_config = ConfigDict(
|
||||
frozen=True,
|
||||
)
|
||||
|
||||
opt: bool = Field(..., description="Whether to perform geometry optimization")
|
||||
maxcyc: int = Field(
|
||||
@@ -42,7 +46,9 @@ class PlayerConfig(BaseModel):
|
||||
"simfiles", description="Directory name for the simulation files"
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_altsteps(self) -> Self:
|
||||
self.altsteps = round(max(MIN_STEP, self.altsteps) / 1000) * 1000
|
||||
return self
|
||||
@model_validator(mode="before")
|
||||
@staticmethod
|
||||
def validate_altsteps(fields) -> dict[str, Any]:
|
||||
altsteps = fields.pop("altsteps", MIN_STEP)
|
||||
fields["altsteps"] = round(max(MIN_STEP, altsteps) / STEP_INCREMENT) * STEP_INCREMENT
|
||||
return fields
|
||||
|
||||
Reference in New Issue
Block a user