Nextflow 如何在workflow.onError中调用流程

Nextflow 如何在workflow.onError中调用流程,nextflow,Nextflow,我有一个小管道: process test { """ echo 'hello' exit 1 """ } workflow.onError { process finish_error{ script: """ echo 'blablabla' """ } }

我有一个小管道:


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

workflow.onError {
    process finish_error{
        script:
        """
        echo 'blablabla'
        """
    }
}
我想使用finisherror过程触发一个python脚本,以防管道出现错误,但即使使用一个简单的
echobala
示例,整个过程似乎也不会被触发

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_错误进程,以及如何查看其输出?

当进程导致管道执行提前终止时,将调用
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 

谢谢你的回答,史蒂夫,效果很好。也可以在给定的docker容器中执行此过程吗?我认为要执行的字符串也可以是一个列表,因此您可以执行以下操作:
def proc=['/bin/sh'、'-c'、“docker run--rm-v${baseDir}:/scripts python:3.7 python/scripts/test.py”]。execute()
。不过这感觉有点像黑客。如果可能的话,最好将Python重构为Groovy代码。