×

nf-python @ 0.1.4

Provider: Roy Jacobson
Claimed: 07 Nov 2025 17:45:28 (UTC)
Description: The `nf-python` plugin integrates Nextflow workflows with Python scripts, enabling seamless execution of Python code within pipelines while automatically handling argument passing and output serialization. It solves the challenge of combining Python-based data processing with Nextflow's workflow management, ideal for bioinformaticians, data scientists, or developers who need to incorporate Python tools or custom scripts into scalable, reproducible pipelines. Users can specify Python environments (e.g., Conda) and run scripts either as external files or inline code, simplifying hybrid workflow development.
Latest version: 0.1.4
Total downloads: 315 View trends

Summary

nf-python is a Nextflow plugin enabling seamless integration between Nextflow and Python scripts. Python scripts can be invoked as part of your Nextflow workflow, and arguments and outputs will be serialized back-and-forth automatically, making them available as native pythonic objects.

Get Started

To use the plugin in your Nextflow data pipelines, simply include it by writing include { pyFunction } from 'plugin/nf-python' and it will be downloaded and installed. For all setup options, please refer to the Nextflow plugins documentation.

nf-python requires a working python installation in the execution environment. By default, the python in path will be used. It is also possible to specify a path to a specific python executable or a conda environment. Either in the configuration file:

nf_python {
  // Option 1
  executable = '/usr/bin/python'
  // Option 2
  conda_env = ''
}

The supported values for the conda_env option are the same ones supported by Nextflow's native conda support, and is using the same configuration options. Here are a few options:

  1. A list of required packages (e.g. conda_env = 'numpy biopython')
  2. A conda configuration file (e.g. conda_env = '/opt/task-env.yml')
  3. A path to an existing conda environment (e.g. conda_env = '/home/user/.conda/envs/my-env')

It is also possible to specify different environments on a per-function basis:

pyFunction(script: "", x: 1, y: 2, _executable: "/usr/bin/python")
pyFunction(script: "", x: 1, y: 2, _conda_env: "matplotlib")

Examples

To use a python script as part of your Nextflow pipeline, import pyFunction from the nf-python plugin:

include { pyFunction } from 'plugin/nf-python'

pyFunction('my_other_script.py', foo: 'too')

Usage inside python is easy:

  • Arguments (like foo) are passed as nf_python.nf.args.
  • To return results to nextflow, use nf_python.nf.output(...)
  • All major native data types (lists, dicts, etc.) are supported.
# example_script.py
from nf_python import nf

# Access arguments and options
print(nf.args)
print(nf.opts)

# Assign output
nf.output(result=nf.args[0] + 1)

Inline Code Support

pyFunction also support inline code. Here is an example:

result = pyFunction("""
    # Code is automatically de-indented correctly
    # `nf_python.nf` is accessible as `nf`
    nf.output(arg1=123, arg2='abc')
""")
assert result == [arg1: 123, arg2: 'abc']

result = pyFunction("""
    nf.output(arg1=123, arg2='abc', arg3=nf.args['foo'])
""", foo: 1)
assert result == [arg1: 123, arg2: 'abc', arg3: 1]

License

See COPYING for license information. The layout of the project is based on the nf-hello project, licensed under the Apache License 2.0.

Nextflow version >=24.04.0
Depends On -
Release Date 09 Jan 2026 13:50:38 (UTC)
Release Notes -
Download URL https://registry.nextflow.io/api/v1/plugins/nf-python/0.1.4/download/nf-python-0.1.4.zip
Store URL https://public.cr.seqera.io/v2/nextflow/plugin/nf-python/blobs/sha256:022250a2c68a96bad589bc3515a3cab8fafcfdf1acc2a0b742fb040bd20f1b2c
Size 31.1 KB
Checksum 99d59cf3e396ea934480f6ad1571e9a4038c1cd4c80e6836ce769c5eba06d01f126be2b8ce7eea5ae5bd842634dcb6bfe6851797b06a60469130803ee9a14567
Total downloads 13 View trends
Security Scan
Version Nextflow version Date Status Downloads
0.1.4 >=24.04.0 09 Jan 2026 13:50:38 (UTC) 13
0.1.3 >=23.04.0 28 Jul 2025 12:30:22 (UTC) 138
0.1.2 >=22.04.0 05 Jul 2025 21:33:08 (UTC) 164