commit/galaxy-central: kanwei: Show details: now works even when tool is obsolete. Show inheritance chain where the dataset came from if it was copied from a history or library
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/0ddd359e5b65/ changeset: r5540:0ddd359e5b65 user: kanwei date: 2011-05-11 17:36:22 summary: Show details: now works even when tool is obsolete. Show inheritance chain where the dataset came from if it was copied from a history or library affected #: 2 files (1.4 KB) --- a/lib/galaxy/web/controllers/dataset.py Wed May 11 10:49:32 2011 -0400 +++ b/lib/galaxy/web/controllers/dataset.py Wed May 11 11:36:22 2011 -0400 @@ -8,6 +8,7 @@ from galaxy.util.sanitize_html import sanitize_html from galaxy.util import inflector from galaxy.model.item_attrs import * +from galaxy.model import LibraryDatasetDatasetAssociation, HistoryDatasetAssociation from email.MIMEText import MIMEText import pkg_resources; @@ -718,6 +719,21 @@ """ Show the parameters used for an HDA """ + + def source_dataset_chain( dataset, lst ): + try: + cp_from_ldda = dataset.copied_from_library_dataset_dataset_association + cp_from_hda = dataset.copied_from_history_dataset_association + if cp_from_ldda: + lst.append( (cp_from_ldda, "(Data Library)") ) + return source_dataset_chain( cp_from_ldda, lst ) + elif cp_from_hda: + lst.append( (cp_from_hda, cp_from_hda.history.name) ) + return source_dataset_chain( cp_from_hda, lst ) + except: + pass + return lst + hda = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) if not hda: raise paste.httpexceptions.HTTPRequestRangeNotSatisfiable( "Invalid reference dataset id: %s." % str( dataset_id ) ) @@ -726,31 +742,29 @@ # Get the associated job, if any. If this hda was copied from another, # we need to find the job that created the origial hda + params_objects = None + tool = None job_hda = hda while job_hda.copied_from_history_dataset_association: job_hda = job_hda.copied_from_history_dataset_association - if not job_hda.creating_job_associations: - return "Could not find the job for this dataset." - # Get the job object - job = None - for assoc in job_hda.creating_job_associations: - job = assoc.job - break - if not job: - return "Could not find the job for this dataset." - # Get the tool object - try: - # Load the tool - toolbox = self.get_toolbox() - tool = toolbox.tools_by_id.get( job.tool_id, None ) - assert tool is not None, 'Requested tool has not been loaded.' - except: - return "Error: This dataset was created by an obsolete tool (%s)." % job.tool_id - try: - params_objects = job.get_param_values( trans.app ) - except: - return "Failed to get parameters for this dataset." - return trans.fill_template( "show_params.mako", history=trans.get_history(), hda=hda, tool=tool, params_objects=params_objects ) + if job_hda.creating_job_associations: + job = None + for assoc in job_hda.creating_job_associations: + job = assoc.job + break + if job: + # Get the tool object + try: + # Load the tool + toolbox = self.get_toolbox() + tool = toolbox.tools_by_id.get( job.tool_id, None ) + assert tool is not None, 'Requested tool has not been loaded.' + params_objects = job.get_param_values( trans.app ) + except: + pass + + inherit_chain = source_dataset_chain(hda, []) + return trans.fill_template( "show_params.mako", inherit_chain=inherit_chain, history=trans.get_history(), hda=hda, tool=tool, params_objects=params_objects ) @web.expose def copy_datasets( self, trans, source_history=None, source_dataset_ids="", target_history_id=None, target_history_ids="", new_history_name="", do_copy=False, **kwd ): --- a/templates/show_params.mako Wed May 11 10:49:32 2011 -0400 +++ b/templates/show_params.mako Wed May 11 11:36:22 2011 -0400 @@ -1,6 +1,15 @@ <%inherit file="/base.mako"/><% from galaxy.util import nice_size %> +<style> + .inherit { + border: 1px solid #bbb; + padding: 15px; + text-align: center; + background-color: #eee; + } +</style> + <%def name="inputs_recursive( input_params, param_values, depth=1 )"> %for input_index, input in enumerate( input_params.itervalues() ): %if input.type == "repeat": @@ -24,25 +33,46 @@ </%def><table class="tabletip"> - <thead> - <tr><th colspan="2" style="font-size: 120%;">${tool.name}</th></tr> - </thead> - <tbody> - <tr><td>Created:</th><td>${history.create_time.strftime("%b %d, %Y")}</td></tr> -## <tr><td>Copied from another history?</td><td>${hda.source_library_dataset}</td></tr> - <tr><td>Filesize:</th><td>${nice_size(hda.dataset.file_size)}</td></tr> - <tr><td>Dbkey:</th><td>${hda.dbkey}</td></tr> - <tr><td>Format:</th><td>${hda.ext}</td></tr> - -</table><br /> + <thead> + <tr><th colspan="2" style="font-size: 120%;"> + % if tool: + Tool: ${tool.name} + % else: + Unknown Tool + % endif + </th></tr> + </thead> + <tbody> + <tr><td>Name:</td><td>${hda.name}</td></tr> + <tr><td>Created:</td><td>${hda.create_time.strftime("%b %d, %Y")}</td></tr> + ## <tr><td>Copied from another history?</td><td>${hda.source_library_dataset}</td></tr> + <tr><td>Filesize:</td><td>${nice_size(hda.dataset.file_size)}</td></tr> + <tr><td>Dbkey:</td><td>${hda.dbkey}</td></tr> + <tr><td>Format:</td><td>${hda.ext}</td></tr> +</table> +<br /><table class="tabletip"> - <thead> - <tr> - <th>Input Parameter</th> - <th>Value</th> - </tr> - </thead> - <tbody> - ${ inputs_recursive(tool.inputs, params_objects, depth=1) } - </tbody> + <thead> + <tr> + <th>Input Parameter</th> + <th>Value</th> + </tr> + </thead> + <tbody> + % if params_objects and tool: + ${ inputs_recursive(tool.inputs, params_objects, depth=1) } + % else: + <tr><td colspan="2">No parameters.</td></tr> + % endif + </tbody></table> + + + <h3>Inheritance Chain</h3> + <div class="inherit" style="background-color: #fff; font-weight:bold;">${hda.name}</div> + + % for dep in inherit_chain: + <div style="font-size: 36px; text-align: center;">↑</div> + <div class="inherit">${dep[0].name}<br/>${dep[1]}</div> + % endfor + Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket