commit/galaxy-central: dan: Better handling of implict datatype conversion and dynamic options. Still lots of cleanup to do.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/0886ed0a8c9f/ changeset: 0886ed0a8c9f user: dan date: 2011-06-10 00:35:42 summary: Better handling of implict datatype conversion and dynamic options. Still lots of cleanup to do. affected #: 4 files (815 bytes) --- a/lib/galaxy/tools/__init__.py Thu Jun 09 17:49:20 2011 -0400 +++ b/lib/galaxy/tools/__init__.py Thu Jun 09 18:35:42 2011 -0400 @@ -798,6 +798,8 @@ elif elem.tag == "param": param = self.parse_param_elem( elem, enctypes, context ) rval[param.name] = param + if hasattr( param, 'data_ref' ): + param.ref_input = context[ param.data_ref ] return rval def parse_param_elem( self, input_elem, enctypes, context ): @@ -923,8 +925,6 @@ if not self.check_values: return for input in self.inputs.itervalues(): - if input.name not in value: - value[input.name] = input.get_initial_value( None, value ) if isinstance( input, ToolParameter ): callback( "", input, value[input.name] ) else: --- a/lib/galaxy/tools/actions/__init__.py Thu Jun 09 17:49:20 2011 -0400 +++ b/lib/galaxy/tools/actions/__init__.py Thu Jun 09 18:35:42 2011 -0400 @@ -37,7 +37,7 @@ if data and not isinstance( data.datatype, formats ): # Need to refresh in case this conversion just took place, i.e. input above in tool performed the same conversion trans.sa_session.refresh( data ) - target_ext, converted_dataset = data.find_conversion_destination( formats, converter_safe = input.converter_safe( param_values, trans ) ) + target_ext, converted_dataset = data.find_conversion_destination( formats ) if target_ext: if converted_dataset: data = converted_dataset --- a/lib/galaxy/tools/parameters/basic.py Thu Jun 09 17:49:20 2011 -0400 +++ b/lib/galaxy/tools/parameters/basic.py Thu Jun 09 18:35:42 2011 -0400 @@ -714,6 +714,9 @@ # Dependency on a value that does not yet exist if isinstance( dep_value, RuntimeValue ): return True + #dataset not ready yet + if hasattr( self, 'ref_input' ) and isinstance( dep_value, self.tool.app.model.HistoryDatasetAssociation ) and ( dep_value.is_pending or not isinstance( dep_value.datatype, self.ref_input.formats ) ): + return True # Dynamic, but all dependenceis are known and have values return False def get_initial_value( self, trans, context ): @@ -844,6 +847,7 @@ self.force_select = string_as_bool( elem.get( "force_select", True )) self.accept_default = string_as_bool( elem.get( "accept_default", False )) self.data_ref = elem.get( "data_ref", None ) + self.ref_input = None self.default_value = elem.get( "default_value", None ) self.is_dynamic = True def from_html( self, value, trans=None, context={} ): @@ -939,7 +943,7 @@ if not dataset.metadata.columns: # Only allow late validation if the dataset is not yet ready # (since we have reason to expect the metadata to be ready eventually) - if dataset.is_pending: + if dataset.is_pending or not isinstance( dataset.datatype, self.ref_input.formats ): return True # No late validation return False @@ -1321,7 +1325,7 @@ selected = ( value and ( hda in value ) ) field.add_option( "%s: %s" % ( hid, hda_name ), hda.id, selected ) else: - target_ext, converted_dataset = hda.find_conversion_destination( self.formats, converter_safe = self.converter_safe( other_values, trans ) ) + target_ext, converted_dataset = hda.find_conversion_destination( self.formats ) if target_ext: if converted_dataset: hda = converted_dataset @@ -1370,13 +1374,22 @@ pass #no valid options def dataset_collector( datasets ): def is_convertable( dataset ): - target_ext, converted_dataset = dataset.find_conversion_destination( self.formats, converter_safe = self.converter_safe( context, trans ) ) + target_ext, converted_dataset = dataset.find_conversion_destination( self.formats ) if target_ext is not None: return True return False for i, data in enumerate( datasets ): - if data.visible and not data.deleted and data.state not in [data.states.ERROR, data.states.DISCARDED] and ( isinstance( data.datatype, self.formats) or is_convertable( data ) ): - if self.options and self._options_filter_attribute( data ) != filter_value: + if data.visible and not data.deleted and data.state not in [data.states.ERROR, data.states.DISCARDED]: + is_valid = False + if isinstance( data.datatype, self.formats ): + is_valid = True + else: + target_ext, converted_dataset = data.find_conversion_destination( self.formats ) + if target_ext: + is_valid = True + if converted_dataset: + data = converted_dataset + if not is_valid or ( self.options and self._options_filter_attribute( data ) != filter_value ): continue most_recent_dataset[0] = data # Also collect children via association object --- a/lib/galaxy/tools/parameters/dynamic_options.py Thu Jun 09 17:49:20 2011 -0400 +++ b/lib/galaxy/tools/parameters/dynamic_options.py Thu Jun 09 18:35:42 2011 -0400 @@ -440,6 +440,9 @@ # Load Validators for validator in elem.findall( 'validator' ): self.validators.append( validation.Validator.from_element( self.tool_param, validator ) ) + + if self.dataset_ref_name: + tool_param.data_ref = self.dataset_ref_name def parse_column_definitions( self, elem ): for column_elem in elem.findall( 'column' ): 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