|
a |
|
b/modules/local/stimulus/tune/main.nf |
|
|
1 |
process STIMULUS_TUNE { |
|
|
2 |
tag "${meta.id}" |
|
|
3 |
label 'process_high' |
|
|
4 |
container "docker.io/mathysgrapotte/stimulus-py:dev" |
|
|
5 |
|
|
|
6 |
input: |
|
|
7 |
tuple val(meta), path(transformed_data), path(data_sub_config) |
|
|
8 |
tuple val(meta2), path(model), path(model_config), path(initial_weights) |
|
|
9 |
|
|
|
10 |
output: |
|
|
11 |
tuple val(meta), path("${prefix}-best-model.safetensors") , emit: model |
|
|
12 |
tuple val(meta), path("${prefix}-best-optimizer.opt") , emit: optimizer |
|
|
13 |
tuple val(meta), path("optuna_results/artifacts") , emit: artifacts |
|
|
14 |
tuple val(meta), path("optuna_results/optuna_journal_storage.log"), emit: journal |
|
|
15 |
path "versions.yml" , emit: versions |
|
|
16 |
// now we need to output these in this format for the predict module - thiw will have to be changed! |
|
|
17 |
tuple val(meta), path(model), path("best_config.json"), path("${prefix}-best-model.safetensors"), emit: model_tmp |
|
|
18 |
tuple val(meta), path(data_sub_config) , emit: data_config_tmp |
|
|
19 |
|
|
|
20 |
script: |
|
|
21 |
prefix = task.ext.prefix ?: meta.id |
|
|
22 |
def args = task.ext.args ?: "" |
|
|
23 |
def use_initial_weights = initial_weights != [] ? "-w ${initial_weights}" : "" |
|
|
24 |
""" |
|
|
25 |
stimulus tune \ |
|
|
26 |
-d ${transformed_data} \ |
|
|
27 |
-m ${model} \ |
|
|
28 |
-e ${data_sub_config} \ |
|
|
29 |
-c ${model_config} \ |
|
|
30 |
-o ${prefix}-best-model.safetensors \ |
|
|
31 |
-bo ${prefix}-best-optimizer.opt \ |
|
|
32 |
${args} |
|
|
33 |
|
|
|
34 |
cat <<-END_VERSIONS > versions.yml |
|
|
35 |
"${task.process}": |
|
|
36 |
stimulus: \$(stimulus -v | cut -d ' ' -f 3) |
|
|
37 |
END_VERSIONS |
|
|
38 |
""" |
|
|
39 |
|
|
|
40 |
stub: |
|
|
41 |
prefix = task.ext.prefix ?: meta.id |
|
|
42 |
""" |
|
|
43 |
touch ${prefix}-best-model.safetensors |
|
|
44 |
touch ${prefix}-best-optimizer.opt |
|
|
45 |
touch best_config.json |
|
|
46 |
touch TuneModel_stub.txt |
|
|
47 |
|
|
|
48 |
cat <<-END_VERSIONS > versions.yml |
|
|
49 |
"${task.process}": |
|
|
50 |
stimulus: \$(stimulus -v | cut -d ' ' -f 3) |
|
|
51 |
END_VERSIONS |
|
|
52 |
""" |
|
|
53 |
} |