details: http://www.bx.psu.edu/hg/galaxy/rev/7cb131814770 changeset: 3671:7cb131814770 user: James Taylor <james@jamestaylor.org> date: Mon Apr 19 17:43:39 2010 -0400 description: Fix ordering in display_structured, also use insane eagerloading to make it massively faster diffstat: lib/galaxy/util/odict.py | 10 +++++++--- lib/galaxy/web/controllers/history.py | 25 ++++++++++++++++--------- templates/history/display_structured.mako | 13 ++++++++++--- 3 files changed, 33 insertions(+), 15 deletions(-) diffs (128 lines): diff -r b8d25aabb98d -r 7cb131814770 lib/galaxy/util/odict.py --- a/lib/galaxy/util/odict.py Tue Apr 20 11:47:51 2010 -0400 +++ b/lib/galaxy/util/odict.py Mon Apr 19 17:43:39 2010 -0400 @@ -31,9 +31,9 @@ self._keys = [] def copy(self): - new = odict() - new.update( self ) - return new + new = odict() + new.update( self ) + return new def items(self): return zip(self._keys, self.values()) @@ -82,3 +82,7 @@ def __iter__( self ): for key in self._keys: yield key + + def reverse( self ): + self._keys.reverse() + diff -r b8d25aabb98d -r 7cb131814770 lib/galaxy/web/controllers/history.py --- a/lib/galaxy/web/controllers/history.py Tue Apr 20 11:47:51 2010 -0400 +++ b/lib/galaxy/web/controllers/history.py Mon Apr 19 17:43:39 2010 -0400 @@ -1,6 +1,7 @@ from galaxy.web.base.controller import * from galaxy.web.framework.helpers import time_ago, iff, grids from galaxy import util +from galaxy.util.odict import odict from galaxy.model.mapping import desc from galaxy.model.orm import * from galaxy.util.json import * @@ -336,25 +337,31 @@ """ # Get history if id is None: - history = trans.history + id = trans.history.id else: id = trans.security.decode_id( id ) - history = trans.sa_session.query( model.History ).get( id ) - assert history - assert history.user and ( history.user == trans.user ) or ( history == trans.history ) + # Expunge history from the session to allow us to force a reload + # with a bunch of eager loaded joins + trans.sa_session.expunge( trans.history ) + history = trans.sa_session.query( model.History ).options( + eagerload_all( 'active_datasets.creating_job_associations.job.workflow_invocation_step.workflow_invocation.workflow' ), + eagerload_all( 'active_datasets.children' ) + ).get( id ) + assert history + assert history.user and ( history.user.id == trans.user.id ) or ( history.id == trans.history.id ) # Resolve jobs and workflow invocations for the datasets in the history # items is filled with items (hdas, jobs, or workflows) that go at the # top level items = [] # First go through and group hdas by job, if there is no job they get # added directly to items - jobs = dict() + jobs = odict() for hda in history.active_datasets: # Follow "copied from ..." association until we get to the original # instance of the dataset original_hda = hda - while original_hda.copied_from_history_dataset_association: - original_hda = original_hda.copied_from_history_dataset_association + ## while original_hda.copied_from_history_dataset_association: + ## original_hda = original_hda.copied_from_history_dataset_association # Check if the job has a creating job, most should, datasets from # before jobs were tracked, or from the upload tool before it # created a job, may not @@ -370,7 +377,7 @@ else: jobs[ job ] = [ ( hda, None ) ] # Second, go through the jobs and connect to workflows - wf_invocations = dict() + wf_invocations = odict() for job, hdas in jobs.iteritems(): # Job is attached to a workflow step, follow it to the # workflow_invocation and group @@ -1025,4 +1032,4 @@ msg = 'Clone with name "%s" is now included in your previously stored histories.' % new_history.name else: msg = '%d cloned histories are now included in your previously stored histories.' % len( histories ) - return trans.show_ok_message( msg ) \ No newline at end of file + return trans.show_ok_message( msg ) diff -r b8d25aabb98d -r 7cb131814770 templates/history/display_structured.mako --- a/templates/history/display_structured.mako Tue Apr 20 11:47:51 2010 -0400 +++ b/templates/history/display_structured.mako Mon Apr 19 17:43:39 2010 -0400 @@ -16,6 +16,7 @@ .workflow { border: solid gray 1px; + margin: 5px 0; border-left-width: 5px; } @@ -96,9 +97,15 @@ <%def name="render_item_job( job, children )"> <div class="tool toolForm"> - <div class="header toolFormTitle">Tool: ${trans.app.toolbox.tools_by_id[job.tool_id].name}</div> + <% + if job.tool_id in trans.app.toolbox.tools_by_id: + tool_name = trans.app.toolbox.tools_by_id[job.tool_id].name + else: + tool_name = "Unknown tool with id '%s'" % job.tool_id + %> + <div class="header toolFormTitle">Tool: ${tool_name}</div> <div class="body toolFormBody"> - %for e, c in children: + %for e, c in reversed( children ): ${render_item( e, c )} %endfor </div> @@ -111,7 +118,7 @@ <div class="workflow"> <div class="header">Workflow: ${wf.workflow.name}</div> <div class="body"> - %for e, c in children: + %for e, c in reversed( children ): ${render_item( e, c )} %endfor </div>