Skip to content

Commit 2432e90

Browse files
committed
add documentation and tests
Signed-off-by: jorgee <jorge.ejarque@seqera.io>
1 parent 24a741f commit 2432e90

25 files changed

Lines changed: 2937 additions & 51 deletions

docs/cli.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,120 @@ $ nextflow secrets set AWS_ACCESS_KEY_ID
262262
$ nextflow secrets delete AWS_ACCESS_KEY_ID
263263
```
264264

265-
See {ref}`cli-secrets` for more information.
265+
See {ref}`cli-secrets` for more information.
266+
267+
## Module management
268+
269+
:::{versionadded} 26.04.0
270+
:::
271+
272+
Module management commands enable working with reusable, registry-based modules. The Nextflow module system allows you to install, run, search, and publish standardized modules from registries, eliminating duplicate work and spreading improvements throughout the community.
273+
274+
Use these commands to discover modules in registries, install them into your project, run them directly without creating a workflow, and publish your own modules for others to use.
275+
276+
### Installing modules
277+
278+
The `module install` command downloads modules from a registry and makes them available in your workflow. Modules are stored locally in the `modules/` directory and version information is tracked in `nextflow_spec.json`.
279+
280+
Use this to add reusable modules to your pipeline, manage module versions, or update modules to newer versions.
281+
282+
```console
283+
$ nextflow module install nf-core/fastqc
284+
$ nextflow module install nf-core/fastqc -version 1.0.0
285+
```
286+
287+
After installation, module will be available in `modules/@nf-core/fastqc` and included in `nextflow_spec.json`
288+
289+
Use the `-force` flag to reinstall a module even if local modifications exist.
290+
291+
See {ref}`cli-module-install` for more information.
292+
293+
### Running modules directly
294+
295+
The `module run` command executes a module directly from the registry without requiring a wrapper workflow. This provides immediate access to module functionality for ad-hoc tasks or testing.
296+
297+
Use this to quickly run a module, test module functionality, or execute one-off data processing tasks.
298+
299+
```console
300+
$ nextflow module run nf-core/fastqc --input 'data/*.fastq.gz'
301+
$ nextflow module run nf-core/fastqc --input 'data/*.fastq.gz' -version 1.0.0
302+
```
303+
304+
The command accepts all standard Nextflow execution options (`-profile`, `-resume`, etc.):
305+
306+
```console
307+
$ nextflow module run nf-core/salmon \
308+
--reads reads.fq \
309+
--index salmon_index \
310+
-profile docker \
311+
-resume
312+
```
313+
314+
See {ref}`cli-module-run` for more information.
315+
316+
### Listing modules
317+
318+
The `module list` command displays all modules currently installed in your project, showing their versions and integrity status.
319+
320+
Use this to review installed modules, check module versions, or detect local modifications.
321+
322+
```console
323+
$ nextflow module list
324+
$ nextflow module list -json
325+
```
326+
327+
The output shows each module's name, installed version, and whether it has been modified locally. Use `-json` for machine-readable output suitable for scripting.
328+
329+
See {ref}`cli-module-list` for more information.
330+
331+
### Searching for modules
332+
333+
The `module search` command queries the module registry to discover available modules by keyword or name.
334+
335+
Use this to find modules for specific tasks, explore available tools, or discover community contributions.
336+
337+
```console
338+
$ nextflow module search alignment
339+
$ nextflow module search "quality control" -limit 10
340+
$ nextflow module search bwa -json
341+
```
342+
343+
Results include module names, versions, descriptions, and download statistics. Use `-limit` to control the number of results and `-json` for programmatic access.
344+
345+
See {ref}`cli-module-search` for more information.
346+
347+
### Removing modules
348+
349+
The `module remove` command deletes modules from your project, removing local files and configuration entries.
350+
351+
Use this to clean up unused modules, free disk space, or remove deprecated modules from your pipeline.
352+
353+
```console
354+
$ nextflow module remove nf-core/fastqc
355+
$ nextflow module remove nf-core/fastqc -keep-config
356+
$ nextflow module remove nf-core/fastqc -keep-files
357+
```
358+
359+
By default, both local files and configuration entries are removed. Use `-keep-config` to preserve version information in `nextflow_spec.json`, or `-keep-files` to remove only the configuration entry while keeping local files.
360+
361+
See {ref}`cli-module-remove` for more information.
362+
363+
### Publishing modules
364+
365+
The `module publish` command uploads modules to a registry, making them available for others to install and use.
366+
367+
Use this to share your modules with the community, contribute to module libraries, or distribute modules within your organization.
368+
369+
```console
370+
$ nextflow module publish myorg/my-module
371+
$ nextflow module publish myorg/my-module -dry-run
372+
```
373+
374+
Publishing requires authentication via the `NXF_REGISTRY_TOKEN` environment variable or `registry.auth` in the Nextflow configuration. The module must include `main.nf`, `meta.yaml`, and `README.md` files.
375+
376+
Use `-dry-run` to validate your module structure without uploading.
377+
378+
See {ref}`cli-module-publish` for more information.
266379

267380
## Configuration and validation
268381

docs/reference/cli.md

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,187 @@ $ nextflow log tiny_leavitt -F 'process =~ /split_letters/'
11251125
work/1f/f1ea9158fb23b53d5083953121d6b6
11261126
```
11271127

1128+
(cli-module)=
1129+
1130+
### `module`
1131+
1132+
:::{versionadded} 26.04.0
1133+
:::
1134+
1135+
Manage Nextflow modules from registries.
1136+
1137+
**Usage**
1138+
1139+
```console
1140+
$ nextflow module <subcommand> [options]
1141+
```
1142+
1143+
**Description**
1144+
1145+
The `module` command provides a comprehensive system for managing reusable, registry-based modules. It enables installing modules from registries, running them directly, searching for available modules, and publishing your own modules for community use.
1146+
1147+
**Subcommands**
1148+
1149+
(cli-module-install)=
1150+
1151+
`install [options] [scope/name]`
1152+
1153+
: Install a module from the registry into your project.
1154+
: Downloaded modules are stored in the `modules/` directory and version information is tracked in `nextflow_spec.json`.
1155+
: The following options are available:
1156+
1157+
`-version`
1158+
: Specify the module version to install (e.g., `1.0.0`). If not specified, installs the latest version.
1159+
1160+
`-force`
1161+
: Force reinstall even if the module exists locally with modifications. Without this flag, Nextflow prevents overwriting locally modified modules.
1162+
1163+
: **Examples:**
1164+
1165+
```console
1166+
# Install latest version
1167+
$ nextflow module install nf-core/fastqc
1168+
1169+
# Install specific version
1170+
$ nextflow module install nf-core/fastqc -version 1.0.0
1171+
1172+
# Force reinstall over local modifications
1173+
$ nextflow module install nf-core/fastqc -force
1174+
```
1175+
1176+
(cli-module-run)=
1177+
1178+
`run [options] [scope/name] [--<input_name> <input-value>]`
1179+
1180+
: Execute a module directly from the registry without creating a wrapper workflow.
1181+
: Automatically downloads the module if not already installed. Accepts all standard Nextflow run options.
1182+
: The following options are available:
1183+
1184+
`-version`
1185+
: Specify the module version to run (e.g., `1.0.0`). If not specified, uses the latest version.
1186+
1187+
All standard `run` command options
1188+
: The `module run` command extends the `run` command and accepts all its options, including `-profile`, `-resume`, `-c`, etc.
1189+
1190+
: **Examples:**
1191+
1192+
```console
1193+
# Run module with inputs
1194+
$ nextflow module run nf-core/fastqc --input 'data/*.fastq.gz'
1195+
1196+
# Run specific version with Nextflow options
1197+
$ nextflow module run nf-core/fastqc \
1198+
--input 'data/*.fastq.gz' \
1199+
-version 1.0.0 \
1200+
-profile docker \
1201+
-resume
1202+
```
1203+
1204+
(cli-module-list)=
1205+
1206+
`list [options]`
1207+
1208+
: List all modules currently installed in your project.
1209+
: Shows module names, versions, and integrity status (whether they've been modified locally).
1210+
: The following options are available:
1211+
1212+
`-json`
1213+
: Output results in JSON format for programmatic processing.
1214+
1215+
: **Examples:**
1216+
1217+
```console
1218+
# Display installed modules in formatted table
1219+
$ nextflow module list
1220+
1221+
# Output as JSON
1222+
$ nextflow module list -json
1223+
```
1224+
1225+
(cli-module-search)=
1226+
1227+
`search [options] [query]`
1228+
1229+
: Search for modules in the registry by keyword or name.
1230+
: Returns modules matching the query with their names, versions, descriptions, and download statistics.
1231+
: The following options are available:
1232+
1233+
`-limit`
1234+
: Maximum number of results to return (default: varies by registry).
1235+
1236+
`-json`
1237+
: Output results in JSON format for programmatic processing.
1238+
1239+
: **Examples:**
1240+
1241+
```console
1242+
# Search for alignment-related modules
1243+
$ nextflow module search alignment
1244+
1245+
# Search with limited results
1246+
$ nextflow module search "quality control" -limit 10
1247+
1248+
# Get results as JSON
1249+
$ nextflow module search bwa -json
1250+
```
1251+
1252+
(cli-module-remove)=
1253+
1254+
`remove [options] [scope/name]`
1255+
1256+
: Remove a module from your project.
1257+
: By default, removes both local files and configuration entries. Use options to control what gets removed.
1258+
: The following options are available:
1259+
1260+
`-keep-config`
1261+
: Keep the version entry in `nextflow_spec.json` but delete local files from the `modules/` directory.
1262+
1263+
`-keep-files`
1264+
: Remove the version entry from `nextflow_spec.json` but keep local files in the `modules/` directory.
1265+
1266+
: **Examples:**
1267+
1268+
```console
1269+
# Remove module completely
1270+
$ nextflow module remove nf-core/fastqc
1271+
1272+
# Delete files but keep version config
1273+
$ nextflow module remove nf-core/fastqc -keep-config
1274+
1275+
# Remove from config but keep local files
1276+
$ nextflow module remove nf-core/fastqc -keep-files
1277+
```
1278+
1279+
(cli-module-publish)=
1280+
1281+
`publish [options] [scope/name]`
1282+
1283+
: Publish a module to the registry, making it available for others to install.
1284+
: Requires authentication via `NXF_REGISTRY_TOKEN` environment variable or `registry.auth` configuration.
1285+
: The module directory must contain `main.nf`, `meta.yaml`, and `README.md`.
1286+
: The following options are available:
1287+
1288+
`-dry-run`
1289+
: Validate the module structure and metadata without uploading to the registry. Useful for testing before publishing.
1290+
1291+
`-registry`
1292+
: Specify the registry to publish the module (default: `https://registry.nextflow.io`)
1293+
1294+
: **Examples:**
1295+
1296+
```console
1297+
# Validate module structure without publishing
1298+
$ nextflow module publish myorg/my-module -dry-run
1299+
1300+
# Publish to nextflow registry
1301+
$ export NXF_REGISTRY_TOKEN=your-token
1302+
$ nextflow module publish myorg/my-module
1303+
1304+
# Publish to a custom registry
1305+
$ export NXF_REGISTRY_TOKEN=your-token
1306+
$ nextflow module publish myorg/my-module -registry 'https://custom.registry.com'
1307+
```
1308+
11281309
(cli-plugin)=
11291310

11301311
### `plugin`

modules/nextflow/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ dependencies {
5555
api 'io.seqera:lib-trace:0.1.0'
5656
api 'com.fasterxml.woodstox:woodstox-core:7.1.1'
5757
api 'org.apache.commons:commons-compress:1.27.1' // For tar.gz extraction
58+
api 'io.seqera:npr-api:0.20.1'
5859

5960
testImplementation 'org.subethamail:subethasmtp:3.1.7'
6061
testImplementation (project(':nf-lineage'))
62+
testImplementation 'org.wiremock:wiremock:3.13.1'
6163
// test configuration
6264
testFixturesApi ("org.apache.groovy:groovy-test:4.0.30") { exclude group: 'org.apache.groovy' }
6365
testFixturesApi ("org.objenesis:objenesis:3.4")

modules/nextflow/src/main/groovy/nextflow/cli/module/ModuleInstall.groovy

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ import nextflow.config.ModulesConfig
2626
import nextflow.config.RegistryConfig
2727
import nextflow.exception.AbortOperationException
2828
import nextflow.module.ModuleReference
29+
import nextflow.module.ModuleRegistryClient
2930
import nextflow.module.ModuleResolver
3031
import nextflow.pipeline.PipelineSpec
32+
import nextflow.util.TestOnly
3133

34+
import java.nio.file.Path
3235
import java.nio.file.Paths
3336

3437
/**
@@ -50,6 +53,12 @@ class ModuleInstall extends CmdBase {
5053
@Parameter(description = "[scope/name]", required = true)
5154
List<String> args
5255

56+
@TestOnly
57+
protected Path root
58+
59+
@TestOnly
60+
protected ModuleRegistryClient client
61+
5362
@Override
5463
String getName() {
5564
return 'install'
@@ -66,21 +75,19 @@ class ModuleInstall extends CmdBase {
6675
def reference = ModuleReference.parse(moduleRef)
6776

6877
// Get config
69-
def baseDir = Paths.get('.').toAbsolutePath().normalize()
78+
def baseDir = root ?: Paths.get('.').toAbsolutePath().normalize()
7079
def config = new ConfigBuilder()
7180
.setOptions(launcher.options)
7281
.setBaseDir(baseDir)
7382
.build()
74-
def registryConfig = config.navigate('registry') as RegistryConfig
83+
final registryConfig = config.navigate('registry') as RegistryConfig
7584

76-
//TODO: Decide final location of modules currently in nextflow_spec.json.
77-
// Alternative: Use nextflow config. It requires to implement nextflow.config updater features
78-
// def modulesConfig = config.navigate('modules') as ModulesConfig
79-
def specFile = new PipelineSpec(baseDir)
80-
def modulesConfig = new ModulesConfig(specFile.getModules())
85+
// Get modules versions from nextflow_spec.json.
86+
final specFile = new PipelineSpec(baseDir)
87+
final modulesConfig = new ModulesConfig(specFile.getModules())
8188

8289
// Create resolver and install
83-
def resolver = new ModuleResolver(baseDir, modulesConfig, registryConfig)
90+
def resolver = new ModuleResolver(baseDir, client ?: new ModuleRegistryClient(registryConfig), modulesConfig)
8491

8592
try {
8693
def installedMainFile = resolver.installModule(reference, version, force)

0 commit comments

Comments
 (0)