Open
Description
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 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: str
multiselect: true
choices:
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 datasets
when: |
{% 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.