Hi all,
I’m trying to develop a tool that lets you select a file on the server. I’m using the dynamic_options setting to let Galaxy render a dropdown list of available file.
However, when I try to test the tool in its current form, I get the following error:
<pre>
galaxy.web.framework.decorators ERROR 2016-01-26 13:08:35,649 Uncaught exception in exposed API method:
Traceback (most recent call last):
File "lib/galaxy/web/framework/decorators.py", line 260, in decorator
rval = func( self, trans, *args, **kwargs)
File "lib/galaxy/webapps/galaxy/api/tools.py", line 98, in build
return tool.to_json(trans, kwd.get('inputs', kwd))
File "lib/galaxy/tools/__init__.py", line 2602, in to_json
populate_state(trans, self.inputs, state_inputs, state_errors, params.__dict__)
File "lib/galaxy/tools/__init__.py", line 2471, in populate_state
state[input.name] = input.get_initial_value(trans, context, history=history)
File "lib/galaxy/tools/parameters/basic.py", line 984, in get_initial_value
value = [ optval for _, optval, selected in options if selected ]
ValueError: too many values to unpack
</pre>
My tool xml looks like this:
<pre>
<tool id="archivetolibrary" name="Copy files" version="0.1.0">
<description>from the archive to a data library</description>
<code file="list_files.py"/>
<command interpreter="bash">
test.sh > $log
</command>
<inputs>
<param name="archive_source" type="select" display="radio" label="Choose source archive">
<options from_file="archives.loc">
<column name="name" index="0"/>
<column name="value" index="1"/>
</options>
</param>
<param name="query" type="text" label="Search for files"/>
<param name="selected_file" type="select" label="Choose your file" dynamic_options="list_files(archive_source,query)"/>
</inputs>
<outputs>
<data name="log" format="txt" label="${tool.name} on ${on_string}"></data>
</outputs>
<tests>
<test>
</test>
</tests>
<help>
This tool copies data from and archive folder to your history. Keep in mind this folder MUST be readable by Galaxy in order for this
tool to work.
</help>
</tool>
</pre>
and the script called in the “code” tag looks like this
<pre>
def list_files(dir,query): listing=[]
for fname in listdir(dir):
fullpath = path.join(dir, fname) #only select datafiles, not md5 checksums
if path.isfile(fullpath) and not fullpath.endswith(".md5"):
listing.append( fname )
return listing
</pre>
This script should return a list with filenames that should be displayed in the dropdown list.
I’m tracking Galaxy release 15.10, running on a Ubuntu 14.04.3 server
Thanks for your help!
Matthias