-
Notifications
You must be signed in to change notification settings - Fork 752
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
base: master
Are you sure you want to change the base?
Changes from 19 commits
bb539fd
7bf66da
ad6ffdb
9dc3eb2
5ddf81b
8eeb349
fbb4798
c24b4ed
978eae7
1c09b33
aac0a38
8ba6f8d
96bf1d1
0775cae
046dda2
6aceabb
c04fc67
1233e4b
4688dba
5984507
ba73e60
bed1758
8203d8c
c54add4
45d54b3
df4c25f
bc36213
0acb3a1
665c29f
aa2604c
fd1a2c0
da708f2
86e1968
1d2eccd
a9a0ab3
7945d73
7b9d8f0
7323357
e309016
996033b
b3779ca
6c71e9b
517e861
3c65275
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
channels: | ||
- conda-forge | ||
- bioconda | ||
|
||
dependencies: | ||
- python=3.12 | ||
- pip | ||
- pip: | ||
- stimulus-py==0.2.4 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,61 @@ | ||||||
process STIMULUS_CHECKTORCHMODEL { | ||||||
tag "$data_config - $data" | ||||||
label 'process_medium' | ||||||
|
||||||
container "docker.io/mathysgrapotte/stimulus-py:0.2.4.dev" | ||||||
vagkaratzas marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
input: | ||||||
path(data) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no meta? :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've found a way to put it back in, it might be useful |
||||||
path(data_config) | ||||||
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 ?: model.baseName.replaceFirst(/\.py/, "") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a suggestion here. Instead of trying to parse the model's file name, shouldn't we just use the |
||||||
def weights_arg = initial_weights ? "--initial_weights ${initial_weights}" : "" | ||||||
vagkaratzas marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
""" | ||||||
# initialize Ray | ||||||
ray start --head --port=6379 --temp-dir /tmp/ray | ||||||
|
||||||
# wait or it to start | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
sleep 10 | ||||||
|
||||||
# run the model check | ||||||
stimulus-check-model \ | ||||||
-d ${data} \ | ||||||
-m ${model} \ | ||||||
-e ${data_config} \ | ||||||
-c ${model_config} \ | ||||||
--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 ?: model.baseName.replaceFirst(/\.py/, "") | ||||||
def STIMULUS_VER = '0.2.2' // 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 | ||||||
""" | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
# 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: | ||
- - 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" | ||
- - 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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// 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] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_stimulus_split.csv', checkIfExists: true) | ||
input[1] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_sub_config_0.yaml', checkIfExists: true) | ||
input[2] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_model.py', checkIfExists: true) | ||
input[3] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_model_cpu.yaml', checkIfExists: true) | ||
input[4] = [] | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert file(process.out.log[0]).readLines().get(1).contains("Configuration for experiment") }, | ||
{ 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("basic - csv - stub") { | ||
|
||
options "-stub" | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_stimulus_split.csv', checkIfExists: true) | ||
input[1] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_sub_config_0.yaml', checkIfExists: true) | ||
input[2] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_model.py', checkIfExists: true) | ||
input[3] = file(params.modules_testdata_base_path + '../../deepmodeloptim/testdata/titanic/titanic_model_cpu.yaml', checkIfExists: true) | ||
input[4] = [] | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot(process.out).match() } | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
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": [ | ||
"titanic_model_modelcheck.log:md5,d41d8cd98f00b204e9800998ecf8427e" | ||
], | ||
"1": [ | ||
"versions.yml:md5,70fcb1abbe6e6a2f1dad708b98db1843" | ||
], | ||
"log": [ | ||
"titanic_model_modelcheck.log:md5,d41d8cd98f00b204e9800998ecf8427e" | ||
], | ||
"versions": [ | ||
"versions.yml:md5,70fcb1abbe6e6a2f1dad708b98db1843" | ||
] | ||
} | ||
], | ||
"meta": { | ||
"nf-test": "0.9.2", | ||
"nextflow": "24.10.3" | ||
}, | ||
"timestamp": "2025-02-11T16:24:24.093869" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just:
tag "$meta.id"