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

Allow conditional process execution from configuration #1393

Merged
merged 2 commits into from
Feb 4, 2022
Merged

Allow conditional process execution from configuration #1393

merged 2 commits into from
Feb 4, 2022

Conversation

mahesh-panchal
Copy link
Member

@mahesh-panchal mahesh-panchal commented Feb 3, 2022

Addition:
Allow modules to use when: block by moving it to configuration.

when:
task.ext.when == null || task.ext.when

Allows modules to flexibly use the when: from the configuration file.
Allows conditional process execution on settings not available in the workflow block.

Configuration is set using process.ext.when allowing one to use process selectors and other configuration benefits to
apply a when condition to a group of processes or test process specific values.

Execution conditions

process {
    withName: 'FOO' {
        ext.args = 'module1,module2'
        // Example settings
        ext.when = null                           // Process executes - no conditional defined. 
        ext.when = true                          // Process executes - e.g. override for existing configuration
        ext.when = !params.skip_module // Process executes if set, or if null 
        ext.when = ext.args.tokenize(',').contains('module1')  // Process does not execute - evaluated in configuration context.
        ext.when = { task.ext.args.tokenize(',').contains('module1') }  // Process does not execute - evaluated in task context.
    }
}

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

@mahesh-panchal
Copy link
Member Author

Bonus insight from @drpatelh: Allows one to skip mirroring conditional logic in the configuration file.

Copy link
Member

@JoseEspinosa JoseEspinosa left a comment

Choose a reason for hiding this comment

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

Really nice @mahesh-panchal , if with this we don't need to use all these ifs in the modules.config to avoid the warning regarding the process config selectors, we really owe you something 🙏

@mahesh-panchal
Copy link
Member Author

I already began a trial. It's not so simple.
https://github.com/mahesh-panchal/rnaseq/tree/when_trial
It requires rewriting logic in the rnaseq workflow here to get it to work.
Just updating modules.config and all the modules brings back the WARN's. One needs to remove all the if's and change some channel assignments to mixes and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants