Loading lib/galaxy/workflow/modules.py +69 −63 Original line number Diff line number Diff line Loading @@ -122,22 +122,7 @@ class ConditionalStepWhen(BooleanToolParameter): pass def evaluate_value_from_expressions(progress, step, execution_state, extra_step_state): when_expression = step.when_expression value_from_expressions = {} if execution_state: for key in execution_state.inputs.keys(): step_input = step.inputs_by_name.get(key) if step_input and step_input.value_from is not None: value_from_expressions[key] = step_input.value_from if not value_from_expressions and when_expression is None: return {} hda_references = [] def to_cwl(value): def to_cwl(value, hda_references, step): element_identifier = None if isinstance(value, model.DatasetCollectionElement) and value.hda: element_identifier = value.element_identifier Loading Loading @@ -171,17 +156,22 @@ def evaluate_value_from_expressions(progress, step, execution_state, extra_step_ elif hasattr(value, "collection"): collection = value.collection if collection.collection_type == "list": return [to_cwl(dce) for dce in collection.dataset_elements] return [to_cwl(dce, hda_references=hda_references, step=step) for dce in collection.dataset_elements] else: # Could be record or nested lists rval = {} for element in collection.elements: rval[element.element_identifier] = to_cwl(element.element_object) rval[element.element_identifier] = to_cwl( element.element_object, hda_references=hda_references, step=step ) return rval elif isinstance(value, list): return [to_cwl(v, hda_references=hda_references, step=step) for v in value] else: return value def from_cwl(value): def from_cwl(value, hda_references, progress): # TODO: turn actual files into HDAs here ... somehow I suppose. Things with # file:// locations for instance. if isinstance(value, dict) and "class" in value and "location" in value: Loading @@ -196,12 +186,28 @@ def evaluate_value_from_expressions(progress, step, execution_state, extra_step_ else: return value def evaluate_value_from_expressions(progress, step, execution_state, extra_step_state): when_expression = step.when_expression value_from_expressions = {} if execution_state: for key in execution_state.inputs.keys(): step_input = step.inputs_by_name.get(key) if step_input and step_input.value_from is not None: value_from_expressions[key] = step_input.value_from if not value_from_expressions and when_expression is None: return {} hda_references: List[model.HistoryDatasetAssociation] = [] step_state = {} for key, value in extra_step_state.items(): step_state[key] = to_cwl(value) step_state[key] = to_cwl(value, hda_references=hda_references, step=step) if execution_state: for key, value in execution_state.inputs.items(): step_state[key] = to_cwl(value) step_state[key] = to_cwl(value, hda_references=hda_references, step=step) if when_expression is not None: if when_expression == "${inputs.when}": Loading Loading @@ -229,7 +235,7 @@ def evaluate_value_from_expressions(progress, step, execution_state, extra_step_ reason=FailureReason.expression_evaluation_failed, workflow_step_id=step.id ) ) when_value = from_cwl(as_cwl_value) when_value = from_cwl(as_cwl_value, hda_references=hda_references, progress=progress) if not isinstance(when_value, bool): raise FailWorkflowEvaluation( InvocationFailureWhenNotBoolean( Loading test/unit/workflows/test_modules.py +12 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,18 @@ def test_subworkflow_new_outputs(): assert output2["name"] == "4:out_file1", output2["name"] def test_to_cwl(): hda = model.HistoryDatasetAssociation(create_dataset=True, flush=False) hda.dataset.state = model.Dataset.states.OK hdas = [hda] hda_references = [] result = modules.to_cwl(hdas, hda_references, model.WorkflowStep()) assert isinstance(result, list) assert len(result) == 1 assert result[0]["class"] == "File" assert hda_references == hdas class MapOverTestCase(NamedTuple): data_input: str step_input_def: Union[str, List[str]] Loading Loading
lib/galaxy/workflow/modules.py +69 −63 Original line number Diff line number Diff line Loading @@ -122,22 +122,7 @@ class ConditionalStepWhen(BooleanToolParameter): pass def evaluate_value_from_expressions(progress, step, execution_state, extra_step_state): when_expression = step.when_expression value_from_expressions = {} if execution_state: for key in execution_state.inputs.keys(): step_input = step.inputs_by_name.get(key) if step_input and step_input.value_from is not None: value_from_expressions[key] = step_input.value_from if not value_from_expressions and when_expression is None: return {} hda_references = [] def to_cwl(value): def to_cwl(value, hda_references, step): element_identifier = None if isinstance(value, model.DatasetCollectionElement) and value.hda: element_identifier = value.element_identifier Loading Loading @@ -171,17 +156,22 @@ def evaluate_value_from_expressions(progress, step, execution_state, extra_step_ elif hasattr(value, "collection"): collection = value.collection if collection.collection_type == "list": return [to_cwl(dce) for dce in collection.dataset_elements] return [to_cwl(dce, hda_references=hda_references, step=step) for dce in collection.dataset_elements] else: # Could be record or nested lists rval = {} for element in collection.elements: rval[element.element_identifier] = to_cwl(element.element_object) rval[element.element_identifier] = to_cwl( element.element_object, hda_references=hda_references, step=step ) return rval elif isinstance(value, list): return [to_cwl(v, hda_references=hda_references, step=step) for v in value] else: return value def from_cwl(value): def from_cwl(value, hda_references, progress): # TODO: turn actual files into HDAs here ... somehow I suppose. Things with # file:// locations for instance. if isinstance(value, dict) and "class" in value and "location" in value: Loading @@ -196,12 +186,28 @@ def evaluate_value_from_expressions(progress, step, execution_state, extra_step_ else: return value def evaluate_value_from_expressions(progress, step, execution_state, extra_step_state): when_expression = step.when_expression value_from_expressions = {} if execution_state: for key in execution_state.inputs.keys(): step_input = step.inputs_by_name.get(key) if step_input and step_input.value_from is not None: value_from_expressions[key] = step_input.value_from if not value_from_expressions and when_expression is None: return {} hda_references: List[model.HistoryDatasetAssociation] = [] step_state = {} for key, value in extra_step_state.items(): step_state[key] = to_cwl(value) step_state[key] = to_cwl(value, hda_references=hda_references, step=step) if execution_state: for key, value in execution_state.inputs.items(): step_state[key] = to_cwl(value) step_state[key] = to_cwl(value, hda_references=hda_references, step=step) if when_expression is not None: if when_expression == "${inputs.when}": Loading Loading @@ -229,7 +235,7 @@ def evaluate_value_from_expressions(progress, step, execution_state, extra_step_ reason=FailureReason.expression_evaluation_failed, workflow_step_id=step.id ) ) when_value = from_cwl(as_cwl_value) when_value = from_cwl(as_cwl_value, hda_references=hda_references, progress=progress) if not isinstance(when_value, bool): raise FailWorkflowEvaluation( InvocationFailureWhenNotBoolean( Loading
test/unit/workflows/test_modules.py +12 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,18 @@ def test_subworkflow_new_outputs(): assert output2["name"] == "4:out_file1", output2["name"] def test_to_cwl(): hda = model.HistoryDatasetAssociation(create_dataset=True, flush=False) hda.dataset.state = model.Dataset.states.OK hdas = [hda] hda_references = [] result = modules.to_cwl(hdas, hda_references, model.WorkflowStep()) assert isinstance(result, list) assert len(result) == 1 assert result[0]["class"] == "File" assert hda_references == hdas class MapOverTestCase(NamedTuple): data_input: str step_input_def: Union[str, List[str]] Loading