-
I found a couple of ways to validate my configuration parameters ( from dataclasses import dataclass
import hydra
from omegaconf import OmegaConf
@dataclass
class MyParam:
my_param: int # I want my_param to be an int
@hydra.main(config_path="./", config_name="test", version_base=None)
def main(cfg: MyParam) -> None:
print(OmegaConf.to_yaml(cfg)) # my_param: this_is_a_string
print(type(cfg.my_param)) # <class 'str'>
if __name__ == "__main__":
main() And this is my_param: this_is_a_string |
Beta Was this translation helpful? Give feedback.
Answered by
Jasha10
Jun 7, 2022
Replies: 1 comment 3 replies
-
See the docs on Structured Config schema. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
hogru
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the docs on Structured Config schema.
You'll need to use a schema if you want to take advantage of OmegaConf's runtime type checking.