Env Functions
exists
env command.exists(path: 'PathBuf', min_lines: 'Option < usize >')
Arguments
path: 'PathBuf'
=> Path to checkmin_lines: 'Option < usize >'
=> Minimum number of lines the file should have
Checks if the given path exists
Node Functions
exists
node command.exists(path: 'Template', min_lines: 'Option < usize >')
Arguments
path: 'Template'
=> Path to checkmin_lines: 'Option < usize >'
=> Minimum number of lines the file should have
Checks if the given path exists when rendering the template
command
node command.command(
cmd: '& Template',
verbose: 'bool' = true,
echo: 'bool' = false
)
Arguments
cmd: '& Template'
=> String Command template to runverbose: 'bool' = true
=> Show the rendered version of command, and other messagesecho: 'bool' = false
=> Echo the stdout from the command
Run the given template as a shell command.
Run any command in the shell. The standard output of the command
will be consumed and if there are lines starting with nadi:var:
and followed by key=val
pairs, it’ll be read as new attributes
to that node.
For example if a command writes nadi:var:name="Joe"
to stdout,
then the for the current node the command is being run for, name
attribute will be set to Joe
. This way, you can write your
scripts in any language and pass the values back to the NADI
system.
It will also print out the new values or changes from old values,
if verbose
is true.
Errors
The function will error if,
- The command template cannot be rendered,
- The command cannot be executed,
- The attributes from command’s stdout cannot be parsed properly
run
node command.run(
command: '& str',
inputs: '& str',
outputs: '& str',
verbose: 'bool' = true,
echo: 'bool' = false
)
Arguments
command: '& str'
=> Node Attribute with the command to runinputs: '& str'
=> Node attribute with list of input filesoutputs: '& str'
=> Node attribute with list of output filesverbose: 'bool' = true
=> Print the command being runecho: 'bool' = false
=> Show the output of the command
Run the node as if it’s a command if inputs are changed
This function will not run a command node if all outputs are older than all inputs. This is useful to networks where each nodes are tasks with input files and output files.
Network Functions
parallel
network command.parallel(
cmd: '& Template',
_workers: 'i64' = 4,
verbose: 'bool' = true,
echo: 'bool' = false
)
Arguments
cmd: '& Template'
=> String Command template to run_workers: 'i64' = 4
=> Number of workers to run in parallelverbose: 'bool' = true
=> Print the command being runecho: 'bool' = false
=> Show the output of the command
Run the given template as a shell command for each nodes in the network in parallel.
Warning
Currently there is no way to limit the number of parallel processes, so please be careful with this command if you have very large number of nodes.
command
network command.command(
cmd: 'Template',
verbose: 'bool' = true,
echo: 'bool' = false
)
Arguments
cmd: 'Template'
=> String Command template to runverbose: 'bool' = true
=> Print the command being runecho: 'bool' = false
=> Show the output of the command
Run the given template as a shell command.
Run any command in the shell. The standard output of the command
will be consumed and if there are lines starting with nadi:var:
and followed by key=val
pairs, it’ll be read as new attributes
to that node.
See node command.command
for more details as they have
the same implementation