-
Notifications
You must be signed in to change notification settings - Fork 655
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
DSL2 - emit tuples with optional values #2678
Comments
closes #2678 Signed-off-by: Jorge Aguilera <jorge.aguilera@seqera.io>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Out of curiosity, is this issue still being worked on? Is it already possible to have an nullable optional output? Thanks! 🙇 |
Hi @rcannood , we've gone through a few sketches since you first submitted the issue. I think we ran into some tricky limitations under the hood that require more fundamental improvements to support nullable values properly. You can see the current state of development here: #4553 . Even this PR is likely not how it will look in the end, but it can give you an idea of where we are heading. Basically, instead of trying to patch the nullable option into the current syntax, we are working on a broader "static type" syntax that should also cover nullable values. Thanks for your patience in the meantime. It ended up being a deeper rabbit hole than we thought 😅 |
Thanks for the update @bentsherman ! Looking forward to static types :) |
Usage scenario
I'd like to be able to return a tuple with optional elements. For example, by defining the output as
tuple val(id), path("output.txt"), path("output2.txt" optional: true)
, I'd like a process to be able to emit an event["foo", path("output.txt"), null]
.The process and downstream processes can take a while to run, so using a multi-channel output in combination with a groupTuple() (See Attempt 3) is very undesirable.
Suggested implementation
Probably this would require:
Reproducible examples
I made several attempts at getting this to run with the current implementation of Nextflow. To summarise:
Attempt 1: optional path in tuple
Because of TupleOutParam.groovy#L103-L105, this optional value is overridden by the tuple's value for 'optional', namely false.
If I try to run the code following code, Nextflow will produce an error when output2.txt is missing.
Attempt 1 reprex
↓
Attempt 2: make the whole tuple optional
By making the whole tuple optional, Nextflow doesn't produce an error anymore, but my whole tuple is removed, which is undesirable.
Attempt 2 reprex
↓
Attempt 3: multichannel output
This approach is what is proposed in #1980. However, having to use 'groupTuple()' to merge the multichannel output back into a single event is also undesirable, as now the whole Channel needs to be executed before any events can be emitted downstream. Note that setting
size: 2
doesn't work in this case, since some tuples should have one element, others two.Attempt 3 reprex
↓
Attempt 4: add junk to output
By adding a file known to exist (e.g. ".command.sh") to the output, I can force the Channel to always return a tuple. This works, but the code looks quite messy and I need to do postprocessing to remove the additional file.
Attempt 4 reprex
↓
The text was updated successfully, but these errors were encountered: