Apolo
HomeConsoleGitHub
  • Apolo concepts
  • CLI Reference
  • Examples/Use Cases
  • Flow CLI
  • Actions Reference
  • Apolo Extras CLI
  • Python SDK
  • Workflows
  • Workflow syntax
    • Expression syntax
    • Live workflow syntax
      • Live contexts
    • Batch workflow syntax
      • Batch contexts
      • Batch workflow commands
    • Project configuration syntax
    • Actions syntax
      • Actions contexts
  • CLI reference
  • Expression functions
  • Mixins
  • Modules
Powered by GitBook
On this page
  • Basic functions
  • len(s)
  • keys(dictionary)
  • lower(string)
  • upper(string)
  • fmt(format_string, arg1, ...)
  • to_json(data)
  • from_json(json_string)
  • upload(volume_ctx)
  • parse_volume(string)
  • hash_files(pattern, ...)
  • inspect_job(job_name, [suffix])
  • values(dict_instance)
  • str(any)
  • replace(string, old, new)
  • join(separator, array)
  • Task status check functions
  • success([task_id, ...])
  • failure([task_id, ...])
  • always()

Was this helpful?

Expression functions

Basic functions

All expressions (${{ <expression }}) support a set of pre-built functions:

Function name
Description

Return the length of the argument.

Return the keys of the dictionary.

Convert a string to lowercase.

Convert a string to uppercase.

Perform string formatting.

Convert an object to a JSON string.

Convert a JSON string to an object.

Upload a volume to the Apolo storage.

Parse a volume reference string to an object.

Calculate a SHA256 hash of given files.

Get values from a dictionary.

Convert any object to a string.

Replace all occurrences of a symbol sequence in a string with a new one.

Concatenate an array of strings by inserting a separator between them

len(s)

Return the length of an object (the number of items it contains). The argument may be a string, a list, or a dictionary.

Example:

${{ len('fooo') }}

keys(dictionary)

Get the list of keys in a dictionary.

Example:

${{ keys(env) }}

lower(string)

Convert a string to lowercase.

Example:

${{ lower('VALue') == 'value' }}

upper(string)

Convert a string to uppercase.

Example:

${{ upper('valUE') == 'VALUE' }}

fmt(format_string, arg1, ...)

Perform a string formatting operation. The format_string can contain text or replacement fields delimited by curly braces {}. The replacement field will be replaced with other arguments' string values in order they appear in the format_string.

Example:

${{ fmt("Param test value is: {}", params.test) }}

This function can be useful in situations when you want to get a value from a mapping using a non-static key:

${{ needs[fmt("{}-{}", matrix.x, matrix.y)] }}

to_json(data)

Example:

${{ to_json(env) }}

from_json(json_string)

Parse a JSON string to an object.

Example:

${{ from_json('{"array": [1, 2, 3], "value": "value"}').value }}

upload(volume_ctx)

This function allows to automatically upload a volume before a job runs.

Example:

volumes:
  data:
    remote: storage:data
    mount: /data
    local: data
jobs:
  volumes:
    - ${{ upload(volumes.data).ref_rw }}

parse_volume(string)

Example:

${{ parse_volume("storage:data:/mnt/data:rw").mount == "/mnt/data" }}

hash_files(pattern, ...)

File names are relative to the flow's root (${{ flow.workspace }}).

Glob patterns are supported:

Pattern
Meaning

*

matches everything

?

matches any single character

[seq]

matches any character in seq

[!seq]

matches any character not in seq

**

recursively matches this directory and all subdirectories

The calculated hash contains hashed filenames to generate different results when the files are renamed.

Example:

${{ hash_files('Dockerfile', 'requiremtnts/*.txt', 'modules/**/*.py') }}

inspect_job(job_name, [suffix])

Example:

${{ inspect_job('test_job').http_url }}

values(dict_instance)

Get values from a dictionary. This is similar to Python's dict_instance.values().

Example:

${{ values(dictionary) }}

str(any)

Convert any object to a string.

Example:

${{ str(list_of_values) }}

replace(string, old, new)

Replace all occurrences of old in string with new.

Example:

${{ replace("5tring 5tring 5tring", "5", "S") }}

join(separator, array)

Concatenate an array of strings by inserting a separator between them.

Example:

${{ join(", ", ["1", "2", "3"] }}

Task status check functions

Function name
Description

True if given dependencies succeeded.

True if some of the given dependencies failed.

Mark a task to be always executed.

success([task_id, ...])

Example:

tasks:
  - enable: ${{ success() }}

Example with arguments:

tasks:
  - id: task_1
  - enable: ${{ success('task_1') }}

failure([task_id, ...])

Example:

tasks:
  - enable: ${{ failure() }}

Example with arguments:

tasks:
  - id: task_1
  - enable: ${{ failure('task_1') }}

always()

Example:

tasks:
  - enable: ${{ always() }}
PreviousCLI referenceNextMixins

Last updated 10 months ago

Was this helpful?

Convert any data to a JSON string. The result can be converted back using .

Upload the volume to the Apolo storage and then return the passed argument back. The argument should contain an entry of the . The function will fail if the is not set for the corresponding volume definition in the workflow file.

Parse a volume reference string into an object that resembles an entry of the . The id property will be set to "<volume>", and the local property will be set to None.

Calculate the of the given files.

Fetch info about a in live mode. The suffix argument should be used with . The returned object is a .

The following functions can be used in the attribute to conditionally enable task execution.

Returns True if all of the specified tasks are completed successfully. If no arguments are provided, checks all tasks form .

Returns True if at least one of the specified tasks failed. If no arguments are provided, checks all tasks form . This function doesn't enable task execution if a dependency is skipped or cancelled.

Returns a special mark so that Apolo Flow will always run this task, even if some tasks in have failed or were skipped, or the workflow was .

SHA256 hash
from_json(json_string)
len()
keys()
lower()
upper()
fmt()
to_json()
from_json()
upload()
parse_volume()
hash_files()
values()
str()
replace()
join()
success()
failure()
always()
JobDescription
volumes context
volumes context
local attribute
job
multi jobs
cancelled
tasks.enable
tasks.needs
tasks.needs
tasks.needs