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

[24.0] Fix null values in tool expression #18045

Draft
wants to merge 2 commits into
base: release_24.0
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
2 changes: 1 addition & 1 deletion lib/galaxy/tools/parameters/wrapped_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _json_wrap_input(input, value_wrapper, profile, handle_files="skip"):
if isinstance(value_wrapper, list):
value_wrapper = value_wrapper[0]
json_value = _hda_to_object(value_wrapper)
if input.load_contents:
if json_value is not None and input.load_contents:
with open(str(value_wrapper), mode="rb") as fh:
json_value["contents"] = fh.read(input.load_contents).decode("utf-8", errors="replace")
return json_value
Expand Down
19 changes: 11 additions & 8 deletions tools/expression_tools/parse_values_from_file.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<tool name="Parse parameter value" id="param_value_from_file" version="0.1.0" tool_type="expression">
<tool name="Parse parameter value" id="param_value_from_file" version="0.1.1" tool_type="expression">
<description>from dataset</description>
<macros>
<import>expression_macros.xml</import>
</macros>
<expression type="ecma5.1">{
<expression type="ecma5.1"><![CDATA[{
var output;
if ($job.remove_newlines || $job.param_type != 'text') {
$job.input1.contents = $job.input1.contents.trim();
if($job.input1 && $job.input1.contents)
{
$job.input1.contents = $job.input1.contents.trim();
}
}
if ($job.param_type == 'integer') {
output = parseInt($job.input1.contents);
Expand All @@ -25,12 +28,12 @@ if ($job.param_type == 'integer') {
return 'NOT A BOOLEAN VALUE';
}
} else {
output = $job.input1.contents;
output = $job.input1?.contents;
}
return {'output': output};
}</expression>
}]]></expression>
<inputs>
<param type="data" label="Input file containing parameter to parse out of" load_contents="64000" name="input1" />
<param type="data" label="Input file containing parameter to parse out of" load_contents="64000" name="input1"/>
<param name="param_type" type="select" label="Select type of parameter to parse">
<option value="text">Text</option>
<option value="integer">Integer</option>
Expand All @@ -39,7 +42,7 @@ return {'output': output};
</param>
<param name="remove_newlines" checked="true" type="boolean" label="Remove newlines ?" help="Uncheck this only if newlines should be preserved in parameter"/>
</inputs>
<expand macro="typed_outputs" />
<expand macro="typed_outputs"/>
<tests>
<test expect_num_outputs="1">
<param name="input1" value="simple_line.txt"/>
Expand Down Expand Up @@ -92,5 +95,5 @@ return {'output': output};
</output>
</test>
</tests>
<help></help>
<help/>
</tool>
Loading