IƱigo Hidalgo
04/26/2024, 12:23 PMmodel_options:
target: costs
primary_key: [a, b]
columns_to_load: ${append:${.primary_key}, ${.target}}
price_predictor:
_overrides:
target: price
model_options: ${merge:${model_options},${._overrides}}
base:
model_options: ${..model_options}
candidate3:
_overrides:
primary_key: [x, y, z]
target: revenue
model_options: ${merge:${..model_options},${._overrides}}
I was pleasantly surprised to find that for candidate3, columns_to_load
(${append:${.primary_key}, ${.target}}
) correctly resolved to ['x', 'y', 'z', 'revenue']
as opposed to ['a', 'b', 'costs']
.
Is there a predetermined order of operations when resolving config? This is the exact behavior I want, but I am not sure why it behaves this way, and whether this is dependable behavior.
I don't know why the merge was done first and the append at the end, which meant that the resolver had the "true" values of primary key and target available. I would've expected that maybe the first thing to be interpolated would be direct references to other keys, so model_options.columns_to_load
would already be [a, b, costs]
when it came time to be merged into price_predictor and candidate_3.
EDIT: clarityIƱigo Hidalgo
04/26/2024, 12:26 PMmarrrcin
04/26/2024, 2:31 PMIƱigo Hidalgo
04/26/2024, 2:47 PMInterpolations are evaluated lazily on access.From their documentation. I'm not really sure what "on access" implies for kedro configloading. But from that statement I'm gonna assume I'm safe to depend on this functionality until proven otherwise hahaha it's too useful
Nok Lam Chan
04/26/2024, 4:47 PMOmegaConf
.
"lazyily on access" is not true for Kedro, as it's eagerly resolved during the configuration resolution. There are some additional layers to make $global
works nicely with other config as well.Nok Lam Chan
04/26/2024, 4:52 PMkedro
resolves it in eager mode via
if key == "parameters":
# Merge with runtime parameters only for "parameters"
return OmegaConf.to_container(
OmegaConf.merge(*aggregate_config, self.runtime_params), resolve=True
)
Nok Lam Chan
04/26/2024, 4:53 PMIƱigo Hidalgo
04/26/2024, 5:07 PMmodel_options.columns_to_load
as [a, b, costs]
to kedro, when resolving the node price_predictor.candidate_3.model_options
where it makes reference to merge:${..model_options}
, it will actually return the unresolved node ${append:${.primary_key}, ${.target}}
.
Honestly, this is purely a guess, but it's the only thing I can come up with which would explain the behavior I observed.Nok Lam Chan
04/26/2024, 6:13 PMNok Lam Chan
04/26/2024, 6:14 PMIƱigo Hidalgo
04/29/2024, 8:56 AMIƱigo Hidalgo
04/29/2024, 8:57 AM