-
Notifications
You must be signed in to change notification settings - Fork 619
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
add omegaconf
to _JSON_SERIALIZABLE_TYPES
#2212
Comments
@not-lain could you share which library you are trying to integrate and what you've tried that didn't work? I'm not familiar with |
@Wauplin yeh sure : |
I feel that there are 2 different parts to the problem:
That been said, I do like how they handle configs with proper yaml files. Here we are not talking about a few hyperparameters but entire yaml files which are tens of lines long. What |
I think we can do something like this in the deserialization : in the serialization :
|
I can create a pr about this implementing the same logic, should I do it ? |
This is what we already do for dataclasses so it's possible to do it. However, I'm not sure we want to do it's not really standard library (and not so popular compared to other libs). I don't want us to add more and more special cases and would prefer that special cases are handled by individual repos instead. OR we could add a way to define a custom json serializer/deserializer when inheriting from |
fundamentally omegaconf and dict are different on a miniature state which is that you can do both
i can do it all i need to do it transform the input to
nahh, too much work me, i'll just work aroud it by the solution i mentioned in this comment (convert to dict before passing to init and then reconvert it back) shortcuts are my thing 😎👉👉 |
dict
and/or omegaconf
to _JSON_SERIALIZABLE_TYPES
omegaconf
to _JSON_SERIALIZABLE_TYPES
I made it work with the solution above. params = OmegaConf.to_container(omg_params)
model(**params) 2- reconvert them back in the init method using def __init__(self,params) :
omg_params = OmegaConf.create(params) |
Great! This is what should be done yes! Maybe in def __init__(self,params) :
omg_params = OmegaConf.create(params) if isinstance(params, dict) else params Apart from that, I think it's the right approach. I'll close this issue as there's nothing to fix/add in |
I'm working on integrating an AI model with
PyTorchModelHubMixin
and it seems that I cannot serialize the input because it does not belong to the_JSON_SERIALIZABLE_TYPES
.some of my parameters are of type
omegaconf
i tried converting them to a python standarddict
, but again i am still limited by_JSON_SERIALIZABLE_TYPES
.also pinging @Wauplin for feedback
The text was updated successfully, but these errors were encountered: