### Start Docker Service (if needed) Source: https://viash.io/installation Starts the Docker daemon service if it is not already running. This is often necessary on Linux systems before running Docker commands. ```shell sudo systemctl start docker --now ``` -------------------------------- ### Configure Docker Engine with Image and Apt Setup Source: https://viash.io/reference/config/engines/docker This example shows how to configure the Docker engine with a base image and specifies apt packages to be installed during setup. This is useful for ensuring necessary tools like 'curl' are available in the Docker environment. ```yaml engines: - type: docker image: "bash:4.0" setup: - type: apt packages: [ curl ] ``` -------------------------------- ### Test Docker Installation via WSL2 Source: https://viash.io/installation Runs a 'hello-world' container to verify that Docker is installed and functioning correctly within the WSL2 environment. ```shell docker run hello-world ``` -------------------------------- ### Install Viash using wget Source: https://viash.io/installation Downloads and executes the Viash installation script using wget. This method installs Viash to a directory on the system's PATH. ```shell wget -qO- dl.viash.io | bash sudo mv viash /usr/local/bin ``` -------------------------------- ### Verify Viash Installation Source: https://viash.io/installation Checks if Viash has been installed correctly by displaying its help information. This command should be run after installation to confirm it's accessible. ```shell viash --help ``` -------------------------------- ### Install Viash using curl Source: https://viash.io/installation Downloads and executes the Viash installation script using curl. This method installs Viash to the current working directory. ```shell curl -fsSL dl.viash.io | bash mv viash $HOME/bin/viash ``` -------------------------------- ### Build Docker Image Notification Source: https://viash.io/guide/component/add-dependencies Example log message indicating the start of building a container image for a Viash component. ```text [notice] Building container 'example_bash_with_setup:latest' with Dockerfile ``` -------------------------------- ### Viash Docker Engine: Ruby Dependencies with GitHub Source: https://viash.io/guide/component/add-dependencies Example of specifying Ruby package dependencies and GitHub repositories for installation within a Viash Docker engine setup. ```yaml setup: - type: ruby packages: [ pry ] github: [ "pry/pry" ] ``` -------------------------------- ### Viash Docker Engine: Ruby Dependencies Source: https://viash.io/guide/component/add-dependencies Example of specifying Ruby package dependencies for installation within a Viash Docker engine setup. ```yaml setup: - type: ruby packages: [ pry ] ``` -------------------------------- ### Viash Placeholder Code Block Examples Source: https://viash.io/reference/viash_code_block Demonstrates the Viash placeholder code block structure for various programming languages, showing how user-defined parameters are declared within the VIASH START and VIASH END comments. ```Bash #!/bin/bash ## VIASH START par_input=path/to/file.txt par_output=output.txt ## VIASH END # copy file echo "Copying '$par_input' to '$par_output'." cp -r "$par_input" "$par_output" ``` ```C# using System.IO; // VIASH START var par = new { input = "path/to/file.txt", output = "output.txt" }; // VIASH END // copy file Console.WriteLine($"Copying '{par.input}' to '{par.output}'."); File.Copy(par.input, par.output, true); ``` ```JavaScript const fs = require('fs'); // VIASH START let par = { 'input': 'path/to/file.txt', 'output': 'output.txt' }; // VIASH END // copy file console.log(`Copying '${par['input']}' to '${par['output']}'`) fs.copyFile(par['input'], par['output'], (err) => { if (err) throw err; }); ``` ```Python import shutil ## VIASH START par = { 'input': 'file.txt', 'output': 'output.txt' } ## VIASH END # copy file print(f"Copying '{par['input']}' to '{par['output']}'.") shutil.copyfile(par['input'], par['output']) ``` ```R ## VIASH START par <- list( "input" = 'file.txt', "output" = 'output.txt' ) ## VIASH END # copy file cat("Copying '", par$input, "' to '", par$output, "'.\n", sep = "") file.copy(par$input, par$output) ``` ```Scala import java.nio.file.StandardCopyOption.REPLACE_EXISTING import java.nio.file.Files import java.nio.file.Paths // VIASH START case class ViashPar(input: String, output: String) val par = ViashPar( "path/to/file.txt", "output.txt" ) // VIASH END // copy file println(s"Copying '${par.input}' to '${par.output}'.") val fileIn = Paths.get(par.input) val fileOut = Paths.get(par.output) Files.copy(fileIn, fileOut, REPLACE_EXISTING) ``` -------------------------------- ### Build Docker Image Command (C#) Source: https://viash.io/guide/component/add-dependencies Command to build the Docker image for the 'example_csharp_with_setup' component, using the '--setup cachedbuild' flag. ```bash target/example_csharp_with_setup ---setup cachedbuild ``` -------------------------------- ### Build Docker Image Command (R) Source: https://viash.io/guide/component/add-dependencies Command to build the Docker image for the 'example_r_with_setup' component, using the '--setup cachedbuild' flag. ```bash target/example_r_with_setup ---setup cachedbuild ``` -------------------------------- ### Running VIASH Component (Bash Example) Source: https://viash.io/guide/component/add-resources Example command to run a VIASH component using Bash. This command executes a configuration file and specifies input and output parameters. ```bash viash run config.vsh.yaml -- --input config.vsh.yaml --output foo.txt ``` -------------------------------- ### Viash Docker Engine: Javascript Dependencies Source: https://viash.io/guide/component/add-dependencies Example of specifying Javascript package dependencies and optionally GitHub repositories for installation within a Viash Docker engine setup. ```yaml setup: - type: javascript packages: [ express ] github: [ "expressjs/express" ] ``` -------------------------------- ### Build Docker Image Command (JavaScript) Source: https://viash.io/guide/component/add-dependencies Command to build the Docker image for the 'example_js_with_setup' component, using the '--setup cachedbuild' flag. ```bash target/example_js_with_setup ---setup cachedbuild ``` -------------------------------- ### Viash Package Configuration Example Source: https://viash.io/reference/packageConfig Example of a _viash.yaml file demonstrating basic package configuration, including version, source, target, organization, and custom config modifications. ```yaml viash_version: 0.9.0 source: src target: target version: 1.0 organization: viash-io links: repository: 'https://github.com/viash-io/viash' docker_registry: 'ghcr.io' config_mods: | .runners[.type == 'nextflow'].directives.tag := '$id' .runners[.type == 'nextflow'].config.script := 'includeConfig("configs/custom.config")' ``` -------------------------------- ### Build Docker Image Command (Python) Source: https://viash.io/guide/component/add-dependencies Command to build the Docker image for the 'example_python_with_setup' component, using the '--setup cachedbuild' flag. ```bash target/example_python_with_setup ---setup cachedbuild ``` -------------------------------- ### Configure Docker Platform Base Image and Setup Source: https://viash.io/reference/config/deprecated/platforms/docker Defines a Docker platform for Viash components, specifying the base Docker image and the setup instructions for installing dependencies within the container. This allows for reproducible builds or pulling pre-built images. ```yaml platforms: - type: docker image: "bash:4.0" setup: - type: apt packages: [ curl ] ``` -------------------------------- ### Nextflow Platform Configuration Example Source: https://viash.io/reference/config/deprecated/platforms/nextflow Example of how to configure the Nextflow platform, specifying its type and associated directives like labels for resource allocation. ```yaml platforms: - type: nextflow directives: label: [lowcpu, midmem] ``` -------------------------------- ### Check Java Installation Source: https://viash.io/installation Verifies if Java is installed on the system. This is a prerequisite for Viash as it is developed in Scala. ```shell java -version ``` -------------------------------- ### Viash Docker Engine: Python Dependencies Source: https://viash.io/guide/component/add-dependencies Example of specifying Python package dependencies and optionally GitHub repositories for installation within a Viash Docker engine setup. ```yaml setup: - type: python packages: [ anndata ] github: [ jkbr/httpie ] ``` -------------------------------- ### Viash Docker Engine: Apt Dependencies Source: https://viash.io/guide/component/add-dependencies Example of specifying package dependencies to be installed using the 'apt' package manager within a Viash Docker engine setup. ```yaml setup: - type: apt packages: [ curl ] ``` -------------------------------- ### Install Python Packages from Generic URL Source: https://viash.io/reference/config/engines/docker/setup/pythonRequirements Installs Python packages from a generic URL, typically a zipball or tarball of the package source. The `setup` block also demonstrates this. ```yaml url: [ https://github.com/some_org/some_pkg/zipball/master ] ``` -------------------------------- ### Execute C# Component Source: https://viash.io/guide/component/create-component Example of executing a C# component named 'example_csharp'. Similar to the Bash example, it requires '--input' and '--output' parameters. The log output details the Docker image availability check, potential pull failures, and the container build process. ```csharp viash run config.vsh.yaml -- --input config.vsh.yaml --output foo.txt ``` ```text [notice] Checking if Docker image is available at 'example_csharp:latest' [warning] Could not pull from 'example_csharp:latest'. Docker image doesn't exist or is not accessible. [notice] Building container 'example_csharp:latest' with Dockerfile Copying '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/csharp/config.vsh.yaml' to '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/csharp/foo.txt'. ``` -------------------------------- ### Build Docker Image Command (Bash) Source: https://viash.io/guide/component/add-dependencies Command to build the Docker image for the 'example_bash_with_setup' component, using the '--setup cachedbuild' flag. ```bash target/example_bash_with_setup ---setup cachedbuild ``` -------------------------------- ### R Unit Test Setup for Viash Component Source: https://viash.io/guide/component/unit-testing This R code snippet shows the setup for a unit test of a Viash component. It defines the meta information, which includes the executable path for the R component. Further testing logic would follow this setup. ```r ## VIASH START meta <- list( "target/example_r" ) ``` -------------------------------- ### Nextflow Example Directives Source: https://viash.io/reference/config/runners/nextflow/directives A basic example of Nextflow directives specifying container, label, CPU, and memory requirements for a process. ```yaml directives: container: rocker/r-ver:4.1 label: highcpu cpus: 4 memory: 16 GB ``` -------------------------------- ### Configure Executable Runner with Port Source: https://viash.io/reference/config/runners/executable Example configuration for the executable runner, specifying the runner type and the port to be exposed. This is a basic setup for running code as an executable. ```yaml runners: - type: executable port: 8080 ``` -------------------------------- ### Example Summary Configuration Source: https://viash.io/reference/config Illustrates how to set a one-sentence summary for a Viash component, used in documentation generation. ```yaml summary: "A component for performing XYZ" ``` -------------------------------- ### Update and Upgrade Ubuntu Packages via WSL2 Source: https://viash.io/installation Updates the package list and upgrades all installed packages on Ubuntu running within WSL2. This ensures the system is up-to-date before further installations. ```shell sudo apt-get update && sudo apt-get upgrade -y ``` -------------------------------- ### Install Homebrew and Java 17 on macOS Source: https://viash.io/installation Installs Homebrew package manager and then OpenJDK 17 on macOS. Homebrew simplifies the installation of software on macOS. ```shell /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install openjdk@17 ``` -------------------------------- ### Install R Packages from Generic URL Source: https://viash.io/reference/config/engines/docker/setup/rRequirements Installs R packages from a generic URL, which can point to zip archives or other package distributions. Useful for installing specific versions or packages not hosted on standard repositories. ```yaml url: [ https://github.com/hadley/stringr/archive/HEAD.zip ] ``` -------------------------------- ### Install R Packages from Bitbucket Source: https://viash.io/reference/config/engines/docker/setup/rRequirements Installs R packages from Bitbucket repositories. Accepts package names in 'user/repo' format or full Git URIs. ```yaml bitbucket: [ org/package ] ``` -------------------------------- ### Install R Packages from GitHub Source: https://viash.io/reference/config/engines/docker/setup/rRequirements Installs R packages directly from GitHub repositories. Accepts package names in 'user/repo' format or full Git URIs. Useful for development versions or private repositories. ```yaml github: [ rcannood/SCORPIUS ] ``` -------------------------------- ### Specify Target Image Name for Setup Source: https://viash.io/reference/config/engines/docker Configures a specific name ('myfoo') for the Docker image that will be built when setup instructions are provided. If no setup is defined, the 'image' field is used. ```yaml target_image: myfoo ``` -------------------------------- ### Install R Packages from GitLab Source: https://viash.io/reference/config/engines/docker/setup/rRequirements Installs R packages from GitLab repositories. Similar to GitHub, it accepts 'user/repo' format or full Git URIs. ```yaml gitlab: [ org/package ] ``` -------------------------------- ### View Dockerfile for JavaScript Component Source: https://viash.io/guide/component/add-dependencies Displays the Dockerfile for the JavaScript component. It uses a Node.js slim image and installs curl and wget. ```Bash target/example_js_with_setup ---dockerfile ``` ```Dockerfile FROM node:19-bullseye-slim ENTRYPOINT [] RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y curl wget && \ rm -rf /var/lib/apt/lists/* LABEL org.opencontainers.image.description="Companion container for running component example_js_with_setup" LABEL org.opencontainers.image.created="2025-10-10T13:50:31Z" ``` -------------------------------- ### C# Docker Image with Setup Source: https://viash.io/guide/component/add-dependencies Defines a Viash component using a C# script, extending a .NET Docker image with 'curl' and 'wget' via package manager setup. Supports native and Docker engines, with executable and Nextflow runners. ```yaml name: example_csharp_with_setup description: A minimal example component. arguments: - type: file name: --input example: file.txt required: true - type: file name: --output direction: output example: output.txt required: true resources: - type: csharp_script path: script.csx engines: - type: docker image: ghcr.io/data-intuitive/dotnet-script:1.3.1 setup: - type: apk packages: - curl - wget - type: native runners: - type: executable - type: nextflow ``` -------------------------------- ### View Dockerfile for Scala Component Source: https://viash.io/guide/component/add-dependencies Displays the Dockerfile for the Scala component. It uses an sbt-based Scala image and installs curl and wget. ```Bash target/example_scala_with_setup ---dockerfile ``` ```Dockerfile FROM sbtscala/scala-sbt:eclipse-temurin-19_36_1.7.2_2.13.10 ENTRYPOINT [] RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y curl wget && \ rm -rf /var/lib/apt/lists/* LABEL org.opencontainers.image.description="Companion container for running component example_scala_with_setup" LABEL org.opencontainers.image.created="2025-10-10T13:51:53Z" ``` -------------------------------- ### Specify Apt Packages in Viash IO Setup Source: https://viash.io/reference/config/engines/docker/setup/aptRequirements This snippet demonstrates how to declare apt package requirements within the 'setup' section of a Viash IO component configuration. It specifies that the 'sl' package should be available. Dependencies include the Viash IO framework. ```yaml setup: - type: apt packages: [ sl ] ``` -------------------------------- ### String Argument with Example Value Source: https://viash.io/reference/config/arguments/string Specifies an example value for a string argument. This can serve as the default if no 'default' property is set. ```yaml - name: --my_string type: string example: "Hello World" ``` -------------------------------- ### YAML Example: Component References Source: https://viash.io/reference/config/references An example demonstrating how to define both DOI and BibTeX references for a component in YAML format. This is crucial for attribution and scientific reproducibility. ```yaml references: doi: 10.1000/xx.123456.789 bibtex: | @article{foo, title={Foo}, author={Bar}, journal={Baz}, year={2024} } ``` -------------------------------- ### VDSL3 Module Interface Example Source: https://viash.io/reference/nextflow_vdsl3/import_module Illustrates the expected input and output channel interface for VDSL3 modules. The module takes a channel of [id, state] tuples and emits a channel of [id, new_state] tuples, where state is a Map. ```nextflow workflow { Channel.fromList([ ["myid", [input: file("in.txt")]] ]) | mymodule } ``` -------------------------------- ### View Dockerfile for Python Component Source: https://viash.io/guide/component/add-dependencies Displays the Dockerfile for the Python component. It utilizes a slim Python image and installs anndata. ```Bash target/example_python_with_setup ---dockerfile ``` ```Dockerfile FROM python:3.10-slim ENTRYPOINT [] RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y curl wget && \ rm -rf /var/lib/apt/lists/* RUN pip install --upgrade pip && \ pip install --upgrade --no-cache-dir "anndata" LABEL org.opencontainers.image.description="Companion container for running component example_python_with_setup" LABEL org.opencontainers.image.created="2025-10-10T13:50:44Z" ``` -------------------------------- ### Define a file argument with an example value Source: https://viash.io/reference/config/arguments/file Provides an example value for a file argument. If no default value is specified, this example value will be used as the default. ```yaml - name: --my_file type: file example: data.csv ``` -------------------------------- ### Git Repository URI Example (YAML) Source: https://viash.io/reference/config/repositories/gitRepository An example demonstrating the format for specifying the Uniform Resource Identifier (URI) of a Git repository. This URI is used to locate the remote repository where dependency components are hosted. ```yaml uri: "git+https://github.com/openpipelines-bio/openpipeline.git" ``` -------------------------------- ### Scala Docker Image with Setup Source: https://viash.io/guide/component/add-dependencies Defines a Viash component using a Scala script, extending a Scala Docker image with 'curl' and 'wget' via package manager setup. Supports native and Docker engines, with executable and Nextflow runners. ```yaml name: example_scala_with_setup description: A minimal example component. arguments: - type: file name: --input example: file.txt required: true - type: file name: --output direction: output example: output.txt required: true resources: - type: scala_script path: script.scala engines: - type: docker image: sbtscala/scala-sbt:eclipse-temurin-19_36_1.7.2_2.13.10 setup: - type: apt packages: - curl - wget - type: native runners: - type: executable - type: nextflow ``` -------------------------------- ### Install JavaScript Packages from Generic URI Source: https://viash.io/reference/config/engines/docker/setup/javascriptRequirements This section details how to specify JavaScript packages to be installed from a generic Uniform Resource Identifier (URI), such as a zip archive. Provide the full URI for the package source. This can be a single URI or a list of URIs. ```yaml url: [ https://github.com/org/repo/archive/HEAD.zip ] ``` -------------------------------- ### Viash Version Output Source: https://viash.io/guide/project/package-config Example output showing the currently active Viash version after configuration. ```text viash 0.9.0 (c) 2020 Data Intuitive ``` -------------------------------- ### Install JavaScript Packages from GitHub Source: https://viash.io/reference/config/engines/docker/setup/javascriptRequirements This section details how to specify JavaScript packages to be installed directly from a GitHub repository. Provide the repository in the format 'owner/repository'. This can be a single repository or a list of repositories. ```yaml github: [ owner/repository ] ``` -------------------------------- ### Install JavaScript Packages from Git URI Source: https://viash.io/reference/config/engines/docker/setup/javascriptRequirements This section details how to specify JavaScript packages to be installed directly from a Git Uniform Resource Identifier (URI). Provide the full Git URI for the repository. This can be a single URI or a list of URIs. ```yaml git: [ https://some.git.repository/org/repo ] ``` -------------------------------- ### Bash Docker Image with Setup Source: https://viash.io/guide/component/add-dependencies Defines a Viash component using a Bash script, extending a Bash Docker image with 'curl' and 'wget' via package manager setup. Supports native and Docker engines, with executable and Nextflow runners. ```yaml name: example_bash_with_setup description: A minimal example component. arguments: - type: file name: --input example: file.txt required: true - type: file name: --output direction: output example: output.txt required: true resources: - type: bash_script path: script.sh engines: - type: docker image: bash:4.0 setup: - type: apk packages: - curl - wget - type: native runners: - type: executable - type: nextflow ``` -------------------------------- ### Docker Setup Strategy Configuration Source: https://viash.io/reference/config/deprecated/platforms/docker Configures the Docker setup strategy for building container images. Options range from always building, using cached builds, pulling from registries, or doing nothing. This setting determines how the Docker image is obtained or created. ```yaml setup_strategy: alwaysbuild ``` -------------------------------- ### Example Requirements Configuration (YAML) Source: https://viash.io/reference/config/computationalRequirements An example of how to specify computational requirements for a component in YAML format. This includes the number of CPUs and the amount of memory the component needs. ```yaml requirements: cpus: 5 memory: 10GB ``` -------------------------------- ### Viash Docker Engine: Apk Dependencies Source: https://viash.io/guide/component/add-dependencies Example of specifying package dependencies to be installed using the 'apk' package manager within a Viash Docker engine setup. ```yaml setup: - type: apk packages: [ curl ] ``` -------------------------------- ### Docker Setup with Custom Commands Source: https://viash.io/reference/config/engines/docker/setup/dockerRequirements Defines a Docker setup step that executes custom shell commands during the build process. It allows specifying build arguments and multi-line commands to be run. ```yaml setup: - type: docker build_args: "R_VERSION=hello_world" run: | echo 'Run a custom command' echo 'Foo' > /path/to/file.txt ``` -------------------------------- ### Viash Docker Engine: R Dependencies Source: https://viash.io/guide/component/add-dependencies Example of specifying R package dependencies, Bioconductor packages, and GitHub repositories for installation within a Viash Docker engine setup. ```yaml setup: - type: r packages: [ anndata ] bioc: [ AnnotationDbi, SingleCellExperiment ] github: rcannood/SCORPIUS ``` -------------------------------- ### View Dockerfile for R Component Source: https://viash.io/guide/component/add-dependencies Displays the Dockerfile for the R component. It uses an R2U base image and installs the tidyverse package. ```Bash target/example_r_with_setup ---dockerfile ``` ```Dockerfile FROM eddelbuettel/r2u:22.04 ENTRYPOINT [] RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y curl wget && \ rm -rf /var/lib/apt/lists/* RUN Rscript -e 'options(warn = 2); if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes")' && \ Rscript -e 'options(warn = 2); remotes::install_cran(c("tidyverse"), repos = "https://cran.rstudio.com")' LABEL org.opencontainers.image.description="Companion container for running component example_r_with_setup" LABEL org.opencontainers.image.created="2025-10-10T13:51:10Z" ``` -------------------------------- ### Nextflow Directives Configuration Example Source: https://viash.io/reference/config/deprecated/platforms/nextflow Shows how to set Nextflow directives for container image, CPU, memory, and labels to manage process execution. ```yaml directives: container: rocker/r-ver:4.1 label: highcpu cpus: 4 memory: 16 GB ``` -------------------------------- ### Execute Bash Component Source: https://viash.io/guide/component/create-component Example of executing a Bash component named 'example_bash'. It shows how to provide required file parameters like '--input' and '--output' to the component. The output log indicates the status of the Docker image check and build process. ```bash viash run config.vsh.yaml -- --input config.vsh.yaml --output foo.txt ``` ```text [notice] Checking if Docker image is available at 'example_bash:latest' [warning] Could not pull from 'example_bash:latest'. Docker image doesn't exist or is not accessible. [notice] Building container 'example_bash:latest' with Dockerfile Copying '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/bash/config.vsh.yaml' to '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/bash/foo.txt'. ``` -------------------------------- ### Viash Package Description Configuration Source: https://viash.io/reference/packageConfig Example of how to provide a multiline description for a Viash package, used for documentation purposes. ```yaml description: | A (multiline) description of the purpose of this package and the components it contains. ``` -------------------------------- ### Run Viash Component with Help Source: https://viash.io/guide/component/create-component This command demonstrates how to access the help information for a Viash component, providing an overview of its parameters and descriptions. It's useful for understanding the expected inputs and outputs. ```bash viash run config.vsh.yaml -- --help ``` -------------------------------- ### Install Viash Dependencies on WSL2 Ubuntu Source: https://viash.io/installation Installs OpenJDK 17, unzip, and zip packages on Ubuntu within WSL2. These are essential dependencies for Viash. ```shell sudo apt-get install -y openjdk-17-jdk unzip zip ``` -------------------------------- ### Install Java 17 on RHEL/Fedora Source: https://viash.io/installation Installs OpenJDK 17, unzip, and curl on RHEL or Fedora systems using the yum package manager. These are required dependencies for Viash. ```shell sudo yum install java-17-openjdk-devel unzip curl ``` -------------------------------- ### Argument Group Summary Example (YAML) Source: https://viash.io/reference/config/argumentGroup This YAML snippet demonstrates how to provide a concise one-sentence summary for an argument group, used for documentation. ```yaml summary: "Arguments related to functionality XYZ" ``` -------------------------------- ### Filtering Components with Query Source: https://viash.io/reference/cli/ns_exec This example shows how to filter which Viash components the command is applied to using the `--query` option with a regular expression. ```shell viash ns exec --query "^my_namespace/component_.*" --cmd 'echo Found component {path}' ``` -------------------------------- ### Install Java 17 on Debian/Ubuntu Source: https://viash.io/installation Installs OpenJDK 17, unzip, and curl on Debian or Ubuntu systems using the apt package manager. These are required dependencies for Viash. ```shell sudo apt-get update sudo apt-get install openjdk-17-jdk unzip curl ``` -------------------------------- ### Run R Executable with Input/Output Source: https://viash.io/guide/component/create-component Demonstrates running a Viash-generated R script by providing input and output file paths. This example shows the command-line invocation and the resulting output, including a confirmation message and file listing. ```r target/example_r --input config.vsh.yaml --output output.txt ``` ```text Copying '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/r/config.vsh.yaml' to '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/r/output.txt'. [1] TRUE ``` ```text ls -l total 20 -rw-r--r-- 1 runner runner 418 Oct 10 13:47 config.vsh.yaml -rw-r--r-- 1 runner runner 418 Oct 10 13:48 foo.txt -rw-r--r-- 1 runner runner 418 Oct 10 13:49 output.txt -rwxr-xr-x 1 runner runner 207 Oct 10 13:47 script.R drwxr-xr-x 2 runner runner 4096 Oct 10 13:49 target ``` -------------------------------- ### Run Scala Executable with Input/Output Source: https://viash.io/guide/component/create-component Shows how to execute a Viash-generated Scala script, requiring input and output file specifications. This example includes the command to run the script and the resulting file system information, noting any compilation warnings. ```scala target/example_scala --input config.vsh.yaml --output output.txt ``` ```text warning: 1 deprecation; re-run with -deprecation for details Copying '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/scala/config.vsh.yaml' to '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/scala/output.txt'. ``` ```text ls -l total 20 -rw-r--r-- 1 runner runner 462 Oct 10 13:47 config.vsh.yaml -rw-r--r-- 1 runner runner 462 Oct 10 13:48 foo.txt -rw-r--r-- 1 runner runner 462 Oct 10 13:49 output.txt -rw-r--r-- 1 runner runner 435 Oct 10 13:47 script.scala drwxr-xr-x 2 runner runner 4096 Oct 10 13:49 target ``` -------------------------------- ### Install Java 17 on Arch Linux Source: https://viash.io/installation Installs OpenJDK 17, unzip, and curl on Arch Linux systems using the pacman package manager. These are required dependencies for Viash. ```shell sudo pacman -Syy jdk17-openjdk unzip curl ``` -------------------------------- ### Viash `.run()`: State Management with `fromState` and `toState` Source: https://viash.io/reference/nextflow_vdsl3/import_module Illustrates how to manage component state using `fromState` and `toState` arguments in the `.run()` method. `fromState` fetches data into the module, while `toState` determines how the module's output updates the pipeline state. ```Groovy def component = Viash.loadComponent('my-component.nf') component.run( key: 'my-run', fromState: [ fastq_file: 'reads.fq' ], toState: { id, output, state -> state + [counts: output.counts] } ) ``` -------------------------------- ### View Dockerfile for Bash Component Source: https://viash.io/guide/component/add-dependencies Displays the Dockerfile used for the Bash component. This file defines the base image, entrypoint, and system dependencies required for the component. ```Bash target/example_bash_with_setup ---dockerfile ``` ```Dockerfile FROM bash:4.0 ENTRYPOINT [] RUN apk add --no-cache curl wget LABEL org.opencontainers.image.description="Companion container for running component example_bash_with_setup" LABEL org.opencontainers.image.created="2025-10-10T13:50:15Z" ``` -------------------------------- ### Example Bash Script for Text Processing Source: https://viash.io/quickstart An example Bash script for the 'remove_comments' Viash component. This script is designed to read an input file, remove lines starting with '#', and write the result to an output file. It demonstrates basic file processing in Bash. ```bash #!/bin/bash # Input and output file paths are expected as arguments INPUT_FILE=$1 OUTPUT_FILE=$2 # Remove lines starting with '#' and save to output file grep -v '^#' "$INPUT_FILE" > "$OUTPUT_FILE" # Exit with success status exit 0 ``` -------------------------------- ### Add User to Docker Group Source: https://viash.io/installation Adds the current user to the 'docker' group, allowing them to run Docker commands without sudo. A re-login is required for the changes to take effect. ```shell sudo usermod -aG docker $USER ``` -------------------------------- ### Apply Engine to Viash Components Source: https://viash.io/reference/cli/ns_exec This example shows how to use the `--apply_engine` option to execute a command for each Viash component, specifically targeting and applying each engine found in the config files. The `{engine}` and `{output}` placeholders are automatically filled. ```shell viash ns exec --apply_engine --engine "^python$" 'echo "Engine: {engine}, Output: {output}" \;' ``` -------------------------------- ### Run Commands in Dockerfile Source: https://viash.io/reference/config/engines/docker/setup/dockerRequirements Defines `RUN` instructions to be executed during the Docker image build. This is useful for installing packages or performing other setup tasks. Accepts a string or a list of strings, supporting multi-line commands. ```yaml run: | echo 'Run a custom command' echo 'Foo' > /path/to/file.txt ``` -------------------------------- ### Run Unit Tests with Viash (Bash Example) Source: https://viash.io/guide/component/unit-testing This snippet demonstrates how to run unit tests for a Viash project using the `viash test` command with a configuration file. It shows a typical output when tests are executed in a temporary directory, including Docker build processes and file operations. ```bash viash test config.vsh.yaml ``` -------------------------------- ### Execute Custom R Script Source: https://viash.io/reference/config/engines/docker/setup/rRequirements Allows execution of custom R code during the build process. This can be used for complex setup tasks or running specific R commands. The code block is executed directly. ```yaml script: | cat("Running custom code\n") install.packages("anndata") ``` -------------------------------- ### Viash Docker Setup Strategies Source: https://viash.io/guide/component/create-component Lists the available strategies for setting up Docker containers within Viash. These options control how the Docker image is built or pulled. ```plaintext ---setup=STRATEGY Setup the docker container. Options are: alwaysbuild, alwayscachedbuild, ifneedbebuild, ifneedbecachedbuild, alwayspull, alwayspullelsebuild, alwayspullelsecachedbuild, ifneedbepull, ifneedbepullelsebuild, ifneedbepullelsecachedbuild, push, pushifnotpresent, donothing. Default: ifneedbepullelsecachedbuild ``` -------------------------------- ### Set Docker Entrypoint (Shell Format) Source: https://viash.io/reference/config/engines/docker Demonstrates setting the Docker container's entrypoint using the shell format. This is a string-based alternative to the exec format. ```yaml entrypoint: "top -b" ``` -------------------------------- ### Set Example Value for Boolean Argument Source: https://viash.io/reference/config/arguments/boolean This example shows how to specify an example value for a boolean argument. If no 'default' property is defined, this 'example' value will be used as the default. ```yaml - name: --my_boolean type: boolean example: true ``` -------------------------------- ### Set Example Value for Double Argument Source: https://viash.io/reference/config/arguments/double This example shows how to specify an example value for a 'double' type argument. If no default value is provided, this example value will be used. ```yaml - name: --my_double type: double example: 5.8 ``` -------------------------------- ### Viash `.run()`: Automatic Processing and Debugging Options Source: https://viash.io/reference/nextflow_vdsl3/import_module Details the use of `auto` options (like `simplifyInput`, `simplifyOutput`, `publish`, `transcript`) and the `debug` flag in the `.run()` method for controlling automated tasks and verbosity. These simplify common pipeline operations. ```Groovy def component = Viash.loadComponent('my-component.nf') component.run( key: 'my-run', auto: [ simplifyInput: true, simplifyOutput: true, publish: true, transcript: true ], debug: true ) ``` -------------------------------- ### Import and Use Python Helper Functions Source: https://viash.io/guide/component/use-helper-functions This Python example illustrates importing helper functions within a Viash environment. It sets up input and output parameters and appends the resource directory to the system path to import and use a 'copy_file' function from a helper module. ```python import sys ## VIASH START par = { 'input': 'file.txt', 'output': 'output.txt' } ## VIASH END # import helper function sys.path.append(meta['resources_dir']) from helper import copy_file # copy file copy_file(par['input'], par['output']) ``` -------------------------------- ### Install R Packages from CRAN Source: https://viash.io/reference/config/engines/docker/setup/rRequirements Specifies R packages to install from the Comprehensive R Archive Network (CRAN). Supports single package names or lists of packages. This is a common method for installing stable R package versions. ```yaml cran: [ anndata, ggplot2 ] ``` ```yaml packages: [ anndata, ggplot2 ] ``` -------------------------------- ### Run Python Executable with Input/Output Source: https://viash.io/guide/component/create-component This example shows how to execute a Viash-generated Python script, specifying input and output files via command-line arguments. It includes the command to run the script and the subsequent file listing, indicating successful execution. ```python target/example_python --input config.vsh.yaml --output output.txt ``` ```text Copying '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/python/config.vsh.yaml' to '/viash_automount/tmp/Rtmp7GQqUa/create_new_component8d4e13c7eb41/python/output.txt'. ``` ```text ls -l total 20 -rw-r--r-- 1 runner runner 423 Oct 10 13:47 config.vsh.yaml -rw-r--r-- 1 runner runner 423 Oct 10 13:48 foo.txt -rw-r--r-- 1 runner runner 423 Oct 10 13:49 output.txt -rwxr-xr-x 1 runner runner 216 Oct 10 13:47 script.py drwxr-xr-x 2 runner runner 4096 Oct 10 13:49 target ``` -------------------------------- ### Example Nextflow Configuration for Viash Workflow Source: https://viash.io/quickstart A Nextflow configuration file (`nextflow.config`) used within a Viash project. This file typically defines process configurations, plugin management, and other pipeline-level settings for Nextflow. ```groovy plugins { id "nf-tower" version "2.+'" } process.container = 'docker.io/library/ubuntu:latest' // Example default container workDir = "work" // Example process configuration params.output_dir = "results" process.executor = 'local' ``` -------------------------------- ### Install R Packages from SVN URI Source: https://viash.io/reference/config/engines/docker/setup/rRequirements Installs R packages using a Subversion (SVN) URI. This is less common but provides compatibility with SVN repositories. ```yaml svn: [ https://path.to.svn/group/repo ] ``` -------------------------------- ### Install Python Packages from GitLab Source: https://viash.io/reference/config/engines/docker/setup/pythonRequirements Specifies Python packages to be installed directly from GitLab repositories. Similar to GitHub, this enables installation from specific project paths. ```yaml gitlab: [ foo/bar ] ``` -------------------------------- ### View Dockerfile for C# Component Source: https://viash.io/guide/component/add-dependencies Displays the Dockerfile used for the C# component. This file specifies the .NET script base image and necessary system packages. ```Bash target/example_csharp_with_setup ---dockerfile ``` ```Dockerfile FROM ghcr.io/data-intuitive/dotnet-script:1.3.1 ENTRYPOINT [] RUN apk add --no-cache curl wget LABEL org.opencontainers.image.description="Companion container for running component example_csharp_with_setup" LABEL org.opencontainers.image.created="2025-10-10T13:50:20Z" ``` -------------------------------- ### Install R Packages from Bioconductor Source: https://viash.io/reference/config/engines/docker/setup/rRequirements Installs R packages from Bioconductor, a repository for bioinformatics software. Accepts single package names or lists. Includes an option to force reinstallation. ```yaml bioc: [ AnnotationDbi, SingleCellExperiment ] ``` ```yaml bioc_force_install: false ``` -------------------------------- ### Define Apt Packages List in Viash IO Source: https://viash.io/reference/config/engines/docker/setup/aptRequirements This snippet shows how to list apt packages that need to be installed for a Viash IO component. It can accept a single package name or a list of package names. Dependencies include the Viash IO framework. ```yaml packages: [ sl ] ``` -------------------------------- ### Define Long Argument with an Example Value Source: https://viash.io/reference/config/arguments/long This example shows how to provide an example value for a 'long' argument. This serves as a hint for users and can be used as a default if no explicit 'default' property is set. ```yaml - name: --my_long type: long example: 100 ``` -------------------------------- ### Clone Viash Template Project Source: https://viash.io/quickstart Clones the Viash template repository from GitHub and changes the directory to the newly cloned project. This is the initial step for setting up a new Viash project. ```bash git clone https://github.com/youruser/my_first_pipeline.git && cd my_first_pipeline ``` -------------------------------- ### List Project Files Source: https://viash.io/quickstart Lists the files and directories in the current project directory using 'ls -l'. This command shows the contents of the project after the Viash build process, including the newly created 'target' directory. ```bash ls -l ``` -------------------------------- ### Example Viash Package Configuration (_viash.yaml) Source: https://viash.io/guide/project/package-config Defines project-wide settings for a Viash package, including name, organization, version, metadata, and Viash-specific configurations like viash_version. ```yaml # project settings name: project_template organization: viash-io version: 0.3.1 # metadata description: | This is a project template for viash projects. summary: | A project template for viash projects. keywords: [viash, template] license: GPL-3.0 links: repository: https://github.com/viash-io/viash_project_template issue_tracker: https://github.com/viash-io/viash_project_template/issues docker_registry: ghcr.io authors: - name: Alice roles: [author, maintainer] - name: Bob roles: [author] # settings viash_version: 0.9.4 ``` -------------------------------- ### Install Python Packages from SVN URI Source: https://viash.io/reference/config/engines/docker/setup/pythonRequirements Installs Python packages using an SVN URI. This is for packages hosted in Subversion repositories. ```yaml svn: [ http://svn.repo/some_pkg/trunk/#egg=SomePackage ] ``` -------------------------------- ### Nextflow Runner Configuration Example Source: https://viash.io/reference/config/runners/nextflow An example of how to configure the Nextflow runner within a Viash component. This specifies the runner type and associated directives. ```yaml runners: - type: nextflow directives: label: [lowcpu, midmem] ``` -------------------------------- ### Display VDSL3 Module Help Information Source: https://viash.io/guide/nextflow_vdsl3/create-and-use-a-module Show the available help information for a VDSL3 module when run as a standalone pipeline. This is useful for understanding the module's parameters and options. ```bash nextflow run target/main.nf --help ``` -------------------------------- ### Install Python Packages from Mercurial URI Source: https://viash.io/reference/config/engines/docker/setup/pythonRequirements Installs Python packages using a Mercurial URI. This is for projects managed with Mercurial version control. ```yaml mercurial: [ https://hg.myproject.org/MyProject/#egg=MyProject ] ``` -------------------------------- ### Install Python Packages from GitHub Source: https://viash.io/reference/config/engines/docker/setup/pythonRequirements Specifies Python packages to be installed directly from GitHub repositories. This allows for the use of unreleased or specific commits. ```yaml github: [ jkbr/httpie ] ```