Skip to content

CELLPOSE process fails on AWS Batch when not selected in segmentation parameter #140

@adamjtaylor

Description

@adamjtaylor

Description

When running the pipeline on AWS Batch (via Seqera Platform), the CELLPOSE process fails with Path value cannot be null even when segmentation is set to only use other segmenters (e.g., mccellpose).

The pipeline works correctly when run locally.

Steps to Reproduce

  1. Run the pipeline on AWS Batch with:
    --segmentation mccellpose
    
  2. Do not set --cellpose_model

Error

Feb-03 15:16:11.793 [Actor Thread 10] DEBUG nextflow.processor.TaskProcessor - Handling unexpected condition for
  task: name=NFCORE_MCMICRO:MCMICRO:CELLPOSE (1); work-dir=null
  error [nextflow.exception.ProcessUnrecoverableException]: Path value cannot be null

Root Cause

The workflow unconditionally pipes ch_segmentation_input to all segmentation processes (DEEPCELL_MESMER, CELLPOSE, MCCELLPOSE), relying on ext.when directives in conf/modules.config to skip execution:

// workflows/mcmicro.nf lines 141-148
ch_segmentation_input
    .multiMap{ meta, image ->
        image: [meta + [segmenter: 'cellpose'], image]
        model: params.cellpose_model  // defaults to [] in nextflow.config
    }
    | CELLPOSE

The ext.when conditions are correctly configured:

// conf/modules.config
ext.when = {params.segmentation && params.segmentation.split(',').contains('cellpose')}

However, AWS Batch executor validates and stages inputs before evaluating the when directive. Since params.cellpose_model defaults to [], the path validation fails before ext.when can skip the task.

This doesn't occur locally because the local executor handles path resolution more lazily.

Suggested Fix

Filter channels based on params.segmentation before piping to each process, rather than relying solely on ext.when:

if (params.segmentation?.split(',')?.contains('cellpose')) {
    ch_segmentation_input
        .multiMap{ meta, image ->
            image: [meta + [segmenter: 'cellpose'], image]
            model: params.cellpose_model
        }
        | CELLPOSE
    ch_masks = ch_masks.mix(CELLPOSE.out.mask)
    ch_versions = ch_versions.mix(CELLPOSE.out.versions)
}

This should be applied to all segmentation processes (DEEPCELL_MESMER, CELLPOSE, MCCELLPOSE).

Environment

  • Nextflow version: 25.10.2
  • Execution platform: AWS Batch via Seqera Platform
  • Pipeline version: 2.0.0 (commit 044dcca)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions