-
-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Initialisation pydantic BaseModel with List causing validation error #1184
Comments
Hi, There are some major changes in instantiating in the next version of Hydra (in master now). Can you share details about why you need to use pydantic here? |
Yes this will solve my problem. Any idea when these will be released?
I am using pydantic because of easy integration with FastApi and less boiler plate code related to validation like http endpoint, ip address, secret string, etc. Not related to this, is there any plan to support recursive initialisation via For example
|
Take a look at the docs I linked, the big change is recursive instantiation support. conversion strategies are just just a side thing. No target data for 1.1. You can follow the milestone progress (there are a lot of things not yet done in the list). In the mean time you can install from master. |
Cool thank you. Closing issue as feature request is already under development. BTW I am using hydra in two ways -
For rest API it is working like charm, and for SDK master branch will fix the issue which I am facing. |
Actually this is developed already. It would be good if you try it out and provide any feedback. About validating things like IP addresses etc: |
Just now tested master branch and Thanks for pointing about OmegaConf, I will check this out. |
Great. try recursive instantiation too! :)
Hydra is using OmegaConf for the config. |
@omry Is there possibility support |
You can use OmegaConf.to_container() directly. |
Thanks. My apologies, I was only focused on Hydra to achieve my configuration need. |
Hydra is utilizing OmegaConf extensively. It's a good use of your time to learn about OmegaConf as well. |
🐛 Bug
Description
First thank you for awesome project.
I am using compose API to initialise class which have only
List[str]
parameter. When passing config in initpydantic
throwing validation error thatvalue is not a valid list (type=type_error.list)
. I found that config is reading list asListConfig[str]
andpydantic
expect it as `List[str].Please suggest how to instruct compose to force parse config in python's fields.
Checklist
To reproduce
** Minimal Code/Config snippet to reproduce **
My config.yaml is as follows -
My Model class as follows -
This is how I am using hydra -
At
allowed_ports = AllowedPort(**cfg)
,pydantic
will throw validation error.** Stack trace/error message **
Expected Behavior
compose should have way to parse config in python default types.
System information
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: