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 STIMULUS/CHECKTORCHMODEL #6898

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bb539fd
Port check_torch_model to nf-core modules
itrujnara Oct 28, 2024
7bf66da
Fix stimulus/checktorchmodel structure and add nf-test
itrujnara Oct 28, 2024
ad6ffdb
Remove pytorch channel
itrujnara Oct 29, 2024
9dc3eb2
Fix initial weights parameter in stimulus/checktorchmodel
itrujnara Oct 29, 2024
5ddf81b
Fix stimulus/checktorchmodel tests
itrujnara Oct 29, 2024
8eeb349
stimulus/checktorchmodel add versions to dependencies
itrujnara Oct 29, 2024
fbb4798
stimulus/checktorchmodel fix typos in main
itrujnara Oct 29, 2024
c24b4ed
stimulus/checktorchmodel fix typos in meta
itrujnara Oct 29, 2024
978eae7
stimulus/checktorchmodel run test
itrujnara Oct 29, 2024
1c09b33
Make prettier happy
itrujnara Oct 29, 2024
aac0a38
Update modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test
itrujnara Oct 30, 2024
8ba6f8d
Update stimulus/checktorchmodel to match new Stimulus API
itrujnara Feb 6, 2025
96bf1d1
Bump container version in stimulus/checktorchmodel
itrujnara Feb 10, 2025
0775cae
Fix file name in stimulus/checktorchmodel test
itrujnara Feb 10, 2025
046dda2
Change container version in stimulus/checktorchmodel
itrujnara Feb 11, 2025
6aceabb
Merge branch 'nf-core:master' into check_torch_model
itrujnara Feb 11, 2025
c04fc67
Merge branch 'check_torch_model' of https://github.com/itrujnara/modu…
itrujnara Feb 11, 2025
1233e4b
Fix test issues in stimulus/checktorchmodel
itrujnara Feb 11, 2025
4688dba
Update Conda environment for stimulus/checktorchmodel
itrujnara Feb 11, 2025
5984507
Fix Conda environment for stimulus/checktorchmodel
itrujnara Feb 12, 2025
ba73e60
Add conda directive, remake inputs, fix arguments for stimulus/checkt…
itrujnara Feb 12, 2025
bed1758
Add meta maps to meta for stimulus/checktorchmodel
itrujnara Feb 12, 2025
8203d8c
Change tests to new input format in stimulus/checktorchmodel
itrujnara Feb 12, 2025
c54add4
Meta tweaks in stimulus/checktorchmodel
itrujnara Feb 13, 2025
45d54b3
Update package version in stimulus/checktorchmodel
itrujnara Feb 13, 2025
df4c25f
Merge branch 'nf-core:master' into check_torch_model
itrujnara Feb 24, 2025
bc36213
Update environment.yml to use the Conda package
itrujnara Feb 24, 2025
0acb3a1
Merge branch 'check_torch_model' of https://github.com/itrujnara/modu…
itrujnara Feb 24, 2025
665c29f
Fix package name in environment.yml in stimulus/checktorchmodel
itrujnara Feb 24, 2025
aa2604c
Add explicit cleanup in stimulus/checktorchmodel
itrujnara Feb 24, 2025
fd1a2c0
Update snapshot after version change in stimulus/checktorchmodel
itrujnara Feb 24, 2025
da708f2
Add meta to output channel in stimulus/checktorchmodel
itrujnara Feb 24, 2025
86e1968
Add Docker options to hopefully resolve CI issues in stimulus/checkto…
itrujnara Feb 24, 2025
1d2eccd
Merge branch 'master' into check_torch_model
itrujnara Feb 25, 2025
a9a0ab3
Try a different Docker config
itrujnara Feb 25, 2025
7945d73
Try another Docker config
itrujnara Feb 25, 2025
7b9d8f0
Merge branch 'check_torch_model' of https://github.com/itrujnara/modu…
itrujnara Feb 25, 2025
7323357
Try yet another config for runners in stimulus/checktorchmodel
itrujnara Feb 26, 2025
e309016
Merge branch 'master' into check_torch_model
itrujnara Feb 26, 2025
996033b
Tweak Docker config for runners in stimulus/checktorchmodel
itrujnara Feb 26, 2025
b3779ca
Merge branch 'check_torch_model' of https://github.com/itrujnara/modu…
itrujnara Feb 26, 2025
6c71e9b
More docker configs
itrujnara Feb 26, 2025
517e861
add ssh debug step
mirpedrol Feb 26, 2025
3c65275
always run debug ssh step
mirpedrol Feb 26, 2025
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
9 changes: 9 additions & 0 deletions modules/nf-core/stimulus/checktorchmodel/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
channels:
- conda-forge
- bioconda

dependencies:
- conda-forge::python=3.12
- conda-forge::pip=25.0.1
- pip:
- stimulus-py==0.2.4
60 changes: 60 additions & 0 deletions modules/nf-core/stimulus/checktorchmodel/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
process STIMULUS_CHECKTORCHMODEL {
tag "$meta.id"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "docker.io/mathysgrapotte/stimulus-py:0.2.6"

input:
tuple val(meta) , path(data) , path(data_config)
tuple val(meta2), path(model), path(model_config), path(initial_weights)

output:
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 ?: meta.id
def weights_arg = initial_weights ? "--initial_weights ${initial_weights}" : ""
"""
# initialize Ray
ray start --head --port=6379 --temp-dir /tmp/ray

# wait for it to start
sleep 10

# run the model check
stimulus-check-model \
-d ${data} \
-m ${model} \
-e ${data_config} \
-c ${model_config} \
${weights_arg} \
--ray_results_dirpath ${workDir} \
$args > ${prefix}_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 ?: ''
prefix = task.ext.prefix ?: meta.id
def STIMULUS_VER = '0.2.6' // container not used in stub, change manually
"""
touch ${prefix}_modelcheck.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Python: \$(python --version | cut -d ' ' -f 2)
Stimulus-py: ${STIMULUS_VER}
END_VERSIONS
"""
}
74 changes: 74 additions & 0 deletions modules/nf-core/stimulus/checktorchmodel/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "stimulus_checktorchmodel"
description: Sanity check a Pytorch model using raytune
keywords:
- machine learning
- neural network
- unit test
tools:
- "stimulus":
description: "Stochastic Testing and Input Manipulation for Unbiased Learning Systems"
homepage: "https://github.com/mathysgrapotte/stimulus-py"
documentation: "https://github.com/mathysgrapotte/stimulus-py"
tool_dev_url: "https://github.com/mathysgrapotte/stimulus-py"
licence: ["MIT"]

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- data:
type: file
description: A CSV file with untransformed data
pattern: "*.csv"
ontologies:
- edam: "http://edamontology.org/format_3752"
- data_config:
type: file
description: A YAML file describing data transformations
pattern: "*.{yml,yaml}"
ontologies:
- edam: "http://edamontology.org/format_3464"
- - meta2:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- model:
type: file
description: Python source file containing the model
pattern: "*.py"
ontologies:
- edam: "http://edamontology.org/format_3996"
- model_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"
- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@mathysgrapotte"
- "@alessiovignoli"
- "@itrujnara"
maintainers:
- "@itrujnara"
66 changes: 66 additions & 0 deletions modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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"

test("basic - csv - py") {

when {
process {
"""
input[0] = [[id: 'test'],
file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_stimulus_split.csv', checkIfExists: true),
file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_sub_config_0.yaml', checkIfExists: true)]
input[1] = [[id: 'test'],
file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_model.py', checkIfExists: true),
file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_model_cpu.yaml', checkIfExists: true),
[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert file(process.out.log[0]).readLines().get(1).contains("Configuration for experiment") },
{ assert snapshot(process.out.versions).match() }
)
}

}

test("basic - csv - stub") {

options "-stub"

when {
process {
"""
input[0] = [[id: 'test'],
file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_stimulus_split.csv', checkIfExists: true),
file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_sub_config_0.yaml', checkIfExists: true)]
input[1] = [[id: 'test'],
file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_model.py', checkIfExists: true),
file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_model_cpu.yaml', checkIfExists: true),
[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
37 changes: 37 additions & 0 deletions modules/nf-core/stimulus/checktorchmodel/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"basic - csv - py": {
"content": [
[
"versions.yml:md5,84d45b8dcf715e8f42c82339832c0f29"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-02-11T16:24:18.958811"
},
"basic - csv - stub": {
"content": [
{
"0": [
"test_modelcheck.log:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"1": [
"versions.yml:md5,93ac0e7a6e1914cf803e967cf11943ff"
],
"log": [
"test_modelcheck.log:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,93ac0e7a6e1914cf803e967cf11943ff"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-02-13T16:29:02.835237"
}
}
Loading