Flexible runtime validation for configs with variable nodes #1164
Unanswered
abefrandsen
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Greetings! I'm a big fan of this library and I'm trying to learn the best ways to perform config validation using structured configs and
OmegaConf.merge
. (I'll try to articulate my question coherently, but I'm at such a basic level where even that is difficult!)My question is about runtime type validation for a config that can have variable nodes. Here's a toy example of what I'm getting at. In the context of an ML project, I specify a model from a config as follows, where the
encoder
andprediction_head
nodes can be variable but all share a high-level structure:But since I want to support different types of encoders and prediction heads, another equally valid config might be (don't worry about the fact that a transformer encoder is typically not easily swappable with a feedforward network...):
I want to use a structured config to validate such configs at runtime. A first attempt at this could be:
The two example configs should validate just fine against this
ModelConfig
schema, but I'd like to further validate that the fields and types given in themodule_cfg
nodes are consistent with the corresponding value ofmodule_name
, and this is where I'm getting stuck. I don't want to write a separate structure config for every possible combination of specific encoders and decoders, but I want to be able to validate all such possible configs. While I found a (probably hackish) halfway solution, I'm very curious about how you all might approach this. Maybe I should just expect the user to provide correct values for these nodes (if they don't the code will almost surely error out as it tries to instantiate the specified module with the given init parameters) and be satisfied with my first attempt above?Thanks all!
Beta Was this translation helpful? Give feedback.
All reactions