Scripting variables

One of the major strengths of Viash is its automatic code generation. The generated variables can be accessed in your scripts.

Tip: You can use the viash config inject command to add all arguments from your Viash config file to your script automatically, together with the meta variables.

Config arguments

Any arguments you added to the functionality section of the Viash config file can be used in your scripts.

functionality:
  ...
  arguments:
  - type: string
    name: input
  ...

The input argument in the example above here can be called in different ways depending on the scripting language.

Bash:

echo $par_input

Python:

print(par["input"])

R example:

cat(par$input)

Javascript:

console.log(par['input']);

Scala:

println(par.input)

C#:

Console.WriteLine(par.input);

Meta variables

Viash offers some hidden variables to use in your scripts that can be used to get meta information about your component.

Functionality name

Name of the component found in the functionality section of the Viash config. Example: my_component_name.

Examples

Bash:

echo $meta_functionality_name

Python:

print(meta["functionality_name"])

R example:

cat(meta$functionality_name)

Javascript:

console.log(meta['functionality_name']);

Scala:

println(meta.functionality_name)

C#:

Console.WriteLine(meta.functionality_name);

Resources directory

Path where the resources as defined in the config file are stored. Example: /home/user/output/resources.

Examples

Bash:

echo $meta_resources_dir

Python:

print(meta["resources_dir"])

R example:

cat(meta$resources_dir)

Javascript:

console.log(meta['resources_dir']);

Scala:

println(meta.resources_dir)

C#:

Console.WriteLine(meta.resources_dir);

Temp directory

Path to the directory supplied by the host system where you can write temporary files to. Example: /tmp.

Examples

Bash:

echo $meta_temp_dir

Python:

print(meta["temp_dir"])

R example:

cat(meta$temp_dir)

Javascript:

console.log(meta['temp_dir']);

Scala:

println(meta.temp_dir)

C#:

Console.WriteLine(meta.temp_dir);