cwl_utils.cwl_v1_2_expression_refactor
======================================
.. py:module:: cwl_utils.cwl_v1_2_expression_refactor
.. autoapi-nested-parse::
CWL Expression refactoring tool for CWL v1.2 .
Attributes
----------
.. autoapisummary::
cwl_utils.cwl_v1_2_expression_refactor.EMPTY_FILE
cwl_utils.cwl_v1_2_expression_refactor.TOPLEVEL_SF_EXPR_ERROR
cwl_utils.cwl_v1_2_expression_refactor.TOPLEVEL_FORMAT_EXPR_ERROR
cwl_utils.cwl_v1_2_expression_refactor.PICKVALUE_FIRST_NON_NULL_EXPR
cwl_utils.cwl_v1_2_expression_refactor.PICKVALUE_THE_ONLY_NON_NULL_EXPR
cwl_utils.cwl_v1_2_expression_refactor.PICKVALUE_ALL_NON_NULL_EXPR
cwl_utils.cwl_v1_2_expression_refactor.PICKVALUE_ERROR
Functions
---------
.. autoapisummary::
cwl_utils.cwl_v1_2_expression_refactor.expand_stream_shortcuts
cwl_utils.cwl_v1_2_expression_refactor.escape_expression_field
cwl_utils.cwl_v1_2_expression_refactor.clean_type_ids
cwl_utils.cwl_v1_2_expression_refactor.get_expression
cwl_utils.cwl_v1_2_expression_refactor.etool_to_cltool
cwl_utils.cwl_v1_2_expression_refactor.traverse
cwl_utils.cwl_v1_2_expression_refactor.load_step
cwl_utils.cwl_v1_2_expression_refactor.generate_etool_from_expr
cwl_utils.cwl_v1_2_expression_refactor.get_input_for_id
cwl_utils.cwl_v1_2_expression_refactor.find_expressionLib
cwl_utils.cwl_v1_2_expression_refactor.replace_expr_with_etool
cwl_utils.cwl_v1_2_expression_refactor.replace_wf_input_ref_with_step_output
cwl_utils.cwl_v1_2_expression_refactor.empty_inputs
cwl_utils.cwl_v1_2_expression_refactor.example_input
cwl_utils.cwl_v1_2_expression_refactor.process_workflow_inputs_and_outputs
cwl_utils.cwl_v1_2_expression_refactor.process_workflow_reqs_and_hints
cwl_utils.cwl_v1_2_expression_refactor.process_level_reqs
cwl_utils.cwl_v1_2_expression_refactor.add_input_to_process
cwl_utils.cwl_v1_2_expression_refactor.traverse_CommandLineTool
cwl_utils.cwl_v1_2_expression_refactor.rename_step_source
cwl_utils.cwl_v1_2_expression_refactor.remove_JSReq
cwl_utils.cwl_v1_2_expression_refactor.replace_step_clt_expr_with_etool
cwl_utils.cwl_v1_2_expression_refactor.replace_clt_hintreq_expr_with_etool
cwl_utils.cwl_v1_2_expression_refactor.cltool_inputs_to_etool_inputs
cwl_utils.cwl_v1_2_expression_refactor.cltool_step_outputs_to_workflow_outputs
cwl_utils.cwl_v1_2_expression_refactor.generate_etool_from_expr2
cwl_utils.cwl_v1_2_expression_refactor.traverse_step
cwl_utils.cwl_v1_2_expression_refactor.workflow_step_to_WorkflowInputParameters
cwl_utils.cwl_v1_2_expression_refactor.replace_step_valueFrom_expr_with_etool
cwl_utils.cwl_v1_2_expression_refactor.replace_step_when_expr_with_etool
cwl_utils.cwl_v1_2_expression_refactor.traverse_workflow
Module Contents
---------------
.. py:function:: expand_stream_shortcuts(process)
Rewrite the "type: stdout" shortcut to use an explicit random filename.
.. py:function:: escape_expression_field(contents)
Escape sequences similar to CWL expressions or param references.
.. py:function:: clean_type_ids(cwltype)
Simplify type identifiers.
.. py:function:: get_expression(string, inputs, self)
Find and return a normalized CWL expression, if any.
CWL expressions in the $() form are converted to the ${} form.
.. py:function:: etool_to_cltool(etool, expressionLib = None)
Convert a ExpressionTool to a CommandLineTool.
.. py:function:: traverse(process, replace_etool, inside, skip_command_line1, skip_command_line2)
Convert the given process and any subprocesses.
.. py:function:: load_step(step, replace_etool, skip_command_line1, skip_command_line2)
If the step's Process is not inline, load and process it.
.. py:function:: generate_etool_from_expr(expr, target, no_inputs = False, self_type = None, extra_processes = None)
Convert a CWL Expression into an ExpressionTool.
.. py:function:: get_input_for_id(name, tool)
Determine the CommandInputParameter for the given input name.
.. py:function:: find_expressionLib(processes)
Return the expressionLib from the highest priority InlineJavascriptRequirement.
processes: should be in order of least important to most important
(Workflow, WorkflowStep, ... CommandLineTool/ExpressionTool)
.. py:function:: replace_expr_with_etool(expr, name, workflow, target, source, replace_etool = False, extra_process = None, source_type = None)
Modify the given workflow, replacing the expr with an standalone ExpressionTool.
.. py:function:: replace_wf_input_ref_with_step_output(workflow, name, target)
Refactor all reference to a workflow input to the specified step output.
.. py:function:: empty_inputs(process_or_step, parent = None)
Produce a mock input object for the given inputs.
.. py:function:: example_input(some_type)
Produce a fake input for the given type.
.. py:data:: EMPTY_FILE
.. py:data:: TOPLEVEL_SF_EXPR_ERROR
:value: "Input '{}'. Sorry, CWL Expressions as part of a secondaryFiles specification in a Workflow...
.. py:data:: TOPLEVEL_FORMAT_EXPR_ERROR
:value: "Input '{}'. Sorry, CWL Expressions as part of a format specification in a Workflow level input...
.. py:data:: PICKVALUE_FIRST_NON_NULL_EXPR
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""${
for (let i = 0; i < self.length; i++) {
if (self[i] !== null){
return self[i];
}
}
throw 'pickValue=first_non_null, but no non-null value found: ' + self;
}
"""
.. raw:: html
.. py:data:: PICKVALUE_THE_ONLY_NON_NULL_EXPR
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""${
var found = null;
self.forEach(function(item) {
if (item !== null) {
if (found !== null) {
throw 'pickValue=the_only_non_null, but multiple non-null values found: ' + self;
} else {
found = item;
}
}
})
if (found !== null) {
return found;
}
throw 'pickValue=the_only_non_null, but no non-null value found: ' + self;
}
"""
.. raw:: html
.. py:data:: PICKVALUE_ALL_NON_NULL_EXPR
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""${
var results = [];
self.forEach(function(item) {
if (item !== null){
results.push(item);
}
})
return results;
}
"""
.. raw:: html
.. py:data:: PICKVALUE_ERROR
:value: "pickValue '{}' is invalid. Should be one of 'first_non_null', 'the_only_non_null', 'all_non_null'"
.. py:function:: process_workflow_inputs_and_outputs(workflow, replace_etool)
Do any needed conversions on the given Workflow's inputs and outputs.
.. py:function:: process_workflow_reqs_and_hints(workflow, replace_etool)
Convert any expressions in a workflow's reqs and hints.
Each expression will be converted to an additional step.
The converted requirement will be copied to all workflow steps that don't have that
requirement type. Those affected steps will gain an additional input from the relevant
synthesized expression step.
.. py:function:: process_level_reqs(process, step, parent, replace_etool, skip_command_line1, skip_command_line2)
Convert expressions inside a process into new adjacent steps.
.. py:function:: add_input_to_process(process, name, inptype, loadingOptions)
Add a new InputParameter to the given CommandLineTool.
.. py:function:: traverse_CommandLineTool(clt, parent, step, replace_etool, skip_command_line1, skip_command_line2)
Extract any CWL Expressions within the given CommandLineTool into sibling steps.
.. py:function:: rename_step_source(workflow, old, new)
Update step source names to the new name.
.. py:function:: remove_JSReq(process, skip_command_line1)
Since the InlineJavascriptRequirement is longer needed, remove it.
.. py:function:: replace_step_clt_expr_with_etool(expr, name, workflow, target, step, replace_etool, self_name = None)
Convert a step level CWL Expression to a sibling expression step.
.. py:function:: replace_clt_hintreq_expr_with_etool(expr, name, workflow, target, step, replace_etool, self_name = None)
Factor out an expression inside a CommandLineTool req or hint into a sibling step.
.. py:function:: cltool_inputs_to_etool_inputs(tool)
Copy CommandLineTool input objects into the equivalent ExpressionTool input objects.
.. py:function:: cltool_step_outputs_to_workflow_outputs(cltool_step, etool_step_id, etool_out_id)
Copy CommandLineTool outputs into the equivalent Workflow output parameters.
Connects the outputSources for each of the new output parameters to the step
they came from.
.. py:function:: generate_etool_from_expr2(expr, target, inputs, self_name = None, process = None, extra_processes = None)
Generate an ExpressionTool to achieve the same result as the given expression.
.. py:function:: traverse_step(step, parent, replace_etool, skip_command_line1, skip_command_line2)
Process the given WorkflowStep.
.. py:function:: workflow_step_to_WorkflowInputParameters(step_ins, parent, except_in_id)
Create WorkflowInputParameters to match the given WorkflowStep inputs.
.. py:function:: replace_step_valueFrom_expr_with_etool(expr, name, workflow, target, step, step_inp, original_process, original_step_ins, source, replace_etool, source_type = None)
Replace a WorkflowStep level 'valueFrom' expression with a sibling ExpressionTool step.
.. py:function:: replace_step_when_expr_with_etool(expr, workflow, step, original_step_ins, replace_etool)
Replace a WorkflowStep level 'when' expression with a sibling ExpressionTool step.
.. py:function:: traverse_workflow(workflow, replace_etool, skip_command_line1, skip_command_line2)
Traverse a workflow, processing each step.