Skip to content
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

Use Channel instead of channel #5352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bentsherman
Copy link
Member

DSL2 introduced channel as an alias for Channel to create channel factories. I assume this was for consistency with other lower-case words like "process" and "workflow". However, Channel is a type like List or Map or Path, and the channel factories are static methods that create values of type Channel.

Technically, channels in Nextflow are of type DataflowReadChannel, but this is really an implementation detail. When we implement static types, we can provide an explicit Channel type to the user that does not expose such internal details To prepare for that, we should deprecate the use of channel before it gets any more widespread and causes confusion

@bentsherman bentsherman requested a review from a team as a code owner October 2, 2024 16:54
Copy link

netlify bot commented Oct 2, 2024

Deploy Preview for nextflow-docs-staging ready!

Name Link
🔨 Latest commit 302b7b5
🔍 Latest deploy log https://app.netlify.com/sites/nextflow-docs-staging/deploys/66fd7acff9034d000988f5bd
😎 Deploy Preview https://deploy-preview-5352--nextflow-docs-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -71,10 +71,6 @@ For example, the `Channel.of()` factory can be used to create a channel from an
Channel.of(1, 2, 3).view()
```

:::{versionadded} 20.07.0
`channel` was introduced as an alias of `Channel`, allowing factory methods to be specified as `channel.of()` or `Channel.of()`, and so on.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to completely remove reference to this? It's out there in the wild already..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could take it or leave it. the strict parser will recognize it and give a deprecation warning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Phil here that it's already out in the wild and will cause frustration if it's not documented why.

Maybe:

channel was introduced as an alias of Channel, allowing factory methods to be specified as channel.of() or Channel.of(), and so on. It is preferable to use Channel to maintain clarity and follow best practices. channel will be depreciated in the future.

Or something like that.

@pditommaso
Copy link
Member

Why this? actually the plane was to converge to channel.x over Channel.x

@bentsherman
Copy link
Member Author

actually the plan was to converge to channel.x over Channel.x

why?

@pditommaso
Copy link
Member

because the use of uppercase is a legacy of Java conventions, but there's no really reason in nextflow lang. I always found unnatural the need to capitalise channel

@bentsherman
Copy link
Member Author

bentsherman commented Oct 3, 2024

Uppercase is still needed to distinguish types from variable names. Otherwise it's difficult to tell which is which at a glance. This is not so important now but will become important when we add static types. So we need to prepare now

@pditommaso
Copy link
Member

Uppercase for types is a pure convention, above all as a nextflow developer I should not be exposed to Channel as type, that's an implementation details. It can be seen as an implicit variable or namespace identifier to access factory methods

@bentsherman
Copy link
Member Author

Users absolutely will be exposed to Channel as a type when we start supporting static types:

workflow foo {
  take:
  inputs: Channel<Path>
  param1: String
  param2: Integer
  flag1: Boolean

  main:
  // ...
}

Similarly when hovering over a variable, they will see something like Channel<T> in the tooltip

Therefore it makes most sense for the channel factories to be static methods of the Channel type, to make it clear that you are creating a channel

@bentsherman
Copy link
Member Author

Of course I agree that we shouldn't expose DataflowReadChannel / DataflowWriteChannel, as they provide many methods that aren't meant to be used like reading/writing individual items and GPars operators like chainWith

With static types, Channel would essentially be a handle that is passed around between factories and operators

@bentsherman bentsherman added this to the 24.10.0 milestone Oct 6, 2024
@bentsherman bentsherman removed this from the 24.10.0 milestone Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants