Debugging Nextfow core/plugins

Requirements

Say you’re developing your own Nextflow plugin (or want to learn how Nextflow works internally) and don’t want to populate your code with thousands of println "passing 1".

Say you want to debug your code to understand these corner cases that tests are not able to reproduce

In this post, I’ll show you how easily it is using Intellij (Community Edition is ok). So basically the requirements are:

  • Intellij as IDE

  • A repository with your code (or the Nextflow core repo)

  • A pipeline to be executed

I’ll use nf-parquet as the plugin I want to debug

Cloning and installing repo

In a fresh directory you need to grab the project

Next, we need to build and install the plugin in our machine

./gradlew installPlugin

This command will compile and install last version of the plugin in our $HOME/.nextflow/plugins folder

IntelliJ

Open the nf-parquet directory with Intellij and let it to reindex the project (hope a few seconds)

In the Project view (at the left) navigate and open ParquetExtension.groovy file

debug nextflow 1

Scroll down until line 44 and click on the line number. A red dot will show the breakpoint is activated in this line

debug nextflow 2

Now we need to create a "JVM Remote Debug configuration".

Select "Edit configuration":

debug nextflow 3

and create a new JVM Debug configuration:

debug nextflow 4

press OK and accept default values

Running the pipeline

nf-parquet comes with some simple pipelines to validate it. Open a console terminal and navigate to the validation folder and execute one of them:

export PARQUET_PLUGIN_VERSION=0.2.1 (1)
nextflow -remote-debug run read.nf (2)
1 nextflow.config allows to test different versions of the plugin
2 pay attention where "-remote-debug" is specified

If all goes well, the pipeline will be stopped at the start and is waiting for the debug session showing the message Listening for transport dt_socket at address: 5005

Go to the Intellij editor and click in the "bug" green button close to the "Unnamed" configuration (in case you didnt provided one)

As soon both JVMs are connected your pipeline will start. When the execution reach the breakpoint it will be stopped and you can inspect the variables, for example:

debug nextflow 5

Uses the debug buttons to "continue", "step by step", etc to continue with the execution of your pipeline

debug nextflow 6
INFO

stop the debug process only "detached" your session, the pipeline will be running

INFO

You dont need to create a new JVM Debug configuration.

Fixing code

Say you find where your code is failing, or you want to try something new. Simple change your code, execute again the installPlugin task and repeat the process

Este texto ha sido escrito por un humano

This post has been written by a human

2019 - 2025 | Mixed with Bootstrap | Baked with JBake v2.6.7 | Terminos Terminos y Privacidad