Hey Kedroids! :kedro: With `OmegaConf` not suppor...
# questions
a
Hey Kedroids! K With
OmegaConf
not supporting tuple, how do you get over scenarios where tuple is absolutely necessary and list won't work? I know you can handle it inside code but sometimes that's too inconvenient. For example here, feature_range has to be a tuple and
scikit-learn>1.2.0
will raise an error if it's not, but
OmegaConf
won't accept it. Handling it case by case for every algorithm is not feasible at all, as it requires a mapping of all type hints.
Copy code
- object: sklearn.preprocessing.MinMaxScaler
  feature_range: [0, 1]
Using
PyYaml
you could do something like:
Copy code
feature_range: !!python/tuple [0, 1]
But this isn't supported in
OmegaConf
Is custom resolver the way? something like
{tuple:[1, 2, 3]}
Thanks! 🙂 CC: @Filipe Oliveira
n
resolver
🙇 2
this 1
check the polars use cases
p.s. it's not that OmegaConf not support tuple, but you cannot load YAML (language agnostic) into tuple. For any non-primitive type or special class, custom resolver is the way.
this 1
!!python/tuple is not a typical YAML syntax I believe, can you load it with
yaml.safe_load
?
IIRC that was a big security problem since you can inject arbitrary code to run from the config.
👍 2
a
Thanks @Nok Lam Chan. It works with
yaml.load
but I doubt it would work with
yaml.safe_load
Will give it a try
👍🏼 1
f
yes, it doesn’t 😢
👍🏼 1
d
As it shouldn’t!
Resolvers are your friend