Repository navigation
Workflow expression evaluator #4917
Replies: 1 comment
|
Thanks for raising this. Evaluating a library-backed replacement seems worthwhile, but the current syntax is Jinja2-like rather than fully Jinja-compatible. We would need to account for typed single-expression results, missing-path handling, numeric-string comparisons, custom filter behavior, and condition diagnostics. Alongside Jinja2, these alternatives seem worth considering:
I would initially shortlist Jinja2 and Lark, with pyparsing as another parser-focused option. They address different goals: Jinja2 could outsource more of the evaluator, while Lark could remove fragile parsing machinery without changing the workflow language. A useful prototype would compare against the existing expression and condition cases, identify behavioral differences, and show whether the compatibility layer actually leaves us with less code and maintenance. That would give us evidence for choosing a library rather than assuming similar syntax means equivalent behavior. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I stumbled across the workflow expressions and had a closer look at
workflows/expressions.py. The evaluator is its own parser, around 1.5k lines including the condition diagnostics. The syntax is basically Jinja2 ({{ }}, pipe filters,and/or/not), and ARCHITECTURE.md calls it "Jinja2-like".I couldn't find anything on why an existing library (e.g. a sandboxed Jinja2) wasn't used. Was that a conscious decision, or did it just grow that way?
I thought replacing the custom implementation with a library could take some complexity out of the codebase. What do you think? I'd be happy to try a prototype if there's interest.
All reactions