Skip to content

Commit d5f571b

Browse files
galaxy: fix selects
galaxyproject/galaxy#11797
1 parent 98509e1 commit d5f571b

File tree

4 files changed

+83
-77
lines changed

4 files changed

+83
-77
lines changed

ctdconverter/galaxy/converter.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,22 +1165,18 @@ def create_param_attribute_list(param_node, param, model, supported_file_formats
11651165
if argument.lstrip("-").replace("-", "_") != name:
11661166
param_node.attrib["name"] = get_galaxy_parameter_name(param)
11671167
param_node.attrib["argument"] = argument
1168+
11681169
param_type = TYPE_TO_GALAXY_TYPE[param.type]
11691170
if param_type is None:
11701171
raise ModelError("Unrecognized parameter type %(type)s for parameter %(name)s"
11711172
% {"type": param.type, "name": param.name})
1173+
11721174
# ITEMLIST is rendered as text field (even if its integers or floats), an
1173-
# exception is files which are treated a bit below
1175+
# exception is files which are treated just below
11741176
if param.is_list:
11751177
param_type = "text"
1176-
11771178
if is_selection_parameter(param):
11781179
param_type = "select"
1179-
if len(param.restrictions.choices) < 5:
1180-
param_node.attrib["display"] = "checkboxes"
1181-
if param.is_list:
1182-
param_node.attrib["multiple"] = "true"
1183-
11841180
if is_boolean_parameter(param):
11851181
param_type = "boolean"
11861182

@@ -1207,10 +1203,20 @@ def create_param_attribute_list(param_node, param, model, supported_file_formats
12071203
# (in Galaxy the default would be prefilled in the form and at least
12081204
# one option needs to be selected).
12091205
if not (param.default is None or type(param.default) is _Null) and param_node.attrib["type"] in ["integer", "float", "text", "boolean", "select"]:
1210-
logger.error("%s %s %s %s %s" % (param.name, param.default is None, type(param.default) is _Null, param_type, param.type))
1211-
param_node.attrib["optional"] = "false"
1206+
# logger.error("%s %s %s %s %s" % (param.name, param.default is None, type(param.default) is _Null, param_type, param.type))
1207+
optional = False
12121208
else:
1213-
param_node.attrib["optional"] = str(not param.required).lower()
1209+
optional = not param.required
1210+
param_node.attrib["optional"] = str(optional).lower()
1211+
1212+
if is_selection_parameter(param):
1213+
if param.is_list:
1214+
param_node.attrib["multiple"] = "true"
1215+
if len(param.restrictions.choices) < 5:
1216+
if param.is_list and optional:
1217+
param_node.attrib["display"] = "checkboxes"
1218+
elif not param.is_list and not optional:
1219+
param_node.attrib["display"] = "radio"
12141220

12151221
# check for parameters with restricted values (which will correspond to a "select" in galaxy)
12161222
if param.restrictions is not None or param_type == "boolean":
@@ -1485,7 +1491,7 @@ def create_boolean_parameter(param_node, param):
14851491

14861492
def all_outputs(model, parameter_hardcoder):
14871493
"""
1488-
return lists of reqired and optional output parameters
1494+
return lists of required and optional output parameters
14891495
"""
14901496
out = []
14911497
optout = []

tests/test-data/ofile-mult-typeparam.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ ${' '.join(["&& mv -n 'test_section_sect_mandatory_mandatoryinput/%(bn)s/%(id)s.
5151
<configfile name="hardcoded_json"><![CDATA[{}]]></configfile>
5252
</configfiles>
5353
<inputs>
54-
<param argument="-mandatory_mandatoryinput_type" display="checkboxes" type="select" optional="false" label="string" help="">
54+
<param argument="-mandatory_mandatoryinput_type" type="select" optional="false" display="radio" label="string" help="">
5555
<option value="ewt">tsv (ewt)</option>
5656
<option value="ext">tsv (ext)</option>
5757
<expand macro="list_string_san" name="mandatory_mandatoryinput_type"/>
5858
</param>
5959
<param argument="-inp_mandatory_mandatoryinput" type="data" format="tsv" multiple="true" optional="false" label="input file" help=" select tsv data sets(s)"/>
6060
<section name="test_section" title="Test Section" help="" expanded="false">
61-
<param name="sect_mandatory_mandatoryinput_type" argument="-test_section:sect_mandatory_mandatoryinput_type" display="checkboxes" type="select" optional="false" label="string" help="">
61+
<param name="sect_mandatory_mandatoryinput_type" argument="-test_section:sect_mandatory_mandatoryinput_type" type="select" optional="false" display="radio" label="string" help="">
6262
<option value="eut">txt (eut)</option>
6363
<option value="ewt">tsv (ewt)</option>
6464
<option value="ext">tsv (ext)</option>

tests/test-data/ofile-typeparam.xml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,25 @@ python3 '$__tool_directory__/fill_ctd.py' '@[email protected]' '$args_json' '$hard
170170
<configfile name="hardcoded_json"><![CDATA[{}]]></configfile>
171171
</configfiles>
172172
<inputs>
173-
<param argument="-mandatory_noformat_type" display="checkboxes" type="select" optional="false" label="string" help="">
173+
<param argument="-mandatory_noformat_type" type="select" optional="false" display="radio" label="string" help="">
174174
<option value="ext">tsv (ext)</option>
175175
<option value="eyt">tabular (eyt)</option>
176176
<option value="ezt">tabular (ezt)</option>
177177
<expand macro="list_string_san" name="mandatory_noformat_type"/>
178178
</param>
179-
<param argument="-optional_noformat_type" display="checkboxes" type="select" optional="false" label="string" help="">
179+
<param argument="-optional_noformat_type" type="select" optional="false" display="radio" label="string" help="">
180180
<option value="ext">tsv (ext)</option>
181181
<option value="eyt">tabular (eyt)</option>
182182
<option value="ezt">tabular (ezt)</option>
183183
<expand macro="list_string_san" name="optional_noformat_type"/>
184184
</param>
185-
<param argument="-mandatory_multformat_type" display="checkboxes" type="select" optional="false" label="string" help="">
185+
<param argument="-mandatory_multformat_type" type="select" optional="false" display="radio" label="string" help="">
186186
<option value="ext">tsv (ext)</option>
187187
<option value="eyt">tabular (eyt)</option>
188188
<option value="ezt">tabular (ezt)</option>
189189
<expand macro="list_string_san" name="mandatory_multformat_type"/>
190190
</param>
191-
<param argument="-optional_multformat_type" display="checkboxes" type="select" optional="false" label="string" help="">
191+
<param argument="-optional_multformat_type" type="select" optional="false" display="radio" label="string" help="">
192192
<option value="ext">tsv (ext)</option>
193193
<option value="eyt">tabular (eyt)</option>
194194
<option value="ezt">tabular (ezt)</option>
@@ -198,49 +198,49 @@ python3 '$__tool_directory__/fill_ctd.py' '@[email protected]' '$args_json' '$hard
198198
<param argument="-decoy_input_oneformat" type="data" format="tsv" optional="false" label="input file" help=" select tsv data sets(s)"/>
199199
<param argument="-decoy_input_multformat" type="data" format="tabular,tsv" optional="false" label="input file" help=" select tabular,tsv data sets(s)"/>
200200
<section name="test_section" title="Test Section" help="" expanded="false">
201-
<param name="sect_mandatory_noformat_type" argument="-test_section:sect_mandatory_noformat_type" display="checkboxes" type="select" optional="false" label="string" help="">
201+
<param name="sect_mandatory_noformat_type" argument="-test_section:sect_mandatory_noformat_type" type="select" optional="false" display="radio" label="string" help="">
202202
<option value="ext">tsv (ext)</option>
203203
<option value="eyt">tabular (eyt)</option>
204204
<option value="ezt">tabular (ezt)</option>
205205
<expand macro="list_string_san" name="sect_mandatory_noformat_type"/>
206206
</param>
207-
<param name="sect_optional_noformat_type" argument="-test_section:sect_optional_noformat_type" display="checkboxes" type="select" optional="false" label="string" help="">
207+
<param name="sect_optional_noformat_type" argument="-test_section:sect_optional_noformat_type" type="select" optional="false" display="radio" label="string" help="">
208208
<option value="ext">tsv (ext)</option>
209209
<option value="eyt">tabular (eyt)</option>
210210
<option value="ezt">tabular (ezt)</option>
211211
<expand macro="list_string_san" name="sect_optional_noformat_type"/>
212212
</param>
213-
<param name="sect_mandatory_multformat_type" argument="-test_section:sect_mandatory_multformat_type" display="checkboxes" type="select" optional="false" label="string" help="">
213+
<param name="sect_mandatory_multformat_type" argument="-test_section:sect_mandatory_multformat_type" type="select" optional="false" display="radio" label="string" help="">
214214
<option value="ext">tsv (ext)</option>
215215
<option value="eyt">tabular (eyt)</option>
216216
<option value="ezt">tabular (ezt)</option>
217217
<expand macro="list_string_san" name="sect_mandatory_multformat_type"/>
218218
</param>
219-
<param name="sect_optional_multformat_type" argument="-test_section:sect_optional_multformat_type" display="checkboxes" type="select" optional="false" label="string" help="">
219+
<param name="sect_optional_multformat_type" argument="-test_section:sect_optional_multformat_type" type="select" optional="false" display="radio" label="string" help="">
220220
<option value="ext">tsv (ext)</option>
221221
<option value="eyt">tabular (eyt)</option>
222222
<option value="ezt">tabular (ezt)</option>
223223
<expand macro="list_string_san" name="sect_optional_multformat_type"/>
224224
</param>
225-
<param name="sect_mandatory_noformat_adv_type" argument="-test_section:sect_mandatory_noformat_adv_type" display="checkboxes" type="select" optional="false" label="string" help="">
225+
<param name="sect_mandatory_noformat_adv_type" argument="-test_section:sect_mandatory_noformat_adv_type" type="select" optional="false" display="radio" label="string" help="">
226226
<option value="ext">tsv (ext)</option>
227227
<option value="eyt">tabular (eyt)</option>
228228
<option value="ezt">tabular (ezt)</option>
229229
<expand macro="list_string_san" name="sect_mandatory_noformat_adv_type"/>
230230
</param>
231-
<param name="sect_optional_noformat_adv_type" argument="-test_section:sect_optional_noformat_adv_type" display="checkboxes" type="select" optional="false" label="string" help="">
231+
<param name="sect_optional_noformat_adv_type" argument="-test_section:sect_optional_noformat_adv_type" type="select" optional="false" display="radio" label="string" help="">
232232
<option value="ext">tsv (ext)</option>
233233
<option value="eyt">tabular (eyt)</option>
234234
<option value="ezt">tabular (ezt)</option>
235235
<expand macro="list_string_san" name="sect_optional_noformat_adv_type"/>
236236
</param>
237-
<param name="sect_mandatory_multformat_adv_type" argument="-test_section:sect_mandatory_multformat_adv_type" display="checkboxes" type="select" optional="false" label="string" help="">
237+
<param name="sect_mandatory_multformat_adv_type" argument="-test_section:sect_mandatory_multformat_adv_type" type="select" optional="false" display="radio" label="string" help="">
238238
<option value="ext">tsv (ext)</option>
239239
<option value="eyt">tabular (eyt)</option>
240240
<option value="ezt">tabular (ezt)</option>
241241
<expand macro="list_string_san" name="sect_mandatory_multformat_adv_type"/>
242242
</param>
243-
<param name="sect_optional_multformat_adv_type" argument="-test_section:sect_optional_multformat_adv_type" display="checkboxes" type="select" optional="false" label="string" help="">
243+
<param name="sect_optional_multformat_adv_type" argument="-test_section:sect_optional_multformat_adv_type" type="select" optional="false" display="radio" label="string" help="">
244244
<option value="ext">tsv (ext)</option>
245245
<option value="eyt">tabular (eyt)</option>
246246
<option value="ezt">tabular (ezt)</option>
@@ -251,25 +251,25 @@ python3 '$__tool_directory__/fill_ctd.py' '@[email protected]' '$args_json' '$hard
251251
<param name="sect_decoy_input_multformat" argument="-test_section:sect_decoy_input_multformat" type="data" format="tabular,tsv" optional="false" label="input file" help=" select tabular,tsv data sets(s)"/>
252252
</section>
253253
<expand macro="adv_opts_macro">
254-
<param argument="-mandatory_noformat_adv_type" display="checkboxes" type="select" optional="false" label="string" help="">
254+
<param argument="-mandatory_noformat_adv_type" type="select" optional="false" display="radio" label="string" help="">
255255
<option value="ext">tsv (ext)</option>
256256
<option value="eyt">tabular (eyt)</option>
257257
<option value="ezt">tabular (ezt)</option>
258258
<expand macro="list_string_san" name="mandatory_noformat_adv_type"/>
259259
</param>
260-
<param argument="-optional_noformat_adv_type" display="checkboxes" type="select" optional="false" label="string" help="">
260+
<param argument="-optional_noformat_adv_type" type="select" optional="false" display="radio" label="string" help="">
261261
<option value="ext">tsv (ext)</option>
262262
<option value="eyt">tabular (eyt)</option>
263263
<option value="ezt">tabular (ezt)</option>
264264
<expand macro="list_string_san" name="optional_noformat_adv_type"/>
265265
</param>
266-
<param argument="-mandatory_multformat_adv_type" display="checkboxes" type="select" optional="false" label="string" help="">
266+
<param argument="-mandatory_multformat_adv_type" type="select" optional="false" display="radio" label="string" help="">
267267
<option value="ext">tsv (ext)</option>
268268
<option value="eyt">tabular (eyt)</option>
269269
<option value="ezt">tabular (ezt)</option>
270270
<expand macro="list_string_san" name="mandatory_multformat_adv_type"/>
271271
</param>
272-
<param argument="-optional_multformat_adv_type" display="checkboxes" type="select" optional="false" label="string" help="">
272+
<param argument="-optional_multformat_adv_type" type="select" optional="false" display="radio" label="string" help="">
273273
<option value="ext">tsv (ext)</option>
274274
<option value="eyt">tabular (eyt)</option>
275275
<option value="ezt">tabular (ezt)</option>

0 commit comments

Comments
 (0)