-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conditionals in Janis #5
Conversation
So that looks pretty useful. Is it only constrained to inputs or will it be possible to work on outputs such as stdout, return code, etc? |
This comment has been minimized.
This comment has been minimized.
Hey @evan-wehi, you could definitely use the outputs of tasks to drive the conditional logic, that would include stdout if you explicitly include this. The return code is a little trickier, in CWL v1.1 you're able to access the return code within an |
# Conflicts: # janis_core/types/selectors.py # janis_core/utils/__init__.py # janis_core/workflow/workflow.py
# Conflicts: # janis_core/types/selectors.py
# Conflicts: # janis_core/translations/wdl.py # janis_core/types/common_data_types.py
# Conflicts: # janis_core/translations/wdl.py # janis_core/types/common_data_types.py
# Conflicts: # janis_core/translations/cwl.py
They should've been breaking before...
# Conflicts: # janis_core/tests/test_translation_wdl.py # janis_core/translations/cwl.py # janis_core/translations/wdl.py # setup.py
# Conflicts: # janis_core/tests/test_translation_cwl.py
# Conflicts: # janis_core/graph/steptaginput.py # janis_core/tests/test_translation_cwl.py # janis_core/tests/test_translation_wdl.py # janis_core/translations/cwl.py # janis_core/translations/wdl.py # janis_core/workflow/workflow.py # setup.py
# Conflicts: # janis_core/tool/commandtool.py # janis_core/translations/cwl.py
This PR has been folded into #38, so see that for more information. |
Conditionals
Introducing "Conditionals" into Janis!
Essentially, we want to to decide at runtime whether to run a task (or not). This concept is based off how CWL, WDL and Nextflow's implementation of this feature. Essentially, we you can insert a
condition
into awhen
block, and if that condition is True at runtime, the step will execute.We'll also add some extra sugar for some basic workflow concepts, such as "if else".
This isn't a fully fleshed out spec yet, and may change without notice:
Basic concept
w.step
. The outputs become optional.Basic syntax
Conditional
Say you want to run an if, else if, else if block. Writing this by hand is a little complicated, and then you'd need to handle the merge yourself. Well, that's why we introduced the
workflow.conditional
. It allows you to write the equivalent statements, and Janis will take care of abstracting the logic.Handling dependencies
If a step includes some conditionality (through the when block), all of it's outputs are marked as optional. The inputs of these dependent tools should be optional (where appropriate), otherwise a typing error should occur.
A SkipIfNull operator should be introduced to ensure that an input to a tool is valid. This should interact with the type check to not throw error, but this might actually be difficult to determine.
We could potentially include a
skip_dependencies
param on the initial workflow, which adds askipIfNull
condition onto all future steps down the tree thatEarly exit
Proposing to add
Workflow.error
block, to early exit a workflow when a condition is met. It would be a commandlinetool with no outputs, so it couldn't be referenced anywhere.Handling multiple inputs
CWL introduces
pickValue
, where WDL would use theselect_all
andselect_first
library functions. The functionality can be mirrored:I propose we introduce the function
select_all
andselect_first
, this aligns well with the proposal to introduce the standard library functions, and this PR makes good groundwork through operators. Could be compared to miniWDL's std.Lib in how extensible it could be.CWL support
For CWL, we're modelling the behaviour off the most current PR for Conditionals (in CWL v1.2): common-workflow-language/cwl-v1.2#4.
As discussed, conditionals is only supported in v1.2 of CWL. I've been mostly mainting CWLGen, but due to the rise of CWLUtils #5, schema-salad has the functionality of generating Python classes that directly mirror the CWL spec. This means CWLGen can be deprecated, and we'll likely devise some "versioning" system for the translations, modelled off these new CWLUtils changes.
WDL support
WDL supports conditionality directly in version 1.0, (although we use the Development Biscayne spec). I've added
WorkflowConditional
to python-wdlgen in python-wdlgen/e656cc1.Similar to CWL, I'd really prefer to build an AST (like in MiniWDL) and let something pretty print this to a string. Relevant: