Hey guys, I'm trying to do a "for loop" on the cat...
# questions
Hey guys, I'm trying to do a "for loop" on the catalog, so I am using TemplatedConfig so I can use jinja. I am trying with the following way, and I am not sure why it is not working. Catalog:
Copy code
{%- for item in mylist %}
out.blind_predictions_{{ item-}}:
    type: pandas.CSVDataSet
    filepath: ${filepath1}_{{ item-}}.csv
    layer: out
{% endfor %}
Copy code
    - item1
    - item2
(For obvious reasons I removed the actual names from the text here) Does anyone know how to accomplish this? (do a for here)
https://docs.kedro.org/en/stable/configuration/advanced_configuration.html#how-to-use-jinja2-syntax-in-configuration You may need to create your custom config loader,
can be interpolated with
but it cannot be used to form the for-loop.
Cc @Ankita Katiyar as I think this is a good example to include for the migration guide
👍 1
Wow, I had no idea about this dataset factory. I will try it out.
It's relatively new feature, we are still trying to improve the docs so we haven't promoted this feature yet.
I am using kedro 0.18.3, but I don't seem to have config.OmegaConfigLoader, do I need to upgrade my kedro?
Also, do you know why I cannot use the for loop? If it supports jinja, I don't see why I can't.
You will need to upgrade your kedro version.
For loop is supported, if you change
Copy code
{%- for item in mylist %}
Copy code
{%- for item in ["item1", "item2"] %}
it should work.
Under the hood the config was loaded with
, to pass global variable into Jinja is not supported out of the box.
So the for works, but I cannot use variables? Hmm, that's weird haha
The for will do it for my case, thank you for the tips!
👍🏼 1