Skip to content

Commit

Permalink
turn __inherits__ into an experimental feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Nov 9, 2022
1 parent b620666 commit 1d724d0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 29 deletions.
69 changes: 43 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,5 @@
# Viash 0.6.3

## NEW FUNCTIONALITY

* `Config`: Any part of a Viash config can use inheritance to fill data (#259). For example:
Contents of `src/test/config.vsh.yaml`:
```yaml
__inherits__: ../api/comp_processor.yaml
functionality:
name: test
resources:
- type: bash_script
path: script.sh
text: |
echo Copying $par_input to $par_output
cp $par_input $par_output
```
Contents of `src/api/comp_processor.yaml`:
```yaml
functionality:
arguments:
- name: "--input"
type: file
- name: "--output"
type: file
direction: output
```

## MAJOR CHANGES

* `Config`: Made major internal changes w.r.t. how config files are read and at which point a platform (native, docker, nextflow)
Expand Down Expand Up @@ -84,6 +58,49 @@

* `DockerRequirements`: The `privileged:` setting has been deprecated and will be removed in Viash 0.7.0. Please use `run_args: "--privileged"` instead.

## EXPERIMENTAL FUNCTIONALITY

* `Config`: Any part of a Viash config can use inheritance to fill data (#259). For example:
Contents of `src/test/config.vsh.yaml`:
```yaml
__inherits__: ../api/base.yaml
functionality:
name: test
resources:
- type: bash_script
path: script.sh
text: |
echo Copying $par_input to $par_output
cp $par_input $par_output
```
Contents of `src/api/base.yaml`:
```yaml
functionality:
arguments:
- name: "--input"
type: file
- name: "--output"
type: file
direction: output
```
The resulting yaml will be:
```yaml
functionality:
name: test
arguments:
- name: "--input"
type: file
- name: "--output"
type: file
direction: output
resources:
- type: bash_script
path: script.sh
text: |
echo Copying $par_input to $par_output
cp $par_input $par_output
```

# Viash 0.6.2

## BUG FIXES
Expand Down
12 changes: 9 additions & 3 deletions src/main/scala/io/viash/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ case class Config(
@internalFunctionality
info: Option[Info] = None
) {

@description(
"""Argument for inheriting YAML partials. This is useful for defining common APIs in
"""Config inheritance by including YAML partials. This is useful for defining common APIs in
|separate files. `__inherits__` can be used in any level of the YAML. For example,
|not just in the config but also in the functionality or any of the platforms.
|
|WARNING: this argument is an EXPERIMENTAL feature. Changes to the API are expected.
|""".stripMargin)
@example("__inherits__: ../api/common_interface.yaml", "yaml")
@since("Viash 0.6.2")
@since("Viash 0.6.3")
@undocumented
val `__inherits__`: Option[File] = None

Expand Down Expand Up @@ -138,6 +140,10 @@ object Config {
// apply inheritance if need be
val js2 = js1.inherit(uri)

if (js1 != js2) {
Console.err.println("Warning: Config inheritance (__inherits__) is an experimental feature. Changes to the API are expected.")
}

// apply preparse config mods
val js3 = preparseMods match {
case None => js2
Expand Down

0 comments on commit 1d724d0

Please sign in to comment.