Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arguments for filtering methods in benchmark workflow #4

Merged
merged 6 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common
19 changes: 16 additions & 3 deletions src/workflows/run_benchmark/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,32 @@ argument_groups:
required: true
direction: output
default: task_info.yaml
- name: Methods
- name: Method filtering
description: |
Use these arguments to filter methods by name. By default, all methods are
run. If `--methods_include` is defined, only those methods are run. If
`--methods_exclude` is defined, all methods except those specified are run.
These arguments are mutually exclusive, so only `--methods_include` OR
`--methods_exclude` can set but not both.
arguments:
- name: "--method_ids"
- name: "--methods_include"
type: string
multiple: true
description: A list of method ids to run. If not specified, all methods will be run.
description: |
A list of method ids to include. If specified, only these methods will be run.
- name: "--methods_exclude"
type: string
multiple: true
description: |
A list of method ids to exclude. If specified, all methods except the ones listed will be run.

resources:
- type: nextflow_script
path: main.nf
entrypoint: run_wf
- type: file
path: /_viash.yaml
- path: /common/nextflow_helpers/helper.nf

dependencies:
- name: h5ad/extract_uns_metadata
Expand Down
15 changes: 12 additions & 3 deletions src/workflows/run_benchmark/main.nf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include { checkItemAllowed } from "${meta.resources_dir}/helper.nf"

workflow auto {
findStates(params, meta.config)
| meta.workflow.run(
Expand Down Expand Up @@ -55,7 +57,7 @@ workflow run_wf {
****************************/
dataset_ch = input_ch
// store join id
| map{ id, state ->
| map{ id, state ->
[id, state + ["_meta": [join_id: id]]]
}

Expand All @@ -72,6 +74,7 @@ workflow run_wf {
/***************************
* RUN METHODS AND METRICS *
***************************/

score_ch = dataset_ch

// run all methods
Expand All @@ -85,7 +88,13 @@ workflow run_wf {
// if the preferred normalisation is none at all,
// we can pass whichever dataset we want
def norm_check = (norm == "log_cp10k" && pref == "counts") || norm == pref
def method_check = !state.method_ids || state.method_ids.contains(comp.config.name)
def method_check = checkItemAllowed(
comp.config.name,
state.methods_include,
state.methods_exclude,
"methods_include",
"methods_exclude"
)

method_check && norm_check
},
Expand Down Expand Up @@ -153,7 +162,7 @@ workflow run_wf {
},
// use 'fromState' to fetch the arguments the component requires from the overall state
fromState: [
input_solution: "input_solution",
input_solution: "input_solution",
input_integrated: "method_output_cleaned"
],
// use 'toState' to publish that component's outputs to the overall state
Expand Down