Skip to content

Commit

Permalink
putting alessio's test since those are nextflow based
Browse files Browse the repository at this point in the history
  • Loading branch information
mathysgrapotte committed Oct 16, 2024
1 parent 125721a commit 0ba06ba
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/handle_data.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

nextflow_workflow {

name "Test Workflow HANDLE_DATA"
script "../workflows/handle_data.nf"
workflow "HANDLE_DATA"

test("Test reproducibility of data handling") {

when {

// make so that nf-test will see a singularity cache dir where is usally set to, again interpretation of projectdir has to be done here and not rely on an external config.
params {
singularity_cache_dir = "${projectDir}/singularity_cache"
}

// repeating in input[0-1] the same content of params.csv and parma.exp_conf present in the test.config because nf-test does not interpret the ${projectDir} correctly otherwise
workflow {
"""
input[0] = "${projectDir}/bin/tests/test_data/dna_experiment/test_with_split.csv"
input[1] = "${projectDir}/examples/test.json"
input[2] = Channel.of("TESTING")
"""
}
}

then {

assert workflow.success

assert snapshot(workflow.out.data).match()
}
}
}
55 changes: 55 additions & 0 deletions tests/handle_data.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"Test reproducibility of data handling": {
"content": [
[
[
"test_with_split.csv - shuffle",
"no_split",
"test_with_split-shuffled-experiment.json:md5,04768aaf767c8cd2c043f510432b78e0",
"test_with_split-shuffle.csv:md5,b69d4616b7cecaa62d5e3e41c010d7c4"
],
[
"test_with_split.csv - test-1",
"no_split",
"test-1-experiment.json:md5,4ce80948f2bd82af2ca42e3bb81fbb32",
"test_with_split-test-1-trans.csv:md5,8dbc69f2845da31ff8ab2381a2667a4e"
],
[
"test_with_split.csv - test-2",
"RandomSplitter_0.34_0.33_0.33_4",
"test-2-experiment.json:md5,5bb998041e683c327dcfec81a908fa36",
"test_with_split-test-2-trans.csv:md5,64ecd933e2bc0c0d2c42a107288c3a0e"
],
[
"test_with_split.csv - test-3",
"no_split",
"test-3-experiment.json:md5,2a6576e2eee24cbd026e3db7944d2733",
"test_with_split-test-3-trans.csv:md5,9f0179b00db4bd806df0d0760e036020"
],
[
"test_with_split.csv - test-4",
"RandomSplitter_0.34_0.33_0.33_4",
"test-4-experiment.json:md5,888b5a8cdf10c3f6fbd0c061c127b28b",
"test_with_split-test-4-trans.csv:md5,35c600e3d5af5280c3ce50e683d4e1da"
],
[
"test_with_split.csv - test-5",
"no_split",
"test-5-experiment.json:md5,0dd70a06361d79438e1cd154cacf132b",
"test_with_split-test-5-trans.csv:md5,535ede6479723133ff71020eec9de4b1"
],
[
"test_with_split.csv - test-6",
"RandomSplitter_0.34_0.33_0.33_4",
"test-6-experiment.json:md5,fde920c7e4d815a56e4825dfd3f7e415",
"test_with_split-test-6-trans.csv:md5,fbbdfd06c6ec07b126ae68592bd09e54"
]
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-06-12T17:34:58.30196"
}
}
58 changes: 58 additions & 0 deletions tests/handle_tune.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
nextflow_workflow {

name "Test Workflow HANDLE_TUNE"
script "../workflows/handle_tune.nf"
workflow "HANDLE_TUNE"

test("Test reproducibility of model tuning") {

setup {
run("HANDLE_DATA") {
script "../workflows/handle_data.nf"
workflow {
"""
input[0] = "${projectDir}/bin/tests/test_data/dna_experiment/test_with_split.csv"
input[1] = "${projectDir}/examples/test.json"
input[2] = Channel.of("TESTING")
"""
}
}
}

when {

// make so that nf-test will see a singularity cache dir where is usally set to, again interpretation of projectdir has to be done here and not rely on an external config.
params {
singularity_cache_dir = "${projectDir}/singularity_cache"
debug_mode = true


max_gpus = 0


}

// repeating in input[0-1] the same content params.model of params.tune_conf present in the test.config because nf-test does not interpret the ${projectDir} correctly otherwise
// using both only CPU and only GPU.
workflow {
"""
input[0] = "${projectDir}/bin/tests/test_model/dnatofloat_model.py"
input[1] = "${projectDir}/bin/tests/test_model/dnatofloat_model_cpu.yaml"
input[2] = HANDLE_DATA.out.data
"""
}
}

then {

// first chech that the model initialization is always identical
// then check that the seeds used are the same through randomly picked numbers
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out.debug).match() }
)
}

}

}
134 changes: 134 additions & 0 deletions tests/handle_tune.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"Test reproducibility of model tuning": {
"content": [
[
[
[
"debug_test_with_split-test-6",
[
"best_model_seed.txt:md5,24b16fede9a67c9251d3e7c7161c83ac",
"best_model_val_pred.txt:md5,08f6d202085b428fa0add4f36084fa59"
],
[
"model.pt:md5,d4adc1515585c66c2843ecdace31de15",
"model.pt:md5,e1310d3caaa760554d47074742fe8359",
"model.pt:md5,8a5d5ada2f493eb23508ec423c500d1b"
],
[
"seeds.txt:md5,ccae8b777d84a1d4ee9dc8965a4d8bd3",
"seeds.txt:md5,4cee7381be8890309148bc2af7ab50c3",
"seeds.txt:md5,6e77a0e21f32c2a9f9a0e27eee59c336"
]
],
[
"debug_test_with_split-test-5",
[
"best_model_seed.txt:md5,24b16fede9a67c9251d3e7c7161c83ac",
"best_model_val_pred.txt:md5,03b1529fca6d3e337a2debe494ab4ef5"
],
[
"model.pt:md5,d4adc1515585c66c2843ecdace31de15",
"model.pt:md5,e1310d3caaa760554d47074742fe8359",
"model.pt:md5,8a5d5ada2f493eb23508ec423c500d1b"
],
[
"seeds.txt:md5,ccae8b777d84a1d4ee9dc8965a4d8bd3",
"seeds.txt:md5,4cee7381be8890309148bc2af7ab50c3",
"seeds.txt:md5,6e77a0e21f32c2a9f9a0e27eee59c336"
]
],
[
"debug_test_with_split-test-4",
[
"best_model_seed.txt:md5,4c56ff4ce4aaf9573aa5dff913df997a",
"best_model_val_pred.txt:md5,f9e0e0a84270d98fd9605c32c8feb3ab"
],
[
"model.pt:md5,d4adc1515585c66c2843ecdace31de15",
"model.pt:md5,e1310d3caaa760554d47074742fe8359",
"model.pt:md5,8a5d5ada2f493eb23508ec423c500d1b"
],
[
"seeds.txt:md5,ccae8b777d84a1d4ee9dc8965a4d8bd3",
"seeds.txt:md5,4cee7381be8890309148bc2af7ab50c3",
"seeds.txt:md5,6e77a0e21f32c2a9f9a0e27eee59c336"
]
],
[
"debug_test_with_split-test-3",
[
"best_model_seed.txt:md5,4c56ff4ce4aaf9573aa5dff913df997a",
"best_model_val_pred.txt:md5,7d83395ef9592300c062666031141443"
],
[
"model.pt:md5,d4adc1515585c66c2843ecdace31de15",
"model.pt:md5,e1310d3caaa760554d47074742fe8359",
"model.pt:md5,8a5d5ada2f493eb23508ec423c500d1b"
],
[
"seeds.txt:md5,ccae8b777d84a1d4ee9dc8965a4d8bd3",
"seeds.txt:md5,4cee7381be8890309148bc2af7ab50c3",
"seeds.txt:md5,6e77a0e21f32c2a9f9a0e27eee59c336"
]
],
[
"debug_test_with_split-test-2",
[
"best_model_seed.txt:md5,4c56ff4ce4aaf9573aa5dff913df997a",
"best_model_val_pred.txt:md5,f9e0e0a84270d98fd9605c32c8feb3ab"
],
[
"model.pt:md5,d4adc1515585c66c2843ecdace31de15",
"model.pt:md5,e1310d3caaa760554d47074742fe8359",
"model.pt:md5,8a5d5ada2f493eb23508ec423c500d1b"
],
[
"seeds.txt:md5,ccae8b777d84a1d4ee9dc8965a4d8bd3",
"seeds.txt:md5,4cee7381be8890309148bc2af7ab50c3",
"seeds.txt:md5,6e77a0e21f32c2a9f9a0e27eee59c336"
]
],
[
"debug_test_with_split-test-1",
[
"best_model_seed.txt:md5,4c56ff4ce4aaf9573aa5dff913df997a",
"best_model_val_pred.txt:md5,7d83395ef9592300c062666031141443"
],
[
"model.pt:md5,d4adc1515585c66c2843ecdace31de15",
"model.pt:md5,e1310d3caaa760554d47074742fe8359",
"model.pt:md5,8a5d5ada2f493eb23508ec423c500d1b"
],
[
"seeds.txt:md5,ccae8b777d84a1d4ee9dc8965a4d8bd3",
"seeds.txt:md5,4cee7381be8890309148bc2af7ab50c3",
"seeds.txt:md5,6e77a0e21f32c2a9f9a0e27eee59c336"
]
],
[
"debug_test_with_split-shuffle",
[
"best_model_seed.txt:md5,4c56ff4ce4aaf9573aa5dff913df997a",
"best_model_val_pred.txt:md5,d151f5cedafe154617ea3e05826261af"
],
[
"model.pt:md5,d4adc1515585c66c2843ecdace31de15",
"model.pt:md5,e1310d3caaa760554d47074742fe8359",
"model.pt:md5,8a5d5ada2f493eb23508ec423c500d1b"
],
[
"seeds.txt:md5,ccae8b777d84a1d4ee9dc8965a4d8bd3",
"seeds.txt:md5,4cee7381be8890309148bc2af7ab50c3",
"seeds.txt:md5,6e77a0e21f32c2a9f9a0e27eee59c336"
]
]
]
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-07-18T19:08:19.490204"
}
}
36 changes: 36 additions & 0 deletions tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
========================================================================================
Nextflow config file for running tests
========================================================================================
*/

/*
params {
// Base directory for nf-core/modules test data
modules_testdata_base_path = 's3://ngi-igenomes/testdata/nf-core/modules/'
// Base directory for nf-core/fetchngs test data
pipelines_testdata_base_path = 's3://ngi-igenomes/testdata/nf-core/pipelines/fetchngs/1.15.0/'
}
// Impose sensible resource limits for testing
process {
withName: '.*' {
cpus = 2
memory = 3.GB
time = 2.h
}
}
*/

// Impose same minimum Nextflow version as the pipeline for testing
manifest {
nextflowVersion = '!>=23.04.0'
}

// Disable all Nextflow reporting options
timeline { enabled = false }
report { enabled = false }
trace { enabled = false }
dag { enabled = false }

0 comments on commit 0ba06ba

Please sign in to comment.