From bb539fded5200b031e9216ccd0364cbc0c773e01 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Mon, 28 Oct 2024 12:18:36 +0100 Subject: [PATCH 01/11] Port check_torch_model to nf-core modules --- .../stimulus/checktorchmodel/environment.yml | 17 ++++ .../nf-core/stimulus/checktorchmodel/main.nf | 51 ++++++++++++ .../nf-core/stimulus/checktorchmodel/meta.yml | 80 +++++++++++++++++++ .../checktorchmodel/tests/main.nf.test | 68 ++++++++++++++++ 4 files changed, 216 insertions(+) create mode 100644 modules/nf-core/stimulus/checktorchmodel/environment.yml create mode 100644 modules/nf-core/stimulus/checktorchmodel/main.nf create mode 100644 modules/nf-core/stimulus/checktorchmodel/meta.yml create mode 100644 modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test diff --git a/modules/nf-core/stimulus/checktorchmodel/environment.yml b/modules/nf-core/stimulus/checktorchmodel/environment.yml new file mode 100644 index 00000000000..0f2a3a84635 --- /dev/null +++ b/modules/nf-core/stimulus/checktorchmodel/environment.yml @@ -0,0 +1,17 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - pytorch + - conda-forge + - bioconda +dependencies: + - python=3.12 + - pytorch + - matplotlib + - pandas + - polars + - ray + - safetensors + - scikit-learn + - pip: + - stimulus-py diff --git a/modules/nf-core/stimulus/checktorchmodel/main.nf b/modules/nf-core/stimulus/checktorchmodel/main.nf new file mode 100644 index 00000000000..42b910a3cef --- /dev/null +++ b/modules/nf-core/stimulus/checktorchmodel/main.nf @@ -0,0 +1,51 @@ +process STIMULUS_CHECKTORCHMODEL { + tag "$experiment_config - $original_csv" + label 'process_medium' + + // TODO freeze to Wave + container "docker.io/mathysgrapotte/stimulus-py:latest" + + input: + tuple val(meta), path(original_csv), path(experiment_config) + tuple val(meta2), path(model), path(ray_tune_config), path(initial_weights) + + output: + tuple val(meta2), path("${meta.id}_${meta2.id}_modelcheck.log"), emit: log + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + """ + stimulus-check-model \ + -d ${original_csv} \ + -m ${model} \ + -e ${experiment_config} \ + -c ${ray_tune_config} \ + --initial_weights ${initial_weights} \ + --gpus ${task.accelerator.request} \ + --cpus ${task.cpus} \ + --memory "${task.memory}" \ + $args > ${meta.id}_${meta2.id}_modelcheck.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + Python: \$(python --version | cut -d ' ' -f 2) + Stimulus-py: \$(pip show stimulus-py | grep Version | cut -d ' ' -f 2) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + """ + touch ${meta.id}_${meta2.id}_modelcheck.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + Python: \$(python --version | cut -d ' ' -f 2) + Stimulus-py: \$(pip show stimulus-py | grep Version | cut -d ' ' -f 2) + END_VERSIONS + """ +} diff --git a/modules/nf-core/stimulus/checktorchmodel/meta.yml b/modules/nf-core/stimulus/checktorchmodel/meta.yml new file mode 100644 index 00000000000..6674b258201 --- /dev/null +++ b/modules/nf-core/stimulus/checktorchmodel/meta.yml @@ -0,0 +1,80 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "stimulus_checktorchmodel" +## TODO nf-core: Add a description of the module and list keywords +description: Sanity check a Pytorch model using raytune +keywords: + - machine learning + - neural network + - unit test +tools: + - "stimulus": + ## TODO nf-core: Add a description and other details for the software below + description: "Stochastic Testing and Input Manipulation for Unbiased Learning Systems" + homepage: "https://github.com/mathysgrapotte/stimulus-py" + documentation: "" + tool_dev_url: "https://github.com/mathysgrapotte/stimulus-py" + doi: "" + licence: "MIT" + identifier: + +input: + - - meta: + type: map + description: | + Groovy Map containing data information + e.g. [ id:'test' ] + - original_csv: + type: file + description: A CSV file with untransformed data + pattern: "*.csv" + ontologies: + - edam: "http://edamontology.org/format_3752" + - experiment_config: + type: file + # nb will be YAML later + description: A JSON file describing data transformations + pattern: "*.json" + ontologies: + - edam: "http://edamontology.org/format_3464" + - - meta2: + type: map + description: | + Groovy Map containing model information + e.g. [ id:'test' ] + - model: + type: file + description: Python source file containing the model + pattern: "*.py" + ontologies: + - edam: "http://edamontology.org/format_3996" + - ray_tune_config: + type: file + description: YAML file containing RayTune tuning parameters + pattern: "*.{yaml,yml}" + ontologies: + - edam: "http://edamontology.org/format_3750" + - initial_weights: + type: file + description: An optional SafeTensors file containing initial weights + pattern: "*.safetensors" + + +output: + - log: + - "*_modelcheck.log": + type: file + description: Model check output + pattern: "*.log" + - versions: + - "versions.yml": + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@mathysgrapotte" + - "@alessiovignoli" + - "@itrujnara" +maintainers: + - "@itrujnara" diff --git a/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test new file mode 100644 index 00000000000..6f8a0f8ba59 --- /dev/null +++ b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test @@ -0,0 +1,68 @@ +// TODO nf-core: Once you have added the required tests, please run the following command to build this file: +// nf-core modules test stimulus/checktorchmodel +nextflow_process { + + name "Test Process STIMULUS_CHECKTORCHMODEL" + script "../main.nf" + process "STIMULUS_CHECKTORCHMODEL" + + tag "modules" + tag "modules_nfcore" + tag "stimulus" + tag "stimulus/checktorchmodel" + + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used + test("sarscov2 - bam") { + + // TODO nf-core: If you are created a test for a chained module + // (the module requires running more than one process to generate the required output) + // add the 'setup' method here. + // You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules). + + when { + process { + """ + // TODO nf-core: define inputs of the process here. Example: + + input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + //TODO nf-core: Add all required assertions to verify the test output. + // See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples. + ) + } + + } + + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix. + test("sarscov2 - bam - stub") { + + options "-stub" + + when { + process { + """ + // TODO nf-core: define inputs of the process here. Example: + + input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + //TODO nf-core: Add all required assertions to verify the test output. + ) + } + + } + +} From 7bf66da7df6e950e30983e4fc74bd9100bb514b2 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Mon, 28 Oct 2024 16:39:27 +0100 Subject: [PATCH 02/11] Fix stimulus/checktorchmodel structure and add nf-test --- .../stimulus/checktorchmodel/environment.yml | 1 + .../nf-core/stimulus/checktorchmodel/main.nf | 19 +++-- .../nf-core/stimulus/checktorchmodel/meta.yml | 71 ++++++++----------- .../checktorchmodel/tests/main.nf.test | 33 +++++---- 4 files changed, 58 insertions(+), 66 deletions(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/environment.yml b/modules/nf-core/stimulus/checktorchmodel/environment.yml index 0f2a3a84635..b0d164429cc 100644 --- a/modules/nf-core/stimulus/checktorchmodel/environment.yml +++ b/modules/nf-core/stimulus/checktorchmodel/environment.yml @@ -13,5 +13,6 @@ dependencies: - ray - safetensors - scikit-learn + # NOTE https://github.com/nf-core/modules/issues/5814 - pip: - stimulus-py diff --git a/modules/nf-core/stimulus/checktorchmodel/main.nf b/modules/nf-core/stimulus/checktorchmodel/main.nf index 42b910a3cef..5fd491a3a0f 100644 --- a/modules/nf-core/stimulus/checktorchmodel/main.nf +++ b/modules/nf-core/stimulus/checktorchmodel/main.nf @@ -6,18 +6,22 @@ process STIMULUS_CHECKTORCHMODEL { container "docker.io/mathysgrapotte/stimulus-py:latest" input: - tuple val(meta), path(original_csv), path(experiment_config) - tuple val(meta2), path(model), path(ray_tune_config), path(initial_weights) + path(original_csv) + path(experiment_config) + path(model) + path(ray_tune_config) + path(initial_weights) output: - tuple val(meta2), path("${meta.id}_${meta2.id}_modelcheck.log"), emit: log - path "versions.yml" , emit: versions + tuple val(meta), path("*_modelcheck.log"), emit: log + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when script: def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: model.replaceFirst(/\.py/, "") """ stimulus-check-model \ -d ${original_csv} \ @@ -28,7 +32,7 @@ process STIMULUS_CHECKTORCHMODEL { --gpus ${task.accelerator.request} \ --cpus ${task.cpus} \ --memory "${task.memory}" \ - $args > ${meta.id}_${meta2.id}_modelcheck.log + $args > ${prefix}_modelcheck.log cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -39,13 +43,14 @@ process STIMULUS_CHECKTORCHMODEL { stub: def args = task.ext.args ?: '' + def STIMULUS_VER = '0.0.9' // container not used in stub, change manually """ - touch ${meta.id}_${meta2.id}_modelcheck.log + touch ${meta.id}_modelcheck.log cat <<-END_VERSIONS > versions.yml "${task.process}": Python: \$(python --version | cut -d ' ' -f 2) - Stimulus-py: \$(pip show stimulus-py | grep Version | cut -d ' ' -f 2) + Stimulus-py: ${STIMULUS_VER} END_VERSIONS """ } diff --git a/modules/nf-core/stimulus/checktorchmodel/meta.yml b/modules/nf-core/stimulus/checktorchmodel/meta.yml index 6674b258201..9aa5448ef6b 100644 --- a/modules/nf-core/stimulus/checktorchmodel/meta.yml +++ b/modules/nf-core/stimulus/checktorchmodel/meta.yml @@ -1,7 +1,6 @@ --- # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json name: "stimulus_checktorchmodel" -## TODO nf-core: Add a description of the module and list keywords description: Sanity check a Pytorch model using raytune keywords: - machine learning @@ -9,55 +8,43 @@ keywords: - unit test tools: - "stimulus": - ## TODO nf-core: Add a description and other details for the software below description: "Stochastic Testing and Input Manipulation for Unbiased Learning Systems" homepage: "https://github.com/mathysgrapotte/stimulus-py" documentation: "" tool_dev_url: "https://github.com/mathysgrapotte/stimulus-py" doi: "" - licence: "MIT" + licence: ["MIT"] identifier: input: - - - meta: - type: map - description: | - Groovy Map containing data information - e.g. [ id:'test' ] - - original_csv: - type: file - description: A CSV file with untransformed data - pattern: "*.csv" - ontologies: - - edam: "http://edamontology.org/format_3752" - - experiment_config: - type: file - # nb will be YAML later - description: A JSON file describing data transformations - pattern: "*.json" - ontologies: - - edam: "http://edamontology.org/format_3464" - - - meta2: - type: map - description: | - Groovy Map containing model information - e.g. [ id:'test' ] - - model: - type: file - description: Python source file containing the model - pattern: "*.py" - ontologies: - - edam: "http://edamontology.org/format_3996" - - ray_tune_config: - type: file - description: YAML file containing RayTune tuning parameters - pattern: "*.{yaml,yml}" - ontologies: - - edam: "http://edamontology.org/format_3750" - - initial_weights: - type: file - description: An optional SafeTensors file containing initial weights - pattern: "*.safetensors" + - original_csv: + type: file + description: A CSV file with untransformed data + pattern: "*.csv" + ontologies: + - edam: "http://edamontology.org/format_3752" + - experiment_config: + type: file + description: A YAML file describing data transformations + pattern: "*.{yml,yaml}" + ontologies: + - edam: "http://edamontology.org/format_3464" + - model: + type: file + description: Python source file containing the model + pattern: "*.py" + ontologies: + - edam: "http://edamontology.org/format_3996" + - ray_tune_config: + type: file + description: YAML file containing RayTune tuning parameters + pattern: "*.{yml,yaml}" + ontologies: + - edam: "http://edamontology.org/format_3750" + - initial_weights: + type: file + description: An optional SafeTensors file containing initial weights + pattern: "*.safetensors" output: diff --git a/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test index 6f8a0f8ba59..3024239bad2 100644 --- a/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test +++ b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test @@ -12,19 +12,16 @@ nextflow_process { tag "stimulus/checktorchmodel" // TODO nf-core: Change the test name preferably indicating the test-data and file-format used - test("sarscov2 - bam") { - - // TODO nf-core: If you are created a test for a chained module - // (the module requires running more than one process to generate the required output) - // add the 'setup' method here. - // You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules). + test("basic - csv - py") { when { process { """ - // TODO nf-core: define inputs of the process here. Example: - - input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + input[0] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/input_data_with_split.csv', checkIfExists: true), + input[1] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/experiment_config.yaml', checkIfExists: true), + input[2] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/dna_to_float_model.py', checkIfExists: true), + input[3] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/tune_config.yaml', checkIfExists: true), + input[4] = [] """ } } @@ -32,25 +29,28 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } - //TODO nf-core: Add all required assertions to verify the test output. - // See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples. + { with(process.out.log) { + assert path(get(1)).readLines().first().contains("Trial finishes successfully") + } }, + { assert snapshot(process.out.versions).match() } ) } } // TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix. - test("sarscov2 - bam - stub") { + test("basic - csv - stub") { options "-stub" when { process { """ - // TODO nf-core: define inputs of the process here. Example: - - input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + input[0] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/input_data_with_split.csv', checkIfExists: true), + input[1] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/experiment_config.yaml', checkIfExists: true), + input[2] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/dna_to_float_model.py', checkIfExists: true), + input[3] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/tune_config.yaml', checkIfExists: true), + input[4] = [] """ } } @@ -59,7 +59,6 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot(process.out).match() } - //TODO nf-core: Add all required assertions to verify the test output. ) } From ad6ffdb660a3144adaf16af3760991b354c72ee6 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 29 Oct 2024 11:56:46 +0100 Subject: [PATCH 03/11] Remove pytorch channel --- modules/nf-core/stimulus/checktorchmodel/environment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/environment.yml b/modules/nf-core/stimulus/checktorchmodel/environment.yml index b0d164429cc..e13b3034b9d 100644 --- a/modules/nf-core/stimulus/checktorchmodel/environment.yml +++ b/modules/nf-core/stimulus/checktorchmodel/environment.yml @@ -1,7 +1,6 @@ --- # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json channels: - - pytorch - conda-forge - bioconda dependencies: From 9dc3eb284d1a1c080f5fcfcb4846e866cae97521 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 29 Oct 2024 11:57:12 +0100 Subject: [PATCH 04/11] Fix initial weights parameter in stimulus/checktorchmodel --- modules/nf-core/stimulus/checktorchmodel/main.nf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/main.nf b/modules/nf-core/stimulus/checktorchmodel/main.nf index 5fd491a3a0f..f9b1a3fd82d 100644 --- a/modules/nf-core/stimulus/checktorchmodel/main.nf +++ b/modules/nf-core/stimulus/checktorchmodel/main.nf @@ -22,13 +22,14 @@ process STIMULUS_CHECKTORCHMODEL { script: def args = task.ext.args ?: '' prefix = task.ext.prefix ?: model.replaceFirst(/\.py/, "") + def weights_arg = initial_weights ? "--initial_weights ${initial_weights}" : "" """ stimulus-check-model \ -d ${original_csv} \ -m ${model} \ -e ${experiment_config} \ -c ${ray_tune_config} \ - --initial_weights ${initial_weights} \ + ${weights_arg} \ --gpus ${task.accelerator.request} \ --cpus ${task.cpus} \ --memory "${task.memory}" \ From 5ddf81bafe2fc51823047111348d75c17c5577d8 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 29 Oct 2024 16:56:58 +0100 Subject: [PATCH 05/11] Fix stimulus/checktorchmodel tests --- .../stimulus/checktorchmodel/tests/main.nf.test | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test index 3024239bad2..234676d0e33 100644 --- a/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test +++ b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test @@ -17,10 +17,10 @@ nextflow_process { when { process { """ - input[0] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/input_data_with_split.csv', checkIfExists: true), - input[1] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/experiment_config.yaml', checkIfExists: true), - input[2] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/dna_to_float_model.py', checkIfExists: true), - input[3] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/tune_config.yaml', checkIfExists: true), + input[0] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/input_data_with_split.csv', checkIfExists: true) + input[1] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/experiment_config.yaml', checkIfExists: true) + input[2] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/dna_to_float_model.py', checkIfExists: true) + input[3] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/tune_config.yaml', checkIfExists: true) input[4] = [] """ } @@ -46,10 +46,10 @@ nextflow_process { when { process { """ - input[0] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/input_data_with_split.csv', checkIfExists: true), - input[1] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/experiment_config.yaml', checkIfExists: true), - input[2] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/dna_to_float_model.py', checkIfExists: true), - input[3] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/tune_config.yaml', checkIfExists: true), + input[0] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/input_data_with_split.csv', checkIfExists: true) + input[1] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/experiment_config.yaml', checkIfExists: true) + input[2] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/dna_to_float_model.py', checkIfExists: true) + input[3] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/dna_experiment/tune_config.yaml', checkIfExists: true) input[4] = [] """ } From 8eeb349a1ad02cf82986aecbced9266415ed62b5 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 29 Oct 2024 16:57:22 +0100 Subject: [PATCH 06/11] stimulus/checktorchmodel add versions to dependencies --- .../stimulus/checktorchmodel/environment.yml | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/environment.yml b/modules/nf-core/stimulus/checktorchmodel/environment.yml index e13b3034b9d..fbf5fe9b102 100644 --- a/modules/nf-core/stimulus/checktorchmodel/environment.yml +++ b/modules/nf-core/stimulus/checktorchmodel/environment.yml @@ -1,17 +1,13 @@ ---- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json channels: - conda-forge - bioconda + dependencies: - - python=3.12 - - pytorch - - matplotlib - - pandas - - polars - - ray - - safetensors - - scikit-learn - # NOTE https://github.com/nf-core/modules/issues/5814 - - pip: - - stimulus-py + - conda-forge::matplotlib=3.9.2 + - conda-forge::pandas=2.2.3 + - conda-forge::polars=1.9.0 + - conda-forge::python=3.12 + - conda-forge::pytorch=2.4.1 + - conda-forge::ray-core=2.37.0 + - conda-forge::safetensors=0.4.5 + - conda-forge::scikit-learn=1.5.2 From fbb4798032f45d602f37e9c6dd3283e95d535ea7 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 29 Oct 2024 16:57:39 +0100 Subject: [PATCH 07/11] stimulus/checktorchmodel fix typos in main --- modules/nf-core/stimulus/checktorchmodel/main.nf | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/main.nf b/modules/nf-core/stimulus/checktorchmodel/main.nf index f9b1a3fd82d..6a396377519 100644 --- a/modules/nf-core/stimulus/checktorchmodel/main.nf +++ b/modules/nf-core/stimulus/checktorchmodel/main.nf @@ -13,16 +13,17 @@ process STIMULUS_CHECKTORCHMODEL { path(initial_weights) output: - tuple val(meta), path("*_modelcheck.log"), emit: log - path "versions.yml" , emit: versions + path "*_modelcheck.log", emit: log + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when script: - def args = task.ext.args ?: '' - prefix = task.ext.prefix ?: model.replaceFirst(/\.py/, "") + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: model.baseName.replaceFirst(/\.py/, "") def weights_arg = initial_weights ? "--initial_weights ${initial_weights}" : "" + def gpu_arg = task.accelerator ? "--gpus ${task.accelerator.request}" : "" """ stimulus-check-model \ -d ${original_csv} \ @@ -30,7 +31,7 @@ process STIMULUS_CHECKTORCHMODEL { -e ${experiment_config} \ -c ${ray_tune_config} \ ${weights_arg} \ - --gpus ${task.accelerator.request} \ + ${gpu_arg} \ --cpus ${task.cpus} \ --memory "${task.memory}" \ $args > ${prefix}_modelcheck.log @@ -43,10 +44,11 @@ process STIMULUS_CHECKTORCHMODEL { """ stub: - def args = task.ext.args ?: '' + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: model.baseName.replaceFirst(/\.py/, "") def STIMULUS_VER = '0.0.9' // container not used in stub, change manually """ - touch ${meta.id}_modelcheck.log + touch ${prefix}_modelcheck.log cat <<-END_VERSIONS > versions.yml "${task.process}": From c24b4edffa8d2907b2b16523b1e311051aa68ff8 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 29 Oct 2024 16:57:59 +0100 Subject: [PATCH 08/11] stimulus/checktorchmodel fix typos in meta --- .../nf-core/stimulus/checktorchmodel/meta.yml | 60 +++++++++---------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/meta.yml b/modules/nf-core/stimulus/checktorchmodel/meta.yml index 9aa5448ef6b..e345c6a8adc 100644 --- a/modules/nf-core/stimulus/checktorchmodel/meta.yml +++ b/modules/nf-core/stimulus/checktorchmodel/meta.yml @@ -10,41 +10,39 @@ tools: - "stimulus": description: "Stochastic Testing and Input Manipulation for Unbiased Learning Systems" homepage: "https://github.com/mathysgrapotte/stimulus-py" - documentation: "" + documentation: "https://github.com/mathysgrapotte/stimulus-py" tool_dev_url: "https://github.com/mathysgrapotte/stimulus-py" - doi: "" licence: ["MIT"] - identifier: input: - - original_csv: - type: file - description: A CSV file with untransformed data - pattern: "*.csv" - ontologies: - - edam: "http://edamontology.org/format_3752" - - experiment_config: - type: file - description: A YAML file describing data transformations - pattern: "*.{yml,yaml}" - ontologies: - - edam: "http://edamontology.org/format_3464" - - model: - type: file - description: Python source file containing the model - pattern: "*.py" - ontologies: - - edam: "http://edamontology.org/format_3996" - - ray_tune_config: - type: file - description: YAML file containing RayTune tuning parameters - pattern: "*.{yml,yaml}" - ontologies: - - edam: "http://edamontology.org/format_3750" - - initial_weights: - type: file - description: An optional SafeTensors file containing initial weights - pattern: "*.safetensors" + - - original_csv: + type: file + description: A CSV file with untransformed data + pattern: "*.csv" + ontologies: + - edam: "http://edamontology.org/format_3752" + - - experiment_config: + type: file + description: A YAML file describing data transformations + pattern: "*.{yml,yaml}" + ontologies: + - edam: "http://edamontology.org/format_3464" + - - model: + type: file + description: Python source file containing the model + pattern: "*.py" + ontologies: + - edam: "http://edamontology.org/format_3996" + - - ray_tune_config: + type: file + description: YAML file containing RayTune tuning parameters + pattern: "*.{yml,yaml}" + ontologies: + - edam: "http://edamontology.org/format_3750" + - - initial_weights: + type: file + description: An optional SafeTensors file containing initial weights + pattern: "*.safetensors" output: From 978eae76403b0c737e6f9d49989e9262e3c1aef2 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 29 Oct 2024 16:58:12 +0100 Subject: [PATCH 09/11] stimulus/checktorchmodel run test --- .../checktorchmodel/tests/main.nf.test.snap | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test.snap diff --git a/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test.snap b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test.snap new file mode 100644 index 00000000000..9e94a8e67c4 --- /dev/null +++ b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test.snap @@ -0,0 +1,37 @@ +{ + "basic - csv - py": { + "content": [ + [ + + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.0" + }, + "timestamp": "2024-10-29T15:30:33.424103" + }, + "basic - csv - stub": { + "content": [ + { + "0": [ + "dna_to_float_model_modelcheck.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ], + "1": [ + "versions.yml:md5,673aceb3844572cdb756ae9835f9187e" + ], + "log": [ + "dna_to_float_model_modelcheck.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ], + "versions": [ + "versions.yml:md5,673aceb3844572cdb756ae9835f9187e" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.0" + }, + "timestamp": "2024-10-29T16:54:27.22745" + } +} \ No newline at end of file From 1c09b33ac51b8143b7c67c81182de6978201d4f9 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 29 Oct 2024 17:05:54 +0100 Subject: [PATCH 10/11] Make prettier happy --- .../nf-core/stimulus/checktorchmodel/meta.yml | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/meta.yml b/modules/nf-core/stimulus/checktorchmodel/meta.yml index e345c6a8adc..c9a1274fbd5 100644 --- a/modules/nf-core/stimulus/checktorchmodel/meta.yml +++ b/modules/nf-core/stimulus/checktorchmodel/meta.yml @@ -15,47 +15,46 @@ tools: licence: ["MIT"] input: - - - original_csv: - type: file - description: A CSV file with untransformed data - pattern: "*.csv" - ontologies: - - edam: "http://edamontology.org/format_3752" - - - experiment_config: - type: file - description: A YAML file describing data transformations - pattern: "*.{yml,yaml}" - ontologies: - - edam: "http://edamontology.org/format_3464" - - - model: - type: file - description: Python source file containing the model - pattern: "*.py" - ontologies: - - edam: "http://edamontology.org/format_3996" - - - ray_tune_config: - type: file - description: YAML file containing RayTune tuning parameters - pattern: "*.{yml,yaml}" - ontologies: - - edam: "http://edamontology.org/format_3750" - - - initial_weights: - type: file - description: An optional SafeTensors file containing initial weights - pattern: "*.safetensors" - + - - original_csv: + type: file + description: A CSV file with untransformed data + pattern: "*.csv" + ontologies: + - edam: "http://edamontology.org/format_3752" + - - experiment_config: + type: file + description: A YAML file describing data transformations + pattern: "*.{yml,yaml}" + ontologies: + - edam: "http://edamontology.org/format_3464" + - - model: + type: file + description: Python source file containing the model + pattern: "*.py" + ontologies: + - edam: "http://edamontology.org/format_3996" + - - ray_tune_config: + type: file + description: YAML file containing RayTune tuning parameters + pattern: "*.{yml,yaml}" + ontologies: + - edam: "http://edamontology.org/format_3750" + - - initial_weights: + type: file + description: An optional SafeTensors file containing initial weights + pattern: "*.safetensors" output: - log: - - "*_modelcheck.log": - type: file - description: Model check output - pattern: "*.log" + - "*_modelcheck.log": + type: file + description: Model check output + pattern: "*.log" - versions: - - "versions.yml": - type: file - description: File containing software versions - pattern: "versions.yml" + - "versions.yml": + type: file + description: File containing software versions + pattern: "versions.yml" authors: - "@mathysgrapotte" From aac0a383179073cb36ed12ef50f6b5dfc4187ef8 Mon Sep 17 00:00:00 2001 From: Igor Trujnara <53370556+itrujnara@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:56:14 +0100 Subject: [PATCH 11/11] Update modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test Co-authored-by: alessiovignoli <45239231+alessiovignoli@users.noreply.github.com> --- modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test index 234676d0e33..626232d8233 100644 --- a/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test +++ b/modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test @@ -1,4 +1,3 @@ -// TODO nf-core: Once you have added the required tests, please run the following command to build this file: // nf-core modules test stimulus/checktorchmodel nextflow_process {