Evaluate Expression
1 version
Evaluate Python expressions on pipeline data
Use This When
- Creating conditional logic in pipelines without writing custom components
- Computing derived fields from multiple inputs like ratios, averages, or boolean combinations
- Implementing quick filters or transformations for prototyping before custom builds
- Building complex decision trees by combining multiple data streams
What It Does
- Evaluates Python expressions using asteval interpreter with pipeline inputs as variables
- Maps inputs to variables x0, x1, x2, etc. for use in expression string
- Returns result of expression evaluation which can be any type supported by inputs
- Supports arithmetic, comparisons, boolean logic, and limited Python standard library
Works Best With
- Multiple component outputs → this component → conditional routing or gating
- Data streams → this component → derived metrics or computed features
- Integration with detect-zone-transition or check-object-distance for complex rule evaluation
- Quick prototyping before implementing optimized custom component logic
Caveats
- Expression executed per message; avoid complex computations that impact throughput
- Sandboxed interpreter prevents file I/O and most unsafe operations for security
- Type errors in expressions fail the pipeline; validate expression syntax before deployment
- Not suitable for ML inference or heavy computation; use dedicated components instead
- Lambda expressions are not supported by the evaluator (
NotImplementedError); use statements/comprehensions instead - Builtins like
getattrare not available inside expressions - String
.format(...)on literals is blocked by the evaluator; prefer f‑strings inside expressions.
Versions
- 9fd40a9elatestdefaultlinux/amd64
Initial commit.