Expression syntax
neuro-flow allows writing custom expressions in YAML configuration files.

About contexts and expressions

You can use expressions to programmatically set variables in workflow files and access contexts. An expression can be any combination of literal values, references to a context, or functions. You can combine literals, context references, and functions with the help of operators.
You need to use specific syntax to tell Neuro Flow to evaluate an expression rather than to treat it as a string.
1
${{ <expression> }}
Copied!

Example - setting an environment variable:

1
env:
2
my_env_var: ${{ <expression> }}
Copied!
Sometimes curly brackets conflict with other tools in your toolchain. For example, cookiecutter uses Jinja2 templates which also uses curly brackets for template formatting.
In this case, neuro-flow accepts the square brackets syntax for expressions: $[[ <expression> ]]. Both notations are equal and interchangeable.

Contexts

Contexts are a way to access information about workflow runs, jobs, tasks, volumes, images, etc. Contexts use the expression syntax.
1
${{ <context> }}
Copied!
There are two main sets of contexts: one is available for live mode and another one for batch mode. Additionally, actions can access a specific namespace with contexts that are similar but slightly different from ones from the main workflow. The following chapters describe all mentioned context namespaces in detail. Refer to live contexts, batch contexts, and actions contexts for details.

Property access

You can access properties of contexts and other objects using one of the following syntaxes:
  • Index syntax: flow['workspace']
  • Property dereference syntax: flow.workspace
In order to use property dereference syntax, the property name must:
  • start with a lettera-Z.
  • be followed by a letter a-Z, digit 0-9 or underscore _.

Literals

As part of an expression, you can use None, bool, int, float, or string data types.
Data type
Literal value
None
None
boolean
True or False(case sensitive).
int
Any integer defined by either decimal (42), hex (0xFF), octal (0o22), or binary
(0b1011) format.
float
A real number that contains digits after the period. Exponential notation is also supported.
string
You can use either single or double quotes for strings.
Example
1
env:
2
NoneValue: ${{ None }}
3
boolValue: ${{ False }}
4
intValue: ${{ 42 }}
5
intHexValue: ${{ 0xff }}
6
intOctalValue: ${{ 0o22}}
7
intBinaryValue: ${{ 0b1011 }}
8
floatValue: ${{ 0.22 }}
9
floatExponentialValue: ${{ 1-e10 }}
10
stringValue: ${{ "String with single quote: ' " }}
Copied!

Operators

Operator
Description
( )
Logical grouping
not
Not
<
Less than
<=
Less than or equal
>
Greater than
>=
Greater than or equal
==
Equal
!=
Not equal
and
And
or
Or

Lists and dictionaries

You can use lists and dictionaries in expressions.
Example
1
env:
2
list: ${{ [ value1, value2, value3 ] }}
3
emptyList: ${{ [] }}
4
dict: ${{ { "key1": "value1", "key2": "value2" } }}
5
emptyDict: ${{ {} }}
Copied!

Functions

To allow some operations in expressions, Neu.ro provides a set of built-in functions. The function call syntax is the following:
1
${{ function_name(arg1, arg2, arg3) }}
Copied!
When a function returns an object as the result, you can access properties as usual:
1
${{ parse_json('{"name": "value"}').name }}
Copied!
Check the functions reference for the list of available functions.
Last modified 6mo ago