Config File

A Viash config file describes the behaviour of a script and the platform it runs on. It consists of two main sections: functionality and platforms.

The functionality section describes the core functionality of the component, such as its inputs, outputs, arguments, and extra resources. For each of the arguments, specifying a description and a set of argument restrictions help create a useful command-line interface. To ensure that your component works as expected, writing one or more tests is essential.

The platforms section specifies the requirements to execute the component on zero or more platforms. The list of currently supported platforms are:

If no platforms are specified, a native platform with no system requirements is assumed.

Usually, the config file is accompanied by a script which contains the actual code for the component.

Only a small example of a Viash config file is shown below, but check out the more detailed documentation regarding the functionality, the Native platform, the Docker platform and the Nextflow platform for the full specifications for each of these subsections.

Example

Here are the contents of a file named config.vsh.yaml:

functionality:
  name: addrowlines
  description: Add rowlines to a text file.
  arguments:
  - name: input                           
    type: file
    description: The input file.
  resources:
  - type: bash_script
    path: script.sh
platforms:
  - type: native
  - type: docker
    image: bash:4.0
  - type: nextflow
    image: bash:4.0

As you can see, this file describes the component. It has the following metadata:

  • Component name
  • A short description
  • A list of arguments that are accepted by the script, in this case a file named input
  • A list of resources, with the type of script and its relative location
  • The list of supported platforms and their parameters

The bash script named script.sh is placed next to the config file with the following content:

#!/bin/bash
cat -n $par_input

The component can be executed with its default (top) platform by running the following command:

viash run config.vsh.yaml -- config.vsh.yaml | head -5
     1  functionality:
     2    name: addrowlines
     3    description: Add rowlines to a text file.
     4    arguments:
     5    - name: input                           

Using the Docker platform instead is quite easy, just pass along the -p (for platform) switch with the platform you want to use instead:

viash run -p docker config.vsh.yaml -- config.vsh.yaml | head -5
[critical] Docker daemon does not seem to be running. Try one of the following:
[critical] - Try running 'dockerd' in the command line
[critical] - See https://docs.docker.com/config/daemon/

Every component comes with its own CLI baked in, so you can run --help to get an overview of a particular component:

viash run config.vsh.yaml -- --help
addrowlines <not versioned>
Add rowlines to a text file.

Options:
   input
        type: file
        The input file.