nextflow-io / nextflow

A DSL for data-driven computational pipelines
http://nextflow.io
Apache License 2.0
2.61k stars 605 forks source link

Docs on running a subprocess in completion handler #5050

Open nick-youngblut opened 3 weeks ago

nick-youngblut commented 3 weeks ago

It would be helpful to include docs on how to run a subprocess in the completion handler. For instance:

workflow.onComplete{
     def proc = ['./bin/final_checks.sh'].execute()
     proc.waitForProcessOutput()
}

...or another example:

workflow.onComplete {
    if (!workflow.success) {
        def proc = ['./bin/run_llm_model_to_eval_the_error.sh'].execute()
        def output = new StringBuffer()
        def error = new StringBuffer()
        proc.consumeProcessOutput(output, error)
        proc.waitFor()

        if (proc.exitValue() != 0) {
            println "Error running LLM model script: ${error.toString()}"
        } else {
            println "LLM model script output: ${output.toString()}"
        }
    }
}

Currently the completion handler docs just discuss workflow introspection:

workflow.onComplete {
    println "Pipeline completed at: $workflow.complete"
    println "Execution status: ${ workflow.success ? 'OK' : 'failed' }"
}