Skip to content

Package directive #6342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
15cf708
test(#6092): Add Pixi environment support
edmundmiller Jun 2, 2025
3e4e74c
test(#6092): Add Pixi environment tests
edmundmiller Jun 3, 2025
08bd78d
test(#6092): Add integration tests for PixiCache functionality
edmundmiller Jun 3, 2025
c7f2085
test: Update sayHello process to use cowpy
edmundmiller Jun 3, 2025
c437cbe
feat: Add preview.package feature flag
edmundmiller Aug 13, 2025
42a1d48
feat: Add core package management abstraction
edmundmiller Aug 13, 2025
f84ff4a
feat: Add package directive to process configuration
edmundmiller Aug 13, 2025
503d412
feat: Update bash wrapper for unified package activation
edmundmiller Aug 13, 2025
b1051fa
feat: Add nf-conda package manager plugin
edmundmiller Aug 13, 2025
2c53f95
feat: Add nf-pixi package manager plugin
edmundmiller Aug 13, 2025
778d059
feat: Add Wave integration for unified package management
edmundmiller Aug 13, 2025
ada8d29
test: Add comprehensive test suite for package management
edmundmiller Aug 13, 2025
7258685
docs: Add unified package management documentation
edmundmiller Aug 13, 2025
4ff0532
fix: update package system to use ISession interface consistently
edmundmiller Aug 14, 2025
51ae824
build: configure package manager plugins for proper compilation
edmundmiller Aug 14, 2025
b3e3f26
style: move inline imports to top-level import statements
edmundmiller Aug 14, 2025
e3b1b47
refactor: remove never-merged Pixi implementation
edmundmiller Aug 14, 2025
c230003
docs: add comprehensive unified package management documentation
edmundmiller Aug 14, 2025
c6aa424
docs: update conda documentation with package directive migration info
edmundmiller Aug 14, 2025
83f4e97
feat: add R package provider for Wave integration
edmundmiller Aug 14, 2025
89f69bc
fix: add session config to test mocks to prevent NPE
edmundmiller Aug 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 219 additions & 0 deletions PACKAGE_MANAGEMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# Unified Package Management System

This document describes the new unified package management system in Nextflow, introduced as a preview feature behind the `nextflow.preview.package` flag.

## Overview

The unified package management system provides a consistent interface for managing packages across different package managers (conda, pixi, mamba, etc.) through a single `package` directive.

## Enabling the Feature

Add this to your `nextflow.config`:

```groovy
nextflow.preview.package = true
```

## Basic Usage

### Single Package

```groovy
process example {
package "samtools=1.17", provider: "conda"

script:
"""
samtools --version
"""
}
```

### Multiple Packages

```groovy
process example {
package ["samtools=1.17", "bcftools=1.18"], provider: "conda"

script:
"""
samtools --version
bcftools --version
"""
}
```

### Using Default Provider

Configure a default provider in your config:

```groovy
packages {
provider = 'conda'
}
```

Then use:

```groovy
process example {
package "samtools=1.17" // uses default provider

script:
"""
samtools --version
"""
}
```

### Advanced Configuration

```groovy
process example {
package {
provider = "conda"
packages = ["samtools=1.17", "bcftools=1.18"]
channels = ["conda-forge", "bioconda"]
options = [
createTimeout: "30 min"
]
}

script:
"""
samtools --version
bcftools --version
"""
}
```

### Environment Files

```groovy
process example {
package {
provider = "conda"
environment = file("environment.yml")
}

script:
"""
python script.py
"""
}
```

## Supported Providers

- `conda` - Anaconda/Miniconda package manager
- `pixi` - Fast conda alternative with lockfiles
- `mamba` - Fast conda alternative
- `micromamba` - Minimal conda implementation

## Configuration

### Global Configuration

```groovy
// nextflow.config
nextflow.preview.package = true

packages {
provider = 'conda' // default provider
}

// Provider-specific configurations
conda {
channels = ['conda-forge', 'bioconda']
createTimeout = '20 min'
}

pixi {
cacheDir = '/tmp/pixi-cache'
}
```

## Wave Integration

The unified package system integrates with Wave for containerization:

```groovy
process example {
package "samtools=1.17", provider: "conda"

script:
"""
samtools --version
"""
}
```

Wave will automatically create a container with the specified packages.

## Backward Compatibility

Old `conda` and `pixi` directives continue to work but show deprecation warnings when the preview feature is enabled:

```groovy
process oldStyle {
conda 'samtools=1.17' // Shows deprecation warning

script:
"""
samtools --version
"""
}
```

## Migration Guide

### From conda directive

**Before:**
```groovy
process example {
conda 'samtools=1.17 bcftools=1.18'
script: "samtools --version"
}
```

**After:**
```groovy
process example {
package ["samtools=1.17", "bcftools=1.18"], provider: "conda"
script: "samtools --version"
}
```

### From pixi directive

**Before:**
```groovy
process example {
pixi 'samtools bcftools'
script: "samtools --version"
}
```

**After:**
```groovy
process example {
package ["samtools", "bcftools"], provider: "pixi"
script: "samtools --version"
}
```

## Plugin Architecture

The system is extensible through plugins. Package managers are implemented as plugins that extend the `PackageProviderExtension` interface:

- `nf-conda` - Conda support
- `nf-pixi` - Pixi support

Custom package managers can be added by implementing the `PackageProvider` interface and registering as a plugin.

## Examples

See the test files for complete examples:
- `tests/package-test.nf` - Basic usage examples
- `tests/integration-test.nf` - Integration and backward compatibility tests
47 changes: 47 additions & 0 deletions docs/conda.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ The Conda environment feature is not supported by executors that use remote obje

The use of Conda recipes specified using the {ref}`process-conda` directive needs to be enabled explicitly in the pipeline configuration file (i.e. `nextflow.config`):

:::{note}
Nextflow also provides a unified {ref}`package-page` system that supports conda and other package managers through a single interface. This newer system is enabled with the `preview.package` feature flag and provides a more consistent experience across different package managers.
:::

```groovy
conda.enabled = true
```
Expand Down Expand Up @@ -191,6 +195,49 @@ process hello {

It is also possible to use [mamba](https://github.com/mamba-org/mamba) to speed up the creation of conda environments. For more information on how to enable this feature please refer to {ref}`Conda <config-conda>`.

## Migration to Unified Package Management

The unified {ref}`package-page` system provides a modern alternative to the conda directive. When the `preview.package` feature is enabled, you can use the new syntax:

### Before (conda directive):
```nextflow
process example {
conda 'samtools=1.15 bcftools=1.15'

script:
"""
samtools --version
bcftools --version
"""
}
```

### After (package directive):
```nextflow
process example {
package 'samtools=1.15 bcftools=1.15', provider: 'conda'

script:
"""
samtools --version
bcftools --version
"""
}
```

To enable the unified package system:

```groovy
// nextflow.config
nextflow.preview.package = true
```

The unified system provides:
- Consistent interface across different package managers
- Plugin-based architecture for extensibility
- Better integration with containerization platforms
- Support for multiple package managers (conda, pixi, etc.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we should be explicit about which package managers are supported. ideally also pak or install2.r for R

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Do you just want to support the package managers that wave supports?

I also thought this might be a nice abstraction for the core container directives, but I wanted to keep the scope tight.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. we should keep aligned with Wave


## Best practices

When a `conda` directive is used in any `process` definition within the workflow script, Conda tool is required for the workflow execution.
Expand Down
Loading
Loading