Description of the feature
Reclass exports allow exposing and querying parameters between targets. While great, it is tricky to wrap (at least for me) how it works due to its somewhat cryptic querying expressions and the fact that is is specific to reclass. See reclass exports and inventory queries here
There is also the current support for calling inventory_global() in a component to allow full scanning to all targets, however this is usually extremely expensive and inefficient.
For this reason, I am thinking that we can create new mechanics to offer similar functionality for this use case.
Let's call these "topics".
Here's my proposal:
Let's imagine that target-1 and target-2 need to expose the colour parameter for target-3 to consume. We do this by declaring the parameters under colours topic in parameters.kapitan.topics.colours.parameters:
# target-1
parameters:
colour: red
kapitan:
topics:
colours:
parameters:
colour: ${colour}
# target-2
parameters:
colour: blue
kapitan:
topics:
colours:
parameters:
colour: ${colour}
Kapitan's inventory logic (regardless of the inventory backend implementation) would then merge these topic parameters as the parameters of the new dynamic _topic_colours target. Note that the purpose of dynamic targets is for the consumption of topics, so these will not be included in the compile loop and therefore will not have any compiled outputs.
So _topic_colours's parameters would look like this:
# _topic_colours
parameters:
targets:
target-1:
colour: red
target-2:
colour: blue
Now a component in target-3 can consume colours declared in the other targets via the inventory() (or maybe a new function):
# components.painter
from kapitan.inputs.kadet import inventory
def main():
target_colours = {}
for target, parameters in inventory(topic="colours").parameters.targets.items():
target_colours[target] = {"colour", parameters.colour}
return target_colours
this should compile the output:
# compiled/target-3/painter.yml
---
target-1:
colour: red
target-2:
colour: blue
I am thinking this would simplify what we can do today with reclass (and can't with omegaconf) without the cryptic query expressions in the inventory.
Additional context
No response
Description of the feature
Reclass exports allow exposing and querying parameters between targets. While great, it is tricky to wrap (at least for me) how it works due to its somewhat cryptic querying expressions and the fact that is is specific to reclass. See reclass exports and inventory queries here
There is also the current support for calling
inventory_global()in a component to allow full scanning to all targets, however this is usually extremely expensive and inefficient.For this reason, I am thinking that we can create new mechanics to offer similar functionality for this use case.
Let's call these "topics".
Here's my proposal:
Let's imagine that
target-1andtarget-2need to expose thecolourparameter fortarget-3to consume. We do this by declaring the parameters undercolourstopic inparameters.kapitan.topics.colours.parameters:Kapitan's inventory logic (regardless of the inventory backend implementation) would then merge these topic parameters as the parameters of the new dynamic
_topic_colourstarget. Note that the purpose of dynamic targets is for the consumption of topics, so these will not be included in the compile loop and therefore will not have any compiled outputs.So
_topic_colours's parameters would look like this:Now a component in
target-3can consume colours declared in the other targets via theinventory()(or maybe a new function):this should compile the output:
I am thinking this would simplify what we can do today with reclass (and can't with omegaconf) without the cryptic query expressions in the inventory.
Additional context
No response