Skip to content

Commit

Permalink
Merge pull request #506 from viash-io/develop
Browse files Browse the repository at this point in the history
Viash 0.7.5 (2023-08-11): Minor breaking changes and new features
  • Loading branch information
Grifs authored Aug 14, 2023
2 parents 652cbae + eda3537 commit 5c4e867
Show file tree
Hide file tree
Showing 187 changed files with 6,167 additions and 3,672 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/sbt_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ jobs:
fail-fast: false
matrix:
config:
- {name: 'ubuntu_latest', os: ubuntu-latest }
- {name: 'macos_latest', os: macos-latest }
- { name: 'ubuntu_latest', os: ubuntu-latest }
- { name: 'macos_latest', os: macos-latest }
java:
- { ver: '11', run_nextflow: true, run_coverage: false }
- { ver: '17', run_nextflow: true, run_coverage: true }
- { ver: '20', run_nextflow: false, run_coverage: false }

steps:
- uses: actions/checkout@v3

- name: Set up Nextflow
- uses: viash-io/viash-actions/update-docker-engine@v3
if: runner.os == 'Linux'

- name: Set up Nextflow
if: ${{ runner.os == 'Linux' && matrix.java.run_nextflow }}
run: |
mkdir -p "$HOME/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH
Expand All @@ -42,7 +49,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '11'
java-version: ${{ matrix.java.ver }}

- name: Set up Scala
run: |
Expand All @@ -52,19 +59,22 @@ jobs:
sudo apt-get update
sudo apt-get install -y scala
fi
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Run tests
run: |
if [[ "${{ matrix.config.name }}" == ^ubuntu_latest$ ]]; then
if [[ "${{ matrix.config.name }}" =~ ^ubuntu.*$ ]] && [[ "${{ matrix.java.run_coverage }}" == "true" ]]; then
# only run coverage on main runner
sbt clean coverage test coverageReport
elif [[ "${{ matrix.config.name }}" =~ ^ubuntu.*$ ]] && [[ "${{ matrix.java.run_nextflow }}" == "false" ]]; then
sbt 'testOnly -- -l io.viash.NextflowTest'
elif [[ "${{ matrix.config.os }}" =~ ^macos.*$ ]]; then
# macOS on github actions does not have Docker, so skip those
sbt 'testOnly -- -l io.viash.DockerTest -l io.viash.NextFlowTest'
sbt 'testOnly -- -l io.viash.DockerTest -l io.viash.NextflowTest'
else
sbt test
fi
Expand Down
86 changes: 86 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,89 @@
# Viash 0.7.5 (2023-08-11): Minor breaking changes and new features

This release contains minor breaking change due to deprecated or outdated functionality being removed.

New functionality includes:

- Export a JSON schema for the Viash config with `viash export json_schema`

- Export a Bash or Zsh autocomplete script with `viash export cli_autocomplete`

- Nextflow VDSL3 modules now have a `fromState` and `toState` argument to allow for better control of the data that gets passed to the module and how the state is managed in a Nextflow workflow.

## BREAKING CHANGES

