Skip to content

Commit 2bf91f3

Browse files
committed
Hack in support for int parameters in Galaxy.
1 parent 819a27b commit 2bf91f3

File tree

8 files changed

+63
-17
lines changed

8 files changed

+63
-17
lines changed

lib/galaxy/tools/cwl/parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,9 @@ def cwl_input_to_galaxy_step(self, input, i):
600600
input_as_dict["type"] = "data_collection_input"
601601
input_as_dict["collection_type"] = "record"
602602
else:
603-
input_as_dict["type"] = "parameter_input"
603+
# input_as_dict["type"] = "parameter_input"
604+
input_as_dict["type"] = "data_input"
605+
# TODO: format = expression.json
604606

605607
return input_as_dict
606608

lib/galaxy/workflow/modules.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ def from_cwl(value):
913913
as_cwl_value = do_eval(
914914
value_from,
915915
step_state,
916-
[],
916+
[{"class": "InlineJavascriptRequirement"}],
917917
None,
918918
None,
919919
{},
@@ -1290,6 +1290,8 @@ def populate_module_and_state( trans, workflow, param_map, allow_tool_state_corr
12901290
for step in workflow.steps:
12911291
step_args = param_map.get( step.id, {} )
12921292
step_errors = module_injector.inject( step, step_args=step_args )
1293+
# RESTRICT TO THIS JUST TO CONNECTIONS
1294+
step.upgrade_messages = []
12931295
if step_errors:
12941296
raise exceptions.MessageException( step_errors, err_data={ step.order_index: step_errors } )
12951297
if step.upgrade_messages:

lib/galaxy/workflow/run.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,21 +311,23 @@ def replacement_for_tool_input( self, step, input, prefixed_name ):
311311
input_collection_type = None
312312
for i, c in enumerate(connection):
313313
input_from_connection = self.replacement_for_connection( c, is_data=is_data )
314-
input_history_content_type = input_from_connection.history_content_type
315-
if i == 0:
316-
if input_history_content_type == "dataset_collection":
317-
input_collection_type = input_from_connection.collection.collection_type
314+
is_data = hasattr(input_from_connection, "history_content_type")
315+
if is_data:
316+
input_history_content_type = input_from_connection.history_content_type
317+
if i == 0:
318+
if input_history_content_type == "dataset_collection":
319+
input_collection_type = input_from_connection.collection.collection_type
320+
else:
321+
input_collection_type = None
318322
else:
319-
input_collection_type = None
320-
else:
321-
if input_collection_type is None:
322-
if input_history_content_type != "dataset":
323-
raise Exception("Cannot map over a combination of datasets and collections.")
324-
else:
325-
if input_history_content_type != "dataset_collection":
326-
raise Exception("Cannot merge over combinations of datasets and collections.")
327-
elif input_from_connection.collection.collection_type != input_collection_type:
328-
raise Exception("Cannot merge collections of different collection types.")
323+
if input_collection_type is None:
324+
if input_history_content_type != "dataset":
325+
raise Exception("Cannot map over a combination of datasets and collections.")
326+
else:
327+
if input_history_content_type != "dataset_collection":
328+
raise Exception("Cannot merge over combinations of datasets and collections.")
329+
elif input_from_connection.collection.collection_type != input_collection_type:
330+
raise Exception("Cannot merge collections of different collection types.")
329331

330332
inputs.append(input_from_connection)
331333

test/api/test_workflows_cwl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ def test_scatter_wf1_v1(self):
137137
def test_record_io(self):
138138
self.run_conformance_test("v1.0_custom", "Test record type inputs to and outputs from workflows.")
139139

140+
def test_workflow_int_io(self):
141+
self.run_conformance_test("v1.0_custom", "Test integer workflow input and outputs")
142+
140143
def _run_count_lines_wf(self, wf_path):
141144
workflow_id = self._load_workflow(wf_path)
142145
hda1 = self.dataset_populator.new_dataset(self.history_id, content="hello world\nhello all\nhello all in world\nhello")

test/base/populators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def replacement_item(value, force_to_file=False):
9292
if isinstance(value, list):
9393
return replacement_list(value)
9494
elif not isinstance(value, dict):
95-
return value
95+
return upload_object(value)
9696

9797
if is_file:
9898
return replacement_file(value)

test/unit/tools/cwl_tools/v1.0_custom/conformance_tests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@
1717
}
1818
tool: v1.0_custom/record-output-wf.cwl
1919
doc: Test record type inputs to and outputs from workflows.
20+
21+
- job: v1.0_custom/int-io-job.json
22+
output: {"o": 10}
23+
tool: v1.0_custom/int-io-wf.cwl
24+
doc: Test integer workflow input and outputs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"i": 5}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.0
4+
5+
requirements:
6+
- class: InlineJavascriptRequirement
7+
8+
inputs:
9+
i:
10+
type: int
11+
12+
outputs:
13+
o:
14+
type: int
15+
outputSource: step1/o
16+
17+
steps:
18+
step1:
19+
in:
20+
i: i
21+
out: [o]
22+
run:
23+
class: ExpressionTool
24+
inputs:
25+
i:
26+
type: int
27+
outputs:
28+
o:
29+
type: int
30+
expression: >
31+
${return {'o': inputs.i * 2};}

0 commit comments

Comments
 (0)