You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello there. I might be mistaken, so please do correct me if I'm wrong, but it seems like the when clause in tasks is checked by rendering the templated string, and then casting it to bool using copier.tools.cast_to_bool.
This boolean casting seems to treat a string containing only spaces or newlines as True, which prevents multi-line when clauses.
I tried using multi-line Jinja like this, to no avail :(
Desired Situation
I'd like to be able to use multi-line when conditions, for example:
examples_to_include:
type: strmultiselect: truechoices:
Image Classification (PyTorch): "image_classifier"Image Classification (Jax): "jax_image_classifier"Proximal Policy Optimization (Jax): "jax_ppo"LLM Fine-tuning (PyTorch, 🤗): "llm_finetuning"Text classification (PyTorch, 🤗): "text_classifier"default:
["image_classifier","jax_image_classifier","jax_ppo","llm_finetuning","text_classifier",]_tasks:
- command: uv remove transformers datasetswhen: | {% if (text_classifier' not in examples_to_include and 'llm_finetuning' not in examples_to_include ) %}true {% endif %}
Proposed solution
Can we make cast_to_bool treat a string with only whitespace as False?
I tried to find tests for the cast_to_bool function, but couldn't find any that directly called it with different values to check the results.
The text was updated successfully, but these errors were encountered:
While I agree the value should be stripped before evaluation, you can workaround this by relying on Jinja whitespace control.
_tasks:
- command: uv remove transformers datasetswhen: | {%- if (text_classifier' not in examples_to_include and 'llm_finetuning' not in examples_to_include ) -%}true {%- endif -%}
I think the proper way is to do it like this though:
_tasks:
- command: uv remove transformers datasetswhen: >- {{ text_classifier' not in examples_to_include and 'llm_finetuning' not in examples_to_include }}
Actual Situation
Hello there. I might be mistaken, so please do correct me if I'm wrong, but it seems like the
when
clause in tasks is checked by rendering the templated string, and then casting it to bool usingcopier.tools.cast_to_bool
.This boolean casting seems to treat a string containing only spaces or newlines as
True
, which prevents multi-linewhen
clauses.I tried using multi-line Jinja like this, to no avail :(
Desired Situation
I'd like to be able to use multi-line
when
conditions, for example:Proposed solution
Can we make
cast_to_bool
treat a string with only whitespace as False?I tried to find tests for the
cast_to_bool
function, but couldn't find any that directly called it with different values to check the results.The text was updated successfully, but these errors were encountered: