Code not being found when using module binaries

Hi :wave:
I am trying to utilise the module binaries feature found Modules β€” Nextflow documentation.
I have added

nextflow.enable.moduleBinaries = true

to my config.
I have structured my module bin as per the above link.

module_name -> module.nf
            -> resources -> usr -> bin -> python_script1.py
                                       -> python_script2.py

and I am getting the error:

Command error:
  .command.sh: line 5: perform_SPRT_SMA_CAH_CF_RB1.py: command not found

and this is my script:

  script:
  """
    touch Description.DMD
    echo "Performing SPRT for ${meta.project_id}, disease is ${meta.description}, probeset is ${meta.probeset}" >> ${meta.project_id}_sprt.log
    perform_SPRT_SMA_CAH_CF_RB1.py -i ${workbook} -p ${meta.probeset} -d ${meta.description} -idx ${idxstats} -dup ${dup_metrics} -mf ${cf_gene_model_file} ${cah_gene_model_file_CYP21A1P} ${cah_gene_model_file_CYP21A2} ${rb1_gene_model_file} ${sma_gene_model_file_SMN1} ${sma_gene_model_file_SMN2} >> ${meta.project_id}_sprt.log
    """

This worked perfectly when my python scripts were in the overall workflow bin but is now failing when I’m trying to use the module bins. I really want this to work with module bins! Please help!
I have ensured all python scripts in the new location are linux executable and I have checked my version of nextflow is compatible (using nextflow:22.10.4). Does anybody have any idea why this is failing?

Where are you running this pipeline, i.e. what’s the executor? I’m asking because if it’s on the cloud, you’d need Wave enabled.

You’re running into this error probably because the Nextflow script file for the module must be named main.nf, instead of your module.nf. I find the same error when naming it module.nf, but when I name it main.nf, I don’t run into the error you mentioned anymore. See my minimal reproducible example below:

.
β”œβ”€β”€ main.nf
β”œβ”€β”€ modules
β”‚   └── hello_world
β”‚       β”œβ”€β”€ main.nf
β”‚       └── resources
β”‚           └── usr
β”‚               └── bin
β”‚                   └── hello.py
β”œβ”€β”€ nextflow.config

Content of the nextflow.config file:

nextflow.enable.moduleBinaries = true

Content of the main.nf file:

include { HELLO_WORLD } from './modules/hello_world/main.nf'

workflow {
  HELLO_WORLD()
}

Content of the main.nf file in the module:

process HELLO_WORLD {
  debug true

  output:
  stdout

  script:
  """
    hello.py
    """
}

Content of the hello.py file:

#!/usr/bin/env python
print('Hello World')

Output when running the pipeline with the version you specified:

NXF_VER=22.10.4 nextflow run main.nf
Nextflow 24.10.0 is available - Please consider updating your version to it
N E X T F L O W  ~  version 22.10.4
Launching `main.nf` [jovial_joliot] DSL2 - revision: e4ace67094
executor >  local (1)
[f2/9bc9e9] process > HELLO_WORLD [100%] 1 of 1 βœ”
Hello World