Skip to content

Commit 334f2d4

Browse files
committed
Improved output and test linters.
Mostly enhanced to recognize output collections but there are some other smaller enhancements there as well.
1 parent a32d082 commit 334f2d4

File tree

3 files changed

+61
-19
lines changed

3 files changed

+61
-19
lines changed
Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11

22

33
def lint_output(tool_xml, lint_ctx):
4-
outputs = tool_xml.findall("./outputs/data")
5-
if not outputs:
6-
lint_ctx.warn("Tool contains no outputs, most tools should produce outputs.")
7-
return
4+
outputs = tool_xml.findall("./outputs")
5+
if len(outputs) == 0:
6+
lint_ctx.warn("Tool contains no outputs section, most tools should produce outputs.")
7+
if len(outputs) > 1:
8+
lint_ctx.warn("Tool contains multiple output sections, behavior undefined.")
89

910
num_outputs = 0
10-
for output in outputs:
11+
for output in list(outputs[0]):
12+
if output.tag not in ["data", "collection"]:
13+
lint_ctx.warn("Unknown element found in outputs [%s]" % output.tag)
14+
continue
1115
num_outputs += 1
1216
output_attrib = output.attrib
13-
format_set = False
14-
if "format" in output_attrib:
15-
format_set = True
16-
format = output_attrib["format"]
17-
if format == "input":
18-
lint_ctx.warn("Using format='input' on output data, format_source attribute is less ambiguous and should be used instead.")
19-
elif "format_source" in output_attrib:
20-
format_set = True
21-
22-
if not format_set:
23-
lint_ctx.warn("Tool data output doesn't define an output format.")
24-
25-
lint_ctx.info("%d output datasets found.", num_outputs)
17+
if output.tag == "data":
18+
format_set = False
19+
if "format" in output_attrib:
20+
format_set = True
21+
format = output_attrib["format"]
22+
if format == "input":
23+
lint_ctx.warn("Using format='input' on output data, format_source attribute is less ambiguous and should be used instead.")
24+
elif "format_source" in output_attrib:
25+
format_set = True
26+
if not format_set:
27+
lint_ctx.warn("Tool data output doesn't define an output format.")
28+
elif output.tag == "collection":
29+
if "type" not in output_attrib:
30+
lint_ctx.warn("Collection output with undefined 'type' found.")
31+
lint_ctx.info("%d outputs found.", num_outputs)

planemo_ext/galaxy/tools/linters/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def lint_tsts(tool_xml, lint_ctx):
1616
if len(test.findall("assert_stdout")) > 0:
1717
has_test = True
1818

19-
outputs = test.findall("output")
19+
outputs = test.findall("output") + test.findall("output_collection")
2020
if len(outputs) > 0:
2121
has_test = True
2222
if not has_test:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<tool id="collection_split_on_column" name="collection_split_on_column" version="1.0.0">
2+
<command>
3+
mkdir outputs; cd outputs; awk '{ print \$2 > \$1 ".tabular" }' $input1
4+
</command>
5+
<inputs>
6+
<param name="input1" type="data" label="Input Table" help="Table to split on first column" format="tabular" />
7+
</inputs>
8+
<outputs>
9+
<collection name="split_output" type="list" label="Table split on first column">
10+
<discover_datasets pattern="__name_and_ext__" directory="outputs" />
11+
</collection>
12+
</outputs>
13+
<tests>
14+
<test>
15+
<param name="input1" value="tinywga.fam" />
16+
<output_collection name="split_output" type="list">
17+
<element name="101">
18+
<assert_contents>
19+
<has_text_matching expression="^1\n2\n3\n$" />
20+
</assert_contents>
21+
</element>
22+
<element name="1334">
23+
<assert_contents>
24+
<has_text_matching expression="^1\n10\n11\n12\n13\n2\n$" />
25+
</assert_contents>
26+
</element>
27+
</output_collection>
28+
</test>
29+
</tests>
30+
<help>
31+
Some Awesome Help!
32+
</help>
33+
<citations>
34+
<citation type="doi">10.1101/014043</citation>
35+
</citations>
36+
</tool>

0 commit comments

Comments
 (0)