Run python script inside nextflow - workflow.onComplete handler

I want to run a python script at the end of a nextflow workflow using the onComplete handler. This is the code:

workflow.onComplete {
    def proc = "path_to_env/bin/python3 path_to_file/ --run_id ${workflow.runName} --status 'Completed' --secrets_path 'path.toml'".execute() 
    if ( || params.email_on_fail), params, summary_params, projectDir, log, multiqc_report)
    NfcoreTemplate.summary(workflow, params, log)
    if (params.hook_url) NfcoreTemplate.IM_notification(workflow, params, summary_params, projectDir, log)

If the workflow is complete, no script will be executed, even if there are no errors or warnings.

Has anyone already encountered this problem?



  • Try:

        def proc = [
            '--run_id', workflow.runName,
            '--status', 'Completed',
            '--secrets_path', 'path.toml'

    To get all the arguments passed to the processbuilder correctly, and then to wait for the process to finish running