如何在 workflow.onError 中调用进程

How to call a process in workflow.onError

我有这个小管道:


process test {
    """
    echo 'hello'
    exit 1
    """
}

workflow.onError {
    process finish_error{
        script:
        """
        echo 'blablabla'
        """
    }
}

我想触发一个 python 脚本,以防管道使用完成错误过程出错,但即使使用简单的 echo blabla 示例,整个过程似乎也不会被触发.

nextflow run test.nf 
N E X T F L O W  ~  version 20.10.0
Launching `test.nf` [cheesy_banach] - revision: 9020d641ca
executor >  local (1)
[56/994298] process > test         [100%] 1 of 1, failed: 1 ✘
[-        ] process > finish_error [  0%] 0 of 1
Error executing process > 'test'

Caused by:
  Process `test` terminated with an error exit status (1)

Command executed:

  echo 'hello'
  exit 1

Command exit status:
  1

Command output:
  hello

Command wrapper:
  hello

Work dir:
  /home/joost/nextflow/work/56/9942985fc9948fd9bf7797d39c1785

Tip: when you have fixed the problem you can continue the execution adding the option `-resume` to the run command line

如何触发此 finish_error 进程,如何查看其输出?

当进程导致管道执行过早终止时,将调用 onError 处理程序。由于 Nextflow 管道实际上只是一系列连接在一起的进程,因此从事件处理程序中启动另一个管道进程对我来说意义不大。如果你的 python 脚本应该是 运行 使用本地执行器,你可以按照通常的方式执行它。此示例假定您的脚本是可执行的并且具有适当的 shebang:

process test {

    """
    echo 'hello'
    exit 1
    """
}

workflow.onError {

    def proc = "${baseDir}/test.py".execute()
    proc.waitFor()

    println proc.text
}

运行 使用:

nextflow run -ansi-log false test.nf