Skip to content

Commit d2ba413

Browse files
replace deprecated 'FieldValidationInfo' with 'ValidationInfo' (#855)
1 parent fd3a7f9 commit d2ba413

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ppsci/utils/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
if importlib.util.find_spec("pydantic") is not None:
3535
from pydantic import BaseModel
3636
from pydantic import field_validator
37-
from pydantic_core.core_schema import FieldValidationInfo
37+
from pydantic_core.core_schema import ValidationInfo
3838

3939
__all__.append("SolverConfig")
4040

@@ -81,7 +81,7 @@ class SWAConfig(BaseModel):
8181
avg_range: Optional[Tuple[int, int]] = None
8282

8383
@field_validator("avg_range")
84-
def avg_range_check(cls, v, info: FieldValidationInfo):
84+
def avg_range_check(cls, v, info: ValidationInfo):
8585
if v[0] > v[1]:
8686
raise ValueError(
8787
f"'avg_range' should be a valid range, but got {v}."
@@ -145,7 +145,7 @@ def save_freq_check(cls, v):
145145
return v
146146

147147
@field_validator("start_eval_epoch")
148-
def start_eval_epoch_check(cls, v, info: FieldValidationInfo):
148+
def start_eval_epoch_check(cls, v, info: ValidationInfo):
149149
if info.data["eval_during_train"]:
150150
if v <= 0:
151151
raise ValueError(
@@ -155,7 +155,7 @@ def start_eval_epoch_check(cls, v, info: FieldValidationInfo):
155155
return v
156156

157157
@field_validator("eval_freq")
158-
def eval_freq_check(cls, v, info: FieldValidationInfo):
158+
def eval_freq_check(cls, v, info: ValidationInfo):
159159
if info.data["eval_during_train"]:
160160
if v <= 0:
161161
raise ValueError(
@@ -165,15 +165,15 @@ def eval_freq_check(cls, v, info: FieldValidationInfo):
165165
return v
166166

167167
@field_validator("ema")
168-
def ema_check(cls, v, info: FieldValidationInfo):
168+
def ema_check(cls, v, info: ValidationInfo):
169169
if "swa" in info.data and info.data["swa"] is not None:
170170
raise ValueError(
171171
"The config of 'swa' should not be used when 'ema' is specifed."
172172
)
173173
return v
174174

175175
@field_validator("swa")
176-
def swa_check(cls, v, info: FieldValidationInfo):
176+
def swa_check(cls, v, info: ValidationInfo):
177177
if "ema" in info.data and info.data["ema"] is not None:
178178
raise ValueError(
179179
"The config of 'ema' should not be used when 'swa' is specifed."
@@ -212,7 +212,7 @@ class InferConfig(BaseModel):
212212

213213
# Fine-grained validator(s) below
214214
@field_validator("engine")
215-
def engine_check(cls, v, info: FieldValidationInfo):
215+
def engine_check(cls, v, info: ValidationInfo):
216216
if v == "tensorrt" and info.data["device"] != "gpu":
217217
raise ValueError(
218218
"'device' should be 'gpu' when 'engine' is 'tensorrt', "
@@ -319,7 +319,7 @@ def seed_check(cls, v):
319319
return v
320320

321321
@field_validator("use_wandb")
322-
def use_wandb_check(cls, v, info: FieldValidationInfo):
322+
def use_wandb_check(cls, v, info: ValidationInfo):
323323
if not isinstance(info.data["wandb_config"], dict):
324324
raise ValueError(
325325
"'wandb_config' should be a dict when 'use_wandb' is True, "

0 commit comments

Comments
 (0)