nextflow-io / nextflow-io/nextflow
Provide a special class for pipeline-defined error messages
Nobody has claimed this yet.
- Dominant language
- Groovy
- Stars
- 3.5k
- Forks
- 811
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 61
Description
New feature
It would be nice to have a special error class or function for pipeline-level errors or warnings, that help distinguish pipeline-defined (conditional) errors versus Nextflow level errors
Usage scenario
Pipelines will often have their own checks or validations, for example mutually exclusive parameters, that they will want to report to a user. Currently it is expected that a pipeline uses error("error message") to report this.
Often these are 'simple' errors, compared to Nextflow errors that have a more technical reason for the problem.
It might nice to be able to distinguish such pipeline-level errors from Nextflow errors. One benefit would be that it makes it much faster to identify where the error is coming from for developers, so they can quickly guide a user to a solution (i.e., whether it's a simple fix, or something the developer needs to investigate deeper.
Currently I do this manually by adding a prefix to warnings or logs, but it could be nice to have this happen automatically. Furthermore the way to report an error vs warning is slightly different (to my understanding anyway).
e.g. to report an error I do the following with the pipeline name as a prefix:
if (params.shortread_qc_includeunmerged && !params.shortread_qc_mergepairs) error("ERROR: [nf-core/taxprofiler] cannot include unmerged reads when merging is not turned on. Please specify --shortread_qc_mergepairs")
vs a warning
if (params.diamond_save_reads ) log.warn "[nf-core/taxprofiler] DIAMOND only allows output of a single format. As --diamond_save_reads supplied, only aligned reads in SAM format will be produced, no taxonomic profiles will be available."
Where I have to manually specify ERROR: in when using error(), but the log.warn() autmatically puts WARN at the beginning. I guess there is a log.error but my understanding this doesn't cause the pipeline run to exit 'nicely'.
Suggest implementation
Could be nice to have something a native pipelineError("") - thing the prefixes the workflow name at the beginning etc.
It could also have a distinct colour from a Nextflow level error.
More info
I initially brought this up for discussion with nf-core (in particular @ewels and @maxulysse) here: https://nfcore.slack.com/archives/C04QR0T3G3H/p1713533132261319 based on the suggestion from @Midnighter here: https://github.com/nf-core/taxprofiler/pull/60#discussion_r852845213.
All three may be able to provide better (technical) suggestions and/or benefits.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing error() and log.warn entry points and compare how pipeline-defined messages and Nextflow-level errors are currently displayed. Define the desired behavior for a native pipelineError-style mechanism, including error termination, warning output, workflow-name prefixes, and any distinct coloring; the issue is done when these behaviors are specified and covered by appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100