-
Notifications
You must be signed in to change notification settings - Fork 716
Type annotations #6278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Type annotations #6278
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,6 +8,51 @@ This page summarizes the upcoming changes in Nextflow 25.10, which will be relea | |||||
This page is a work in progress and will be updated as features are finalized. It should not be considered complete until the 25.10 release. | ||||||
::: | ||||||
|
||||||
## New features | ||||||
|
||||||
<h3>Type annotations</h3> | ||||||
|
||||||
Type annotations are a way to denote the *type* of a variable. They are useful both for documenting and validating your pipeline code. | ||||||
|
||||||
```nextflow | ||||||
workflow RNASEQ { | ||||||
take: | ||||||
reads: Channel<Path> | ||||||
index: Channel<Path> | ||||||
|
||||||
main: | ||||||
samples_ch = QUANT( reads.combine(index) ) | ||||||
|
||||||
emit: | ||||||
samples: Channel<Path> = samples_ch | ||||||
} | ||||||
|
||||||
def isSraId(id: String) -> Boolean { | ||||||
return id.startsWith('SRA') | ||||||
} | ||||||
``` | ||||||
|
||||||
The following declarations can be annotated with types: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
- Pipeline parameters (the `params` block) | ||||||
- Workflow takes and emits | ||||||
- Function parameters and returns | ||||||
- Local variables | ||||||
- Closure parameters | ||||||
- Workflow outputs (the `output` block) | ||||||
|
||||||
Type annotations can refer to any of the {ref}`standard types <stdlib-types>`. | ||||||
|
||||||
Type annotations can be appended with `?` to denote that the value can be `null`: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```nextflow | ||||||
def x_opt: String? = null | ||||||
``` | ||||||
|
||||||
:::{note} | ||||||
While Nextflow inherited type annotations of the form `<type> <name>` from Groovy, this syntax was deprecated in the {ref}`strict syntax <strict-syntax-page>`. Groovy-style type annotations are still allowed for functions and local variables, but will be automatically converted to Nextflow-stype type annotations when formatting code with the language server or `nextflow lint`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
::: | ||||||
|
||||||
## Breaking changes | ||||||
|
||||||
- The AWS Java SDK used by Nextflow was upgraded from v1 to v2, which introduced some breaking changes to the `aws.client` config options. See {ref}`the guide <aws-java-sdk-v2-page>` for details. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -655,7 +655,7 @@ hello | |||||
|
||||||
### Input tuples (`tuple`) | ||||||
|
||||||
The `tuple` qualifier allows you to group multiple values into a single input definition. It can be useful when a channel emits tuples of values that need to be handled separately. Each element in the tuple is associated with a corresponding element in the `tuple` definition. For example: | ||||||
The `tuple` qualifier allows you to group multiple values into a single input definition. It can be useful when a channel emits {ref}`tuples <script-tuples>` of values that need to be handled separately. Each element in the tuple is associated with a corresponding element in the `tuple` definition. For example: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```nextflow | ||||||
process cat { | ||||||
|
@@ -1056,7 +1056,7 @@ If the command fails, the task will also fail. In Bash, you can append `|| true` | |||||
|
||||||
### Output tuples (`tuple`) | ||||||
|
||||||
The `tuple` qualifier allows you to output multiple values in a single channel. It is useful when you need to associate outputs with metadata, for example: | ||||||
The `tuple` qualifier allows you to output multiple values in a single channel as a {ref}`tuple <script-tuples>`. It is useful when you need to associate outputs with metadata, for example: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```nextflow | ||||||
process blast { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.