CONFIGS CONSOLIDATIONS / INTERPOLATIONS in conf/...
# questions
m
CONFIGS CONSOLIDATIONS / INTERPOLATIONS in conf/config.yml
random_state: 42
and in conf/model_training.yml
random_state: ${random_state}
Copy code
kedro run 
>>> [...] 
TypeError: Cannot cast scalar from dtype('<U15') to dtype('int64') according to the rule 'safe'
If I get this correctly, the consolidation / interpolation process resulted in
random_state
being assigned the value
"42"
instead of
42
Granted, I could easily circumvent this issue with
int(params['random_state'])
, but I’m curious and would like to know if this is an expected behavior, and whether there is a more robust / elegant way of handling it. Thx in advance M
d
which config loader are you using ?
you can also try this
random_state: !!int 42
I think that will coerce it properly https://pyyaml.org/wiki/PyYAMLDocumentation
m
Thx @datajoely I wasn’t aware of this syntax for type coercion 🙂 Regarding the loader: I’m just using the default, plain vanilla
ConfigLoader
Could that be the issue ? Shall I use another loader ? Thx
Hmmm… It looks like it could indeed be the issue. I’ve just tried to do
int(params['random_state']
and got
ValueError: invalid literal for int() with base 10: '${random_state}'
I guess variable interpolation requires another config loader… 😅
ah… If only I read (or memorized) documentations better: https://docs.kedro.org/en/stable/configuration/advanced_configuration.html
d
Yes - but longer term the default ConfigLoader (which will be replaced) will have this natively
m
Oh ! great to hear 👍