Skip to content

optional parameter for secret directive #5243

@nick-youngblut

Description

@nick-youngblut

New feature

I want to run an optional process only if the user has provided a secret. Example code:

workflow SUMMARY_WF { 
    main:
    OPTIONAL_PROCESS()
}

process OPTIONAL_PROCESS {
    secret "API_KEY"
  
    output:
    path "output/"

    script:
    """
    run_job.py
    """
}

Currently, if the user has not set the secret for OPTIONAL_PROCESS, the pipeline dies with the following error:

ERROR ~ Error executing process > 'SUMMARY_WF:OPTIONAL_PROCESS (1)'

Caused by:
  Required secret is missing: 'API_KEY'

As far as I can tell from the Nextflow docs, the secret: directive does not include an optional parameter.

Usage scenario

To allow secrets to be optional instead of required. If the secret is not set for the target process, then the environmental variable is empty, and the pipeline developer can thus include a check for the env variable in their code (e.g., if os.getenv("API_KEY") is None:).

Suggest implementation

Add an optional parameter to the secrets: directive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions