How to validate my yaml file using hydra shema? #2827
-
I prefer to use hydra with omegaconf cuz it's convenient to run multiple experiments. And I now want to validate the arguments in given yaml file by checking them and raise error if not correct or of wrong type. So how can I validate the fixed args and do not validate the free args using hydra + omegaconf with dataclass as schema? Suppose my yaml file is below: mode: train # fixed arg, need to be validate
seed: 42 # fixed arg, need to be validate
scope:
a: 1 # free arg, no need to be validate
b: 2 # fixed arg, need to be validate If this can not be achieved, is there any other method better than writting check function for each fixed arg? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
@HydrogenSulfate please read the docs on structured configs, which let you define a schema for validation. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
I guess I have found a solution: using pydantic BaseModel and custom validators for each item to be checked, and seems works well.