4 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/67da1098be88/ changeset: 67da1098be88 user: dan date: 2012-11-06 21:46:57 summary: Add a helper menthol "params_to_incoming" that takes a set of parameters and populates a dictionary as if it were an incoming html post. affected #: 1 file
diff -r aba101adc4a7012f6c959c23ea5f1b8701667649 -r 67da1098be8881f223f469c53ef7dc3528409343 lib/galaxy/tools/parameters/__init__.py --- a/lib/galaxy/tools/parameters/__init__.py +++ b/lib/galaxy/tools/parameters/__init__.py @@ -94,3 +94,26 @@ value = params[key].value_from_basic( value, app, ignore_errors ) rval[ key ] = value return rval + +def params_to_incoming( incoming, inputs, input_values, app, name_prefix="" ): + """ + Given a tool's parameter definition (`inputs`) and a specific set of + parameter `input_values` objects, populate `incoming` with the html values. + + Useful for e.g. the rerun function. + """ + for input in inputs.itervalues(): + if isinstance( input, Repeat ) or isinstance( input, UploadDataset ): + for i, d in enumerate( input_values[ input.name ] ): + index = d['__index__'] + new_name_prefix = name_prefix + "%s_%d|" % ( input.name, index ) + params_to_incoming( incoming, input.inputs, d, app, new_name_prefix ) + elif isinstance( input, Conditional ): + values = input_values[ input.name ] + current = values["__current_case__"] + new_name_prefix = name_prefix + input.name + "|" + incoming[ new_name_prefix + input.test_param.name ] = values[ input.test_param.name ] + params_to_incoming( incoming, input.cases[current].inputs, values, app, new_name_prefix ) + else: + incoming[ name_prefix + input.name ] = input.to_string( input_values.get( input.name ), app ) +
https://bitbucket.org/galaxy/galaxy-central/changeset/50513229f6ef/ changeset: 50513229f6ef user: dan date: 2012-11-06 21:46:57 summary: Allow passing old_errors to handle_input. Fixes for handling old_errors in handle_input for grouping parameters. affected #: 1 file
diff -r 67da1098be8881f223f469c53ef7dc3528409343 -r 50513229f6ef8338361d838a40c956108836465d lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -1731,7 +1731,7 @@ callback( "", input, value[input.name] ) else: input.visit_inputs( "", value[input.name], callback ) - def handle_input( self, trans, incoming, history=None ): + def handle_input( self, trans, incoming, history=None, old_errors=None ): """ Process incoming parameters for this tool from the dict `incoming`, update the tool state (or create if none existed), and either return @@ -1766,7 +1766,7 @@ else: # Update state for all inputs on the current page taking new # values from `incoming`. - errors = self.update_state( trans, self.inputs_by_page[state.page], state.inputs, incoming ) + errors = self.update_state( trans, self.inputs_by_page[state.page], state.inputs, incoming, old_errors=old_errors or {} ) # If the tool provides a `validate_input` hook, call it. validate_input = self.get_hook( 'validate_input' ) if validate_input: @@ -1895,7 +1895,10 @@ any_group_errors = True # Only need to find one that can't be removed due to size, since only # one removal is processed at # a time anyway - break + break + elif group_old_errors and group_old_errors[i]: + group_errors[i] = group_old_errors[i] + any_group_errors = True # Update state max_index = -1 for i, rep_state in enumerate( group_state ): @@ -1978,6 +1981,8 @@ update_only=update_only, old_errors=group_old_errors, item_callback=item_callback ) + if input.test_param.name in group_old_errors and not test_param_error: + test_param_error = group_old_errors[ input.test_param.name ] if test_param_error: group_errors[ input.test_param.name ] = test_param_error if group_errors:
https://bitbucket.org/galaxy/galaxy-central/changeset/81a007dbc152/ changeset: 81a007dbc152 user: dan date: 2012-11-06 21:46:57 summary: Rework rerun functionality to treat the previously set job parameters as though they are an incoming form post. This allows validation and subsequent display of errors between the original and current states. affected #: 1 file
diff -r 50513229f6ef8338361d838a40c956108836465d -r 81a007dbc1528a6124dfdc9caf05579887fe0d4c lib/galaxy/webapps/galaxy/controllers/tool_runner.py --- a/lib/galaxy/webapps/galaxy/controllers/tool_runner.py +++ b/lib/galaxy/webapps/galaxy/controllers/tool_runner.py @@ -6,6 +6,7 @@ from galaxy.util.bunch import Bunch from galaxy.tools import DefaultToolState from galaxy.tools.parameters.basic import UnvalidatedValue +from galaxy.tools.parameters import params_to_incoming from galaxy.tools.actions import upload_common
import logging @@ -192,25 +193,29 @@ if isinstance(value,list): values = [] for val in value: - if val not in history.datasets and val in hda_source_dict: + if val in history.datasets: + values.append( val ) + elif val in hda_source_dict: values.append( hda_source_dict[ val ]) return values if value not in history.datasets and value in hda_source_dict: return hda_source_dict[ value ] visit_input_values( tool.inputs, params_objects, rerun_callback ) - # Create a fake tool_state for the tool, with the parameters values + # Create a fake tool_state for the tool, with the parameters values state = tool.new_state( trans ) state.inputs = params_objects - tool_state_string = util.object_to_string(state.encode(tool, trans.app)) - # Setup context for template - vars = dict( tool_state=state, errors = upgrade_messages ) + #create an incoming object from the original job's dataset-modified param objects + incoming = {} + params_to_incoming( incoming, tool.inputs, params_objects, trans.app ) + incoming[ "tool_state" ] = util.object_to_string( state.encode( tool, trans.app ) ) + template, vars = tool.handle_input( trans, incoming, old_errors=upgrade_messages ) #update new state with old parameters # Is the "add frame" stuff neccesary here? add_frame = AddFrameData() add_frame.debug = trans.debug if from_noframe is not None: add_frame.wiki_url = trans.app.config.wiki_url add_frame.from_noframe = True - return trans.fill_template( "tool_form.mako", + return trans.fill_template( template, history=history, toolbox=self.get_toolbox(), tool_version_select_field=tool_version_select_field,
https://bitbucket.org/galaxy/galaxy-central/changeset/907f364107c5/ changeset: 907f364107c5 user: dan date: 2012-11-06 21:46:58 summary: Add error messages for a DataToolParameter when the provided value is no longer valid due to be deleted or being in an error state. affected #: 1 file
diff -r 81a007dbc1528a6124dfdc9caf05579887fe0d4c -r 907f364107c534cd531b4d91fcda7fe3e59eb4b1 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1539,25 +1539,38 @@ if trans.workflow_building_mode: return None if not value: - raise ValueError( "History does not include a dataset of the required format / build" ) + raise ValueError( "History does not include a dataset of the required format / build" ) if value in [None, "None"]: return None if isinstance( value, list ): - return [ trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( v ) for v in value ] + rval = [ trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( v ) for v in value ] elif isinstance( value, trans.app.model.HistoryDatasetAssociation ): - return value + rval = value else: - return trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( value ) + rval = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( value ) + if isinstance( rval, list ): + values = rval + else: + values = [ rval ] + for v in values: + if v: + if v.deleted: + raise ValueError( "The previously selected dataset has been previously deleted" ) + if v.dataset.state in [galaxy.model.Dataset.states.ERROR, galaxy.model.Dataset.states.DISCARDED ]: + raise ValueError( "The previously selected dataset has entered an unusable state" ) + return rval
def to_string( self, value, app ): - if value is None or isinstance( value, str ): + if value is None or isinstance( value, basestring ): return value + elif isinstance( value, int ): + return str( value ) elif isinstance( value, DummyDataset ): return None elif isinstance( value, list) and len(value) > 0 and isinstance( value[0], DummyDataset): return None elif isinstance( value, list ): - return ",".join( [ val if isinstance( val, str ) else str(val.id) for val in value] ) + return ",".join( [ val if isinstance( val, basestring ) else str(val.id) for val in value] ) return value.id
def to_python( self, value, app ):
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.
galaxy-commits@lists.galaxyproject.org