https://www.boundaryml.com logo
🟡 Constraint error encountered with complex asser...
# questions
n
I am hitting this a lot with tests when I am going for a more complex asserts. I cannot really narrow it down. Constraint error: unknown test (in :1) Some of my asserts:
Copy code
// Validate Presenting Complaint section
    @@assert(has_presenting_complaint_section, {{ this.sections|selectattr('name', 'match', '.*Presenting Complaint.*|.*CO.*')|list|length > 0 }})
    @@assert(presenting_complaint_is_simple_list, {{ this.sections|selectattr('name', 'match', '.*Presenting Complaint.*|.*CO.*')|map(attribute='output_format')|first == "simple_list" }})
    @@assert(presenting_complaint_has_field_labels, {{ this.sections|selectattr('name', 'match', '.*Presenting Complaint.*|.*CO.*')|map(attribute='field_labels')|first is not none }})
    @@assert(presenting_complaint_has_instruction, {{ this.sections|selectattr('name', 'match', '.*Presenting Complaint.*|.*CO.*')|map(attribute='instruction')|first|length > 0 }})
    @@assert(presenting_complaint_instruction_mentions_reason, {{ "reason" in (this.sections|selectattr('name', 'match', '.*Presenting Complaint.*|.*CO.*')|map(attribute='instruction')|first|lower) or "visit" in (this.sections|selectattr('name', 'match', '.*Presenting Complaint.*|.*CO.*')|map(attribute='instruction')|first|lower) }})
Does anyone have a hint?
p
Does BAML support all of minjinja syntax? I presume you're referencing the Rust docs https://docs.rs/minijinja/latest/minijinja/filters/index.html#functions
But I'm wondering if all filters in minijinja are usable in BAML
selectattr and map don't seem to be documented, nor are there examples. Also, wow. Those are some pretty ugly and hard to read tests 😅
Those are the points at which I take things out of BAML and write the tests in the client language
n
hahaha yeah ugly tests but would love to do it in BAML even if ugly
I am generating a list of objects so I have to get the right objects and then test validate it
p
I'm also curious to know the subset of minijinja that's supported. And whether the Rust crate is directly lifted and works off the bat, or whether the BAML team need to massage the jinja outputs to work within the BAML test suite
n
cc @Vaibhav (BAML 🐑) enlighten us 😛
p
enums are a royal pain in jinja 😭
I think you can only solve it via regex, here's how I did it before
I don't think this is a bug, it's feature, of jinja 😛
*feature being, making one's life harder than it needs to be 🤣
But yeah its broadly used and out there, so makes sense why it's used in BAML
Jinja treats enum values as strings, so that's how we'd handle it in BAML too, is my understanding
v
yea enums in jinja are a bit weird. tho in that case the error just needs to get better. we should be able to fix the linter here! I think its doing the right thing.
what is the type of modifer btw?
we do support almost every minijinja filter. I'm gonna have to dig into this to figure out where the error is coming from. this is one thing we are actively working on fixing!
we're almost ready to share our way of writing imperitive code, do you can just write if / for statements and never have to think about
|
every again
n
That will be marvelous 😂
That jinja stuff broke my head
v
i too hate jinja
it was sadly a necessary evil