3
votes

I have a query related with Argo Workflow & JINJA template:

I know Argo workflow support JINJA template for expressions like: {{ ... }}, But does Argo workflow also supports JINJA template control structures like: {% ... %} ........ or not?

I am struggling with one use case, where I need to add below statement in “Single” WorkflowTemplate

{% if inputs.parameters.resources.gpu == 1 %}
    nvidia.com/gpu: {{ inputs.parameters.resources.gpu }}
{% end %}
1

1 Answers

0
votes

Argo Workflows does not currently support Jinja control structures.

If you're okay with a little code duplication, one workaround would be to use conditionals to implement a gpu == 1 and a gpu != 1 branch (as different steps).

You could also use podSpecPatch. It's a JSON string representation of a patch to be applied to a pod spec. For simple variations within that JSON, you could probably use Jinja string templating. For more complex mutations, you could generate the JSON in a step and then use it as an output parameter.