Skip to content

Commit

Permalink
Remove map, mapId, mapData, mapPassthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
DriesSchaumont committed Dec 26, 2024
1 parent 7ebb587 commit 603c756
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 380 deletions.
8 changes: 0 additions & 8 deletions docs/reference/nextflow_vdsl3/import_module.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ workflow {

- `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.
Expand Down
219 changes: 0 additions & 219 deletions src/main/resources/io/viash/runners/nextflow/DataflowHelper.nf

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def processWorkflowArgs(Map args, Map defaultWfArgs, Map meta) {
assert key ==~ /^[a-zA-Z_]\w*$/ : "Error in module '$key': Expected process argument 'key' to consist of only letters, digits or underscores. Found: ${key}"

// check for any unexpected keys
def expectedKeys = ["key", "directives", "auto", "map", "mapId", "mapData", "mapPassthrough", "filter", "runIf", "fromState", "toState", "args", "renameKeys", "debug"]
def expectedKeys = ["key", "directives", "auto" "filter", "runIf", "fromState", "toState", "args", "renameKeys", "debug"]
def unexpectedKeys = workflowArgs.keySet() - expectedKeys
assert unexpectedKeys.isEmpty() : "Error in module '$key': unexpected arguments to the '.run()' function: '${unexpectedKeys.join("', '")}'"

Expand Down Expand Up @@ -74,19 +74,12 @@ def processWorkflowArgs(Map args, Map defaultWfArgs, Map meta) {
workflowArgs.directives.keySet().removeAll(["publishDir", "cpus", "memory", "label"])
}

for (nam in ["map", "mapId", "mapData", "mapPassthrough", "filter", "runIf"]) {
for (nam in ["filter", "runIf"]) {
if (workflowArgs.containsKey(nam) && workflowArgs[nam]) {
assert workflowArgs[nam] instanceof Closure : "Error in module '$key': Expected process argument '$nam' to be null or a Closure. Found: class ${workflowArgs[nam].getClass()}"
}
}

// TODO: should functions like 'map', 'mapId', 'mapData', 'mapPassthrough' be deprecated as well?
for (nam in ["map", "mapData", "mapPassthrough", "renameKeys"]) {
if (workflowArgs.containsKey(nam) && workflowArgs[nam] != null) {
log.warn "module '$key': workflow argument '$nam' is deprecated and will be removed in Viash 0.9.0. Please use 'fromState' and 'toState' instead."
}
}

// check fromState
workflowArgs["fromState"] = _processFromState(workflowArgs.get("fromState"), key, meta.config)

Expand Down
16 changes: 0 additions & 16 deletions src/main/scala/io/viash/runners/nextflow/NextflowHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,6 @@ object NextflowHelper {
| // auto settings
| auto: readJsonBlob('''${jsonPrinter.print(autoJson)}'''),
|
| // Apply a map over the incoming tuple
| // Example: `{ tup -> [ tup[0], [input: tup[1].output] ] + tup.drop(2) }`
| map: null,
|
| // Apply a map over the ID element of a tuple (i.e. the first element)
| // Example: `{ id -> id + "_foo" }`
| mapId: null,
|
| // Apply a map over the data element of a tuple (i.e. the second element)
| // Example: `{ data -> [ input: data.output ] }`
| mapData: null,
|
| // Apply a map over the passthrough elements of a tuple (i.e. the tuple excl. the first two elements)
| // Example: `{ pt -> pt.drop(1) }`
| mapPassthrough: null,
|
| // Filter the channel
| // Example: `{ tup -> tup[0] == "foo" }`
| filter: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ workflow base {

| step1.run(
key: "step1bis",
// TODO: renameKeys, map, mapId, mapData will be deprecated
// TODO: test filter, runIf
map: { id, state ->
def new_state = state + [
Expand All @@ -50,18 +49,18 @@ workflow base {
]
[id, new_state]
},
mapId: { id ->
"${id}_modified"
},
mapData: { state ->
state + [another_key: "bar"]
},
renameKeys: ["original_id": "oid"],
fromState: { id, state ->
["input": state.file]
},
toState: { id, output, state ->
state + ["step1bis_output": output.output]
def original_id = state.original_id
def new_state = state.findAll{k, v -> k != "original_id"}

["${id}_modified", state +
["step1bis_output": output.output] +
["another_key": "bar"] +
["oid": original_id]
]
}
)

Expand Down
Loading

0 comments on commit 603c756

Please sign in to comment.