* `viash export cli_schema`: Added `--format yaml/json` argument, default format is now a YAML (PR #448).

* `viash export config_schema`: Added `--format yaml/json` argument, default format is now a YAML (PR #448).

* `NextflowLegacyPlatform`: Removed deprecated code (PR #469).

* `viash_*`: Remove legacy viash_build, viash_test and viash_push components (PR #470).

* `ComputationalRequirements`, `Functionality`, `DockerPlatform`, `DockerRequirements`: Remove documentation of removed fields (PR #477).

## NEW FUNCTIONALITY

* `viash export json_schema`: Export a json schema derived from the class reflections and annotations already used by the `config_schema` (PR #446).

* `viash export config_schema`: Output `default` values of member fields (PR #446).

* `CI`: Test support for different Java versions on GitHub Actions (PR #456). Focussing on LTS releases starting from 11, so this is 11 and 17. Also test latest Java version, currently 20.

* `viash test` and `viash ns test`: add `--setup` argument to determine the docker build strategy before a component is tested (PR #451).

* `viash export cli_autocomplete`: Export a Bash or Zsh autocomplete script (PR #465 & #482).

* `help message`: Print the relevant help message of (sub-)command when `--help` is given as an argument instead of only printing the help message when it is the leading argument and otherwise silently disregarding it (initially added in PR #472, replaced by PR #496). This is a new feature implemented in Scallop 5.0.0.

* `Logging`: Add a Logger helper class (PR #485 & #490). Allows manually enabling or disabling colorizing TTY output by using `--colorize`. Add provisions for adding debugging or trace code which is not outputted by default. Changing logging level can be changed with `--loglevel`. These CLI arguments are currently hidden.

* `NextflowPlatform`: Nextflow VDSL3 modules now have a `fromState` and `toState` argument to allow for better control of the data that gets passed to the module and how the state is managed in a Nextflow workflow (#479, PR #501).

## MINOR CHANGES

* `PythonScript`: Pass `-B` to Python to avoid creating `*.pyc` and `*.pyo` files on importing helper functions (PR #442).

* `viash config`: Special double values now support `+.inf`, `-.inf` or `.nan` values (PR #446 and PR #450). The stringified versions `"+.inf"`, `"-.inf"` or `".nan"` are supported as well. This is in line with the yaml spec.

* `system environment variables`: Add wrapper around `sys.env` and provide access to specific variables (PR #457). Has advantages for documentation output and testbenches.

* `testbench`: Added some minor testbenches to tackle missing coverage (PR #459, #486, #488, #489, #492 & #494).

* `viash export config_schema`: Simplify file structure (PR #464).

* `helpers.Format`: Add a helper for the Format helper object (PR #466).

* `testbench`: Use config deriver to create config variants for testing (PR #498). This reduces the amount of config files that need to be maintained.

## BUG FIXES

* `viash config`: Validate Viash config Yaml files better and try to give a more informative error message back to the user instead of a stack trace (PR #443).

* `viash ns build`: Fix the error summary when a setup or push failure occurs. These conditions were not displayed and could cause confusion (PR #447).

* `testbench`: Fix the viash version switch test bench not working for newer Java versions (PR #452).

* `malformed input exception`: Capture MalformedInputExceptions when thrown by reading files with invalid Ascii characters when unsupported by Java (PR #458).

* `viash project file parsing`: Give a more informative message when the viash project file fails to parse correctly (PR #475).

* `DockerPlatform`: Fix issue when mounting an input or output folder containing spaces (PR #484).

* `Config mod`: Fix a config mod where the filter should execute multiple deletes (PR #503).

## DOCUMENTATION

* `NextflowPlatform`: Add documentation for the usage and arguments of a VDSL3 module (PR #501).

## INTERNAL CHANGES

* `NextflowVDSL3Platform`: Renamed to `NextflowPlatform` (PR #469).

* Rename mentions of `NextFlow` to `Nextflow` (PR #476).

* `Reference static pages`: Move `.qmd` files from the website to a local folder here; `docs/reference` (PR #504). This way we can track behaviour changes that need to be documented locally.

# Viash 0.7.4 (2023-05-31): Minor bug fixes and minor improvements to VDSL3

Some small fixes and consistency improvements.
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name := "viash"

version := "0.7.4"
version := "0.7.5"

scalaVersion := "2.13.10"

libraryDependencies ++= Seq(
"org.scalactic" %% "scalactic" % "3.2.15" % "test",
"org.scalatest" %% "scalatest" % "3.2.15" % "test",
"org.rogach" %% "scallop" % "4.1.0",
"org.rogach" %% "scallop" % "5.0.0",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1",
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
Expand Down
13 changes: 13 additions & 0 deletions docs/reference/cli/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: CLI
listing:
- id: cli
contents: .
template: template.ejs
order: 10
---

These are the available commands available on the Command Line Interface:

:::{#cli}
:::
9 changes: 9 additions & 0 deletions docs/reference/cli/template.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```{=html}
<ul>
<% for (const item of items) { %>
<li>
<a href="<%- item.path %>"><%= item.title %></a>: <%= item.description %>
</li>
<% } %>
</ul>
```
49 changes: 49 additions & 0 deletions docs/reference/config_mods/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Dynamic Config Modding
order: 50
---

Viash can modify a [viash config](/reference/config/index.html) at runtime using a custom Domain Specific Language (DSL). This allows making dynamic changes to your components or projects.
All Viash subcommands have support for the DSL through the `-c|--config_mod` parameter. The format for these is as follows:

```bash
viash COMMAND -c '.SECTION.PROPERTY := VALUE'
```

Multiple config mods can be added by adding more `-c|--config_mod` parameters:

```bash
viash COMMAND \
-c '.SECTION.PROPERTY := VALUE' \
-c '.SECTION.PROPERTY := VALUE'
```

## Examples

Change the version of a component:

```bash
viash build -c '.functionality.version := "0.3.0"'
```

Change the registry of a docker container:

```bash
viash build -c \
'.platforms[.type == "docker"].container_registry := "url-to-registry"'
```

Add an author to the list:

```bash
viash build -c '.functionality.authors += { name: "Mr. T", role: "sponsor" }'
```

You can use dynamic config modding to alter the config of multiple components at once:

```bash
viash ns build \
-c '.functionality.version := "0.3.0"' \
-c '.platforms[.type == "docker"].container_registry := "url-to-registry"' \
-c '.functionality.authors += { name: "Mr. T", role: "sponsor" }'
```
107 changes: 107 additions & 0 deletions docs/reference/nextflow_vdsl3/import_module.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: Import a VDSL3 module
---

A VDSL3 module is a Nextflow module generated by Viash. See the [guide](/guide/nextflow_vdsl3/introduction.qmd) for a more in-depth explanation on how to create Nextflow workflows with VDSL3 modules.

## Importing a VDSL3 module


After building a VDSL3 module from a component, the VDSL3 module can be imported just like any other Nextflow module.

**Example:**

```groovy
include { mymodule } from 'target/nextflow/mymodule/main.nf'
```

## VDSL3 module interface

VDSL3 modules are actually workflows which take one channel and emit one channel. It expects the channel events to be tuples containing an 'id' and a 'state': `[id, state]`, where `id` is a unique String and `state` is a `Map[String, Object]`. The resulting channel then consists of tuples `[id, new_state]`.

**Example:**

```groovy
workflow {
Channel.fromList([
["myid", [input: file("in.txt")]]
])
| mymodule
}
```

:::{.callout-note}
If the input tuple has more than two elements, the elements after the second element are passed through to the output tuple.
That is, an input tuple `[id, input, ...]` will result in a tuple `[id, output, ...]` after running the module.
For example, an input tuple `["foo", [input: file("in.txt")], "bar"]` will result in an output tuple `["foo", [output: file("out.txt")], "bar"]`.
:::

## Customizing VDSL3 modules on the fly

Usually, Nextflow processes are quite static objects. For example, changing its directives can be quite tricky.

The `.run()` function is a unique feature for every VDSL3 module which allows dynamically altering the behaviour of a module from within the pipeline. For example, we use it to set the `publishDir` directive to `"output/"` so the output of that step in the pipeline will be stored as output.

**Example:**

```groovy
workflow {
Channel.fromList([
["myid", [input: file("in.txt")]]
])
| mymodule.run(
args: [k: 10],
directives: [cpus: 4, memory: "16 GB"]
)
}
```

### Arguments of `.run()`

- `key` (`String`): A unique key used to trace the process and help make names of output files unique. Default: the name of the Viash component.

- `args` (`Map[String, Object]`): Argument overrides to be passed to the module.

- `directives` (`Map[String, Object]`): Custom directives overrides. See the Nextflow documentation for a list of available directives.

- `auto` (`Map[String, Boolean]`): Whether to apply certain automated processing steps. Default values are inherited from the [Viash config](/reference/config/platforms/nextflow/auto.qmd).

- `auto.simplifyInput`: If `true`, if the input tuple is a single file and if the module only has a single input file, the input file will be passed the module accordingly. Default: `true` (inherited from Viash config).

- `auto.simplifyOutput`: If `true`, if the output tuple is a single file and if the module only has a single output file, the output map will be transformed into a single file. Default: `true` (inherited from Viash config).

- `auto.publish`: If `true`, the output files will be published to the `params.publishDir` folder. Default: `false` (inherited from Viash config).

- `auto.transcript`: If `true`, the module's transcript will be published to the `params.transcriptDir` folder. Default: `false` (inherited from Viash config).

- `map` (`Function`): Apply a map over the incoming tuple. Example: `{ tup -> [ tup[0], [input: tup[1].output] ] + tup.drop(2) }`. Default: `null`.

- `mapId` (`Function`): Apply a map over the ID element of a tuple (i.e. the first element). Example: `{ id -> id + "_foo" }`. Default: `null`.

- `mapData` (`Function`): Apply a map over the data element of a tuple (i.e. the second element). Example: `{ data -> [ input: data.output ] }`. Default: `null`.

- `mapPassthrough` (`Function`): Apply a map over the passthrough elements of a tuple (i.e. the tuple excl. the first two elements). Example: `{ pt -> pt.drop(1) }`. Default: `null`.

- `filter` (`Function`): Filter the channel. Example: `{ tup -> tup[0] == "foo" }`. Default: `null`.

- `fromState`: Fetch data from the state and pass it to the module without altering the current state. `fromState` should be `null`, `List[String]`, `Map[String, String]` or a function.

- If it is `null`, the state will be passed to the module as is.
- If it is a `List[String]`, the data will be the values of the state at the given keys.
- If it is a `Map[String, String]`, the data will be the values of the state at the given keys, with the keys renamed according to the map.
- If it is a function, the tuple (`[id, state]`) in the channel will be passed to the function, and the result will be used as the data.

Example: `{ id, state -> [input: state.fastq_file] }`
Default: `null`

- `toState`: Determine how the state should be updated after the module has been run. `toState` should be `null`, `List[String]`, `Map[String, String]` or a function.

- If it is `null`, the state will be replaced with the output of the module.
- If it is a `List[String]`, the state will be updated with the values of the data at the given keys.
- If it is a `Map[String, String]`, the state will be updated with the values of the data at the given keys, with the keys renamed according to the map.
- If it is a function, a tuple (`[id, output, state]`) will be passed to the function, and the result will be used as the new state.

Example: `{ id, output, state -> state + [counts: state.output] }`
Default: `{ id, output, state -> output }`

- `debug`: Whether or not to print debug messages. Default: `false`.
10 changes: 10 additions & 0 deletions docs/reference/nextflow_vdsl3/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Nextflow VDSL3
order: 35
---

Viash supports creating Nextflow workflows in multiple ways.

* [Run a module as a standaline pipeline](run_module.qmd)
* [Import a VDSL3 module](import_module.qmd)
* Create a Nextflow workflow with dependencies
Loading

0 comments on commit 5c4e867

Please sign in to comment.