diff --git a/src/jobflow_remote/config/base.py b/src/jobflow_remote/config/base.py index d9326df5..6d717e57 100644 --- a/src/jobflow_remote/config/base.py +++ b/src/jobflow_remote/config/base.py @@ -6,7 +6,7 @@ from typing import Annotated, Literal, Optional, Union from jobflow import JobStore -from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic import BaseModel, ConfigDict, Field, ValidationInfo, field_validator from qtoolkit.io import BaseSchedulerIO, scheduler_mapping from jobflow_remote.fireworks.launchpad import RemoteLaunchPad @@ -133,7 +133,7 @@ class WorkerBase(BaseModel): model_config = ConfigDict(extra="forbid") @field_validator("scheduler_type") - def check_scheduler_type(cls, scheduler_type: str, values: dict) -> str: + def check_scheduler_type(cls, scheduler_type: str, values: ValidationInfo) -> str: """ Validator to set the default of scheduler_type """ @@ -433,45 +433,45 @@ def get_launchpad(self) -> RemoteLaunchPad: return RemoteLaunchPad(self.get_queue_store()) @field_validator("base_dir") - def check_base_dir(cls, base_dir: str, values: dict) -> str: + def check_base_dir(cls, base_dir: str, values: ValidationInfo) -> str: """ Validator to set the default of base_dir based on the project name """ if not base_dir: from jobflow_remote import SETTINGS - return str(Path(SETTINGS.projects_folder, values["name"])) + return str(Path(SETTINGS.projects_folder, values.data["name"])) return base_dir @field_validator("tmp_dir") - def check_tmp_dir(cls, tmp_dir: str, values: dict) -> str: + def check_tmp_dir(cls, tmp_dir: str, values: ValidationInfo) -> str: """ Validator to set the default of tmp_dir based on the base_dir """ if not tmp_dir: - return str(Path(values["base_dir"], "tmp")) + return str(Path(values.data["base_dir"], "tmp")) return tmp_dir @field_validator("log_dir") - def check_log_dir(cls, log_dir: str, values: dict) -> str: + def check_log_dir(cls, log_dir: str, values: ValidationInfo) -> str: """ Validator to set the default of log_dir based on the base_dir """ if not log_dir: - return str(Path(values["base_dir"], "log")) + return str(Path(values.data["base_dir"], "log")) return log_dir @field_validator("daemon_dir") - def check_daemon_dir(cls, daemon_dir: str, values: dict) -> str: + def check_daemon_dir(cls, daemon_dir: str, values: ValidationInfo) -> str: """ Validator to set the default of daemon_dir based on the base_dir """ if not daemon_dir: - return str(Path(values["base_dir"], "daemon")) + return str(Path(values.data["base_dir"], "daemon")) return daemon_dir @field_validator("jobstore") - def check_jobstore(cls, jobstore: dict, values: dict) -> dict: + def check_jobstore(cls, jobstore: dict, values: ValidationInfo) -> dict: """ Check that the jobstore configuration could be converted to a JobStore. """ @@ -488,7 +488,7 @@ def check_jobstore(cls, jobstore: dict, values: dict) -> dict: return jobstore @field_validator("queue") - def check_queue(cls, queue: dict, values: dict) -> dict: + def check_queue(cls, queue: dict, values: ValidationInfo) -> dict: """ Check that the queue configuration could be converted to a Store. """