diff --git a/lib/galaxy/datatypes/data.py b/lib/galaxy/datatypes/data.py index 5827de8ed5a..8a9c5ba05db 100644 --- a/lib/galaxy/datatypes/data.py +++ b/lib/galaxy/datatypes/data.py @@ -39,6 +39,9 @@ class Data( object ): def validate(self, dataset): """Unimplemented validate, return no exceptions""" return list() + def repair_methods(self, dataset): + """Unimplemented method, returns dict with method/option for repairing errors""" + return None class Text( Data ): def write_from_stream(self, stream): diff --git a/lib/galaxy/datatypes/interval.py b/lib/galaxy/datatypes/interval.py index 6d75d5efa83..3a631b87c97 100644 --- a/lib/galaxy/datatypes/interval.py +++ b/lib/galaxy/datatypes/interval.py @@ -186,6 +186,10 @@ class Interval( Tabular ): infile.close() return errors + def repair_methods( self, dataset ): + """Return options for removing errors along with a description""" + return [("lines","Remove erroneous lines")] + class Bed( Interval ): """Tab delimited data in BED format""" def init_meta( self, dataset ): diff --git a/lib/galaxy/interfaces/root.py b/lib/galaxy/interfaces/root.py index cb8a3edf55b..cd0cb3d4407 100644 --- a/lib/galaxy/interfaces/root.py +++ b/lib/galaxy/interfaces/root.py @@ -7,6 +7,8 @@ import re, socket from galaxy import util, datatypes, jobs, web, util import common from cgi import escape, FieldStorage +import urllib +import traceback log = logging.getLogger( __name__ ) @@ -496,6 +498,29 @@ class Universe(common.Root): def masthead( self, trans ): return trans.fill_template( "masthead.tmpl" ) + @web.expose + def dataset_errors( self, trans, id=None, **kwd ): + """View/fix errors associated with dataset""" + data = trans.app.model.Dataset.get( id ) + p = kwd + if p.get("fix_errors", None): + # launch tool to create new, (hopefully) error free dataset + tool_params = {} + tool_params["tool_id"] = 'fix_errors' + tool_params["runtool_btn"] = 'T' + tool_params["input"] = id + # send methods selected + repair_methods = data.datatype.repair_methods( data ) + methods = [] + for method, description in repair_methods: + if method in p: methods.append(method) + tool_params["methods"] = ",".join(methods) + url = "/tool_runner/index?" + urllib.urlencode(tool_params) + trans.response.send_redirect(url) + else: + history = trans.app.model.History.get( data.history_id ) + return trans.fill_template('dataset_errors.tmpl', data=data, history=history) + # ---- Debug methods ---------------------------------------------------- @web.expose @@ -551,4 +576,4 @@ class Universe(common.Root): new_child.flush() des.hid_counter = src.hid_counter self.app.model.flush() - return des \ No newline at end of file + return des diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index b7dc54adab4..37d4207d427 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -126,6 +126,9 @@ class Tool: self.command = '' # Short description of the tool self.description = util.xml_text(root, "description") + # Is this a 'hidden' tool (hidden in tool menu) + self.hidden = util.xml_text(root, "hidden") + if self.hidden: self.hidden = util.string_as_bool(self.hidden) # Load any tool specific code (optional) self.code_namespace = dict() for code_elem in root.findall("code"): @@ -620,16 +623,18 @@ class DefaultToolAction( object ): # Store data after custom code runs trans.app.model.flush() - - # Build the job's command line + + # Build params, done before hook so hook can use param_dict = tool.build_param_dict( incoming, inp_data, out_data ) - param_filename = tool.build_param_file( param_dict ) - command_line = tool.build_command_line( param_dict ) - + # Run the before queue ("exec_before_job") hook # FIXME: this hook should probably be called exec_before_job_queued tool.call_hook( 'exec_before_job', trans, inp_data=inp_data, out_data=out_data, tool=tool, param_dict=param_dict ) + + # Build the job's command line, moved to after the hook so the hook can alter params + param_filename = tool.build_param_file( param_dict ) + command_line = tool.build_command_line( param_dict ) # Create the job object job = trans.app.model.Job() diff --git a/lib/galaxy/tools/actions/upload.py b/lib/galaxy/tools/actions/upload.py index a62eeec71e4..fffc52d1bb2 100644 --- a/lib/galaxy/tools/actions/upload.py +++ b/lib/galaxy/tools/actions/upload.py @@ -1,7 +1,7 @@ import os, shutil, urllib, StringIO from galaxy import datatypes, jobs from galaxy.datatypes import sniff -from galaxy import model +from galaxy import model, util import sys, traceback @@ -89,7 +89,7 @@ class UploadToolAction( object ): # validate incomming data for error in data.datatype.validate( data ): data.add_validation_error( - model.ValidationError( message=str( error ), err_type=error.__class__.__name__, attributes=str( error.__dict__ ) ) ) + model.ValidationError( message=str( error ), err_type=error.__class__.__name__, attributes=util.object_to_string( error.__dict__ ) ) ) trans.history.add_dataset( data ) trans.app.model.flush() return data diff --git a/templates/history.tmpl b/templates/history.tmpl index 891fc8ebc2e..cc932d040a5 100644 --- a/templates/history.tmpl +++ b/templates/history.tmpl @@ -199,6 +199,11 @@ main();">
$data.display_peek
+
+