Skip to content

Expression builders

Expression helpers for workflow configuration strings.

The backend's expression engine accepts three interpolation syntaxes (see nexus-backend/src/workflow/expression/patterns.py):

  • {{ $node("Name").data.get("field") }} — read a prior node's output
  • {{ $input.data.get("field") }} — read the current node's input
  • {{ $variable("name") }} — read a workflow variable

Hand-writing these strings is error-prone: missing braces, wrong quote style, a typo in data.get silently ship as a literal string. This module provides tiny typed builders whose str() output is always a valid, runnable expression:

>>> from athena_sdk import expr
>>> str(expr.node("Postgres").get("table_name"))
"{{ $node('Postgres').data.get('table_name') }}"
>>> str(expr.input.get("status").eq("active"))
"{{ $input.data.get('status') == 'active' }}"
>>> str(expr.variable("api_key"))
"{{ $variable('api_key') }}"

Comparisons emit valid Python inside the {{ }} frame. Non-string literals (int, bool, None) render with Python's repr; strings use single quotes.

Expression

A single {{ ... }} expression. str() returns the rendered form.

eq

eq(other)

Emit <self> == <other>.

ne

ne(other)

Emit <self> != <other>.

gt

gt(other)

Emit <self> > <other>.

gte

gte(other)

Emit <self> >= <other>.

lt

lt(other)

Emit <self> < <other>.

lte

lte(other)

Emit <self> <= <other>.

node

node(name)

Reference a named upstream node. node('Postgres').get('table_name').

variable

variable(name)

Reference a workflow variable. variable('api_key').

raw

raw(body)

Escape hatch. Wraps body in {{ }} with no validation. Use when the built-in builders don't cover your expression shape.