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

Named arguments for processes and workflows #3712

Closed
wants to merge 1 commit into from

Conversation

bentsherman
Copy link
Member

Closes #2257 #3507

Adds a take option for process inputs that is similar to the emit option for outputs. Processes and workflows can now be invoked with named arguments, using the same syntax as native Groovy functions.

Additionally, you don't have to specify the take option in the input declaration if the process input has a simple name. For inputs with e.g. GStrings, closures, tuples, the take option must be explicit.

It works by interpreting the first process / workflow argument as the named arguments map if it is a map. We have to do this because the invocation happens through WorkflowBinding.invokeMethod() rather than an actual function definition. So there will be a problem if you call a process and the first argument is a map, but you meant for that argument to be for the first process input (i.e. as a value channel).

One way that we could avoid this problem is to refactor the NextflowDSL AST transformation to convert process and workflow definitions into actual function definitions, so that the process/workflow inputs are defined as native function arguments.

@bentsherman bentsherman requested a review from pditommaso March 2, 2023 22:05
@pditommaso pditommaso force-pushed the master branch 2 times, most recently from 0d59b4c to b93634e Compare March 11, 2023 11:20
@pditommaso pditommaso force-pushed the master branch 2 times, most recently from 81f7cb7 to 8a43489 Compare August 20, 2023 20:13
@bentsherman bentsherman changed the title Add named arguments for processes and workflows Named arguments for processes and workflows Sep 15, 2023
@bentsherman
Copy link
Member Author

bentsherman commented Apr 29, 2024

Gonna fold this one into #4553 doing something like this:

process foo {
  input:
    List<Path> inputs
    String args = ''
  output:
    stdout
  script:
    """
    foo_cmd ${args} ${inputs}
    """
}

workflow {
  // positional args
  foo( files('*.foo'), '--custom-option' )

  // named args
  foo( inputs: files('*.foo'), args: '--custom-option' )

  // mixing is not allowed
}

@bentsherman bentsherman deleted the 2257-process-named-inputs branch April 29, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support named channel inputs for processes and workflows
1 participant