details:
http://www.bx.psu.edu/hg/galaxy/rev/6741f6000e03
changeset: 3228:6741f6000e03
user: Greg Von Kuster <greg(a)bx.psu.edu>
date: Tue Jan 12 14:08:17 2010 -0500
description:
Preserve teh order of a tool's output datasets by storing them in an odict rather than
a dict - loosely based on the "patch" contributed by Alexander Rose.
diffstat:
lib/galaxy/tools/__init__.py | 6 +++---
lib/galaxy/tools/actions/__init__.py | 3 ++-
lib/galaxy/tools/actions/metadata.py | 3 ++-
lib/galaxy/tools/actions/upload_common.py | 6 +++++-
test/base/twilltestcase.py | 3 +--
5 files changed, 13 insertions(+), 8 deletions(-)
diffs (95 lines):
diff -r 892199a8078e -r 6741f6000e03 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py Tue Jan 12 11:42:22 2010 -0500
+++ b/lib/galaxy/tools/__init__.py Tue Jan 12 14:08:17 2010 -0500
@@ -372,7 +372,7 @@
# Parse tool help
self.parse_help( root )
# Description of outputs produced by an invocation of the tool
- self.outputs = {}
+ self.outputs = odict()
out_elem = root.find("outputs")
if out_elem:
for data_elem in out_elem.findall("data"):
@@ -790,10 +790,10 @@
elif state.page == self.last_page:
out_data = self.execute( trans, incoming=params )
try:
- assert type( out_data ) is types.DictType
+ assert isinstance( out_data, odict )
return 'tool_executed.mako', dict( out_data=out_data )
except:
- return 'message.mako', dict( message_type='error',
message=out_data, refresh_frames=[] )
+ return 'message.mako', dict( message_type='error',
message='odict not returned from tool execution', refresh_frames=[] )
# Otherwise move on to the next page
else:
state.page += 1
diff -r 892199a8078e -r 6741f6000e03 lib/galaxy/tools/actions/__init__.py
--- a/lib/galaxy/tools/actions/__init__.py Tue Jan 12 11:42:22 2010 -0500
+++ b/lib/galaxy/tools/actions/__init__.py Tue Jan 12 14:08:17 2010 -0500
@@ -1,4 +1,5 @@
from galaxy.util.bunch import Bunch
+from galaxy.util.odict import odict
from galaxy.tools.parameters import *
from galaxy.tools.parameters.grouping import *
from galaxy.util.template import fill_template
@@ -107,7 +108,7 @@
input_values[ input.name ] = galaxy.tools.SelectToolParameterWrapper(
input, input_values[ input.name ], tool.app, other_values = incoming )
else:
input_values[ input.name ] = galaxy.tools.InputValueWrapper( input,
input_values[ input.name ], incoming )
- out_data = {}
+ out_data = odict()
# Collect any input datasets from the incoming parameters
inp_data = self.collect_input_datasets( tool, incoming, trans )
diff -r 892199a8078e -r 6741f6000e03 lib/galaxy/tools/actions/metadata.py
--- a/lib/galaxy/tools/actions/metadata.py Tue Jan 12 11:42:22 2010 -0500
+++ b/lib/galaxy/tools/actions/metadata.py Tue Jan 12 14:08:17 2010 -0500
@@ -1,5 +1,6 @@
from __init__ import ToolAction
from galaxy.datatypes.metadata import JobExternalOutputMetadataWrapper
+from galaxy.util.odict import odict
import logging
log = logging.getLogger( __name__ )
@@ -59,4 +60,4 @@
# Queue the job for execution
trans.app.job_queue.put( job.id, tool )
trans.log_event( "Added set external metadata job to the job queue, id:
%s" % str(job.id), tool_id=job.tool_id )
- return []
+ return odict()
diff -r 892199a8078e -r 6741f6000e03 lib/galaxy/tools/actions/upload_common.py
--- a/lib/galaxy/tools/actions/upload_common.py Tue Jan 12 11:42:22 2010 -0500
+++ b/lib/galaxy/tools/actions/upload_common.py Tue Jan 12 14:08:17 2010 -0500
@@ -1,6 +1,7 @@
import os, tempfile, StringIO
from cgi import FieldStorage
from galaxy import datatypes, util
+from galaxy.util.odict import odict
from galaxy.datatypes import sniff
from galaxy.util.json import to_json_string
from galaxy.model.orm import eagerload_all
@@ -321,7 +322,10 @@
# Queue the job for execution
trans.app.job_queue.put( job.id, tool )
trans.log_event( "Added job to the job queue, id: %s" % str(job.id),
tool_id=job.tool_id )
- return dict( [ ( 'output%i' % i, v ) for i, v in enumerate( data_list ) ] )
+ output = odict()
+ for i, v in enumerate( data_list ):
+ output[ 'output%i' % i ] = v
+ return output
def active_folders( trans, folder ):
# Stolen from galaxy.web.controllers.library_common (importing from which causes a
circular issues).
# Much faster way of retrieving all active sub-folders within a given folder than
the
diff -r 892199a8078e -r 6741f6000e03 test/base/twilltestcase.py
--- a/test/base/twilltestcase.py Tue Jan 12 11:42:22 2010 -0500
+++ b/test/base/twilltestcase.py Tue Jan 12 14:08:17 2010 -0500
@@ -81,8 +81,7 @@
def upload_file( self, filename, ftype='auto', dbkey='unspecified
(?)' ):
"""Uploads a file"""
filename = self.get_filename(filename)
- self.home()
- self.visit_page( "tool_runner/index?tool_id=upload1" )
+ self.visit_url( "%s/tool_runner?tool_id=upload1" % self.url )
try:
tc.fv("1","file_type", ftype)
tc.fv("1","dbkey", dbkey)