Skip to content
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

Apply metadata setter for default to conditionals #7197

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/galaxy/tools/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,25 @@ def set_metadata_defaults(self, output, dataset, tool, on_text, trans, incoming,
<action name="column_names" type="metadata" default="${','.join([input.name for input in $individual_inputs ])}" />
</actions>
</data>

or

<actions>
<conditional name="format">
<when value="something_good">
<action type="metadata" name="column_names" default="one,two,three" />
</when>
</conditional>
</actions>
"""
if output.actions:
action_list = output.actions.actions
for action in output.actions.actions:
if action.tag == "metadata" and action.default:
if action.tag == "conditional":
for case in action.cases:
action_list.extend(case.actions)
for action in action_list:
if action.tag == "metadata" and hasattr(action, "default") and action.default:
metadata_new_value = fill_template(action.default, context=params).split(",")
dataset.metadata.__setattr__(str(action.name), metadata_new_value)

Expand Down
30 changes: 30 additions & 0 deletions test/functional/tools/metadata_column_names_conditional.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<tool id="metadata_columns_conditional" name="metadata_columns_conditional" version="1.0.0">
<description>Tests whether metadata is being set correctly.</description>
<command><![CDATA[
cp '$input' '$output'
]]></command>
<inputs>
<param name="input" type="data" multiple="false" />
<param name="variable" type="integer" value="1" size="1" />
</inputs>
<outputs>
<data format="tabular" name="output">
<actions>
<conditional name="variable">
<when value="1">
<action name="column_names" type="metadata" default="First,${input.name}" />
</when>
</conditional>
</actions>
</data>
</outputs>
<tests>
<test>
<param name="input" value="2.tabular" />
<param name="variable" value="1" />
<output name="output">
<metadata name="column_names" value="First,2.tabular"/>
</output>
</test>
</tests>
</tool>
1 change: 1 addition & 0 deletions test/functional/tools/samples_tool_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<tool file="metadata_bcf.xml" />
<tool file="metadata_biom1.xml" />
<tool file="metadata_column_names.xml" />
<tool file="metadata_column_names_conditional.xml" />
<tool file="strict_shell.xml" />
<tool file="strict_shell_default_off.xml" />
<tool file="detect_errors_aggressive.xml" />
Expand Down