[hg] galaxy 2596: Fix collect_primary_datasets() and add collect...
details: http://www.bx.psu.edu/hg/galaxy/rev/b77721ef035d changeset: 2596:b77721ef035d user: Dan Blankenberg <dan@bx.psu.edu> date: Fri Aug 21 17:03:42 2009 -0400 description: Fix collect_primary_datasets() and add collected primary/child datasets to job. Add new filter to dynamic_options: remove_value. Fix error in exception when reruning a dataset with a JobToOutputDatasetAssociation but with no job. 3 file(s) affected in this change: lib/galaxy/tools/__init__.py lib/galaxy/tools/parameters/dynamic_options.py lib/galaxy/web/controllers/tool_runner.py diffs (150 lines): diff -r 108533bf35b8 -r b77721ef035d lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py Fri Aug 21 15:18:17 2009 -0400 +++ b/lib/galaxy/tools/__init__.py Fri Aug 21 17:03:42 2009 -0400 @@ -1534,10 +1534,19 @@ child_dataset.flush() child_dataset.set_size() child_dataset.name = "Secondary Dataset (%s)" % ( designation ) - child_dataset.state = child_dataset.states.OK child_dataset.init_meta() child_dataset.set_meta() child_dataset.set_peek() + # Associate new dataset with job + job = None + for assoc in outdata.creating_job_associations: + job = assoc.job + break + if job: + assoc = self.app.model.JobToOutputDatasetAssociation( '__new_child_file_%s__' % designation, child_dataset ) + assoc.job = job + assoc.flush() + child_dataset.state = outdata.state child_dataset.flush() # Add child to return dict children[name][designation] = child_dataset @@ -1550,7 +1559,7 @@ def collect_primary_datasets( self, output): primary_datasets = {} - #Loop through output file names, looking for generated primary datasets in form of 'primary_associatedWithDatasetID_designation_visibility_extension' + #Loop through output file names, looking for generated primary datasets in form of 'primary_associatedWithDatasetID_designation_visibility_extension(_DBKEY)' for name, outdata in output.items(): for filename in glob.glob(os.path.join(self.app.config.new_file_path,"primary_%i_*" % outdata.id) ): if not name in primary_datasets: @@ -1563,19 +1572,32 @@ if visible == "visible": visible = True else: visible = False ext = fields.pop(0).lower() + dbkey = outdata.dbkey + if fields: + dbkey = fields[ 0 ] # Create new primary dataset - primary_data = self.app.model.HistoryDatasetAssociation( extension=ext, designation=designation, visible=visible, dbkey=outdata.dbkey, create_dataset=True ) + primary_data = self.app.model.HistoryDatasetAssociation( extension=ext, designation=designation, visible=visible, dbkey=dbkey, create_dataset=True ) self.app.security_agent.copy_dataset_permissions( outdata.dataset, primary_data.dataset ) primary_data.flush() # Move data from temp location to dataset location shutil.move( filename, primary_data.file_name ) primary_data.set_size() - primary_data.name = dataset.name - primary_data.info = dataset.info - primary_data.state = primary_data.states.OK - primary_data.init_meta( copy_from=dataset ) + primary_data.name = outdata.name + primary_data.info = outdata.info + primary_data.init_meta( copy_from=outdata ) + primary_data.dbkey = dbkey primary_data.set_meta() primary_data.set_peek() + # Associate new dataset with job + job = None + for assoc in outdata.creating_job_associations: + job = assoc.job + break + if job: + assoc = self.app.model.JobToOutputDatasetAssociation( '__new_primary_file_%s__' % designation, primary_data ) + assoc.job = job + assoc.flush() + primary_data.state = outdata.state primary_data.flush() outdata.history.add_dataset( primary_data ) # Add dataset to return dict diff -r 108533bf35b8 -r b77721ef035d lib/galaxy/tools/parameters/dynamic_options.py --- a/lib/galaxy/tools/parameters/dynamic_options.py Fri Aug 21 15:18:17 2009 -0400 +++ b/lib/galaxy/tools/parameters/dynamic_options.py Fri Aug 21 17:03:42 2009 -0400 @@ -242,6 +242,55 @@ rval.append( add_value ) return rval +class RemoveValueFilter( Filter ): + """ + Removes a value from an options list. + + Type: remove_value + + Required Attributes: + value: value to remove from select list + or + ref: param to refer to + or + meta_ref: dataset to refer to + key: metadata key to compare to + """ + def __init__( self, d_option, elem ): + Filter.__init__( self, d_option, elem ) + self.value = elem.get( "value", None ) + self.ref_name = elem.get( "ref", None ) + self.meta_ref = elem.get( "meta_ref", None ) + self.metadata_key = elem.get( "key", None ) + assert self.value is not None or ( ( self.ref_name is not None or self.meta_ref is not None )and self.metadata_key is not None ), ValueError( "Required 'value' or 'ref' and 'key' attributes missing from filter" ) + self.multiple = string_as_bool( elem.get( "multiple", "False" ) ) + self.separator = elem.get( "separator", "," ) + def filter_options( self, options, trans, other_values ): + if trans is not None and trans.workflow_building_mode: return options + assert self.value is not None or ( self.ref_name is not None and self.ref_name in other_values ) or (self.meta_ref is not None and self.meta_ref in other_values ) or ( trans is not None and trans.workflow_building_mode), Exception( "Required dependency '%s' or '%s' not found in incoming values" % ( self.ref_name, self.meta_ref ) ) + def compare_value( option_value, filter_value ): + if isinstance( filter_value, list ): + if self.multiple: + option_value = option_value.split( self.separator ) + for value in filter_value: + if value not in filter_value: + return False + return True + return option_value in filter_value + if self.multiple: + return filter_value in option_value.split( self.separator ) + return option_value == filter_value + value = self.value + if value is None: + if self.ref_name is not None: + value = other_values.get( self.ref_name ) + else: + data_ref = other_values.get( self.meta_ref ) + if not isinstance( data_ref, self.dynamic_option.tool_param.tool.app.model.HistoryDatasetAssociation ): + return options #cannot modify options + value = data_ref.metadata.get( self.metadata_key, None ) + return [ ( disp_name, optval, selected ) for disp_name, optval, selected in options if not compare_value( optval, value ) ] + class SortByColumnFilter( Filter ): """ Sorts an options list by a column @@ -274,6 +323,7 @@ unique_value = UniqueValueFilter, multiple_splitter = MultipleSplitterFilter, add_value = AdditionalValueFilter, + remove_value = RemoveValueFilter, sort_by = SortByColumnFilter ) class DynamicOptions( object ): diff -r 108533bf35b8 -r b77721ef035d lib/galaxy/web/controllers/tool_runner.py --- a/lib/galaxy/web/controllers/tool_runner.py Fri Aug 21 15:18:17 2009 -0400 +++ b/lib/galaxy/web/controllers/tool_runner.py Fri Aug 21 17:03:42 2009 -0400 @@ -82,7 +82,7 @@ job = assoc.job break if not job: - raise Exception("Failed to get job information for dataset hid %d" % hid) + raise Exception("Failed to get job information for dataset hid %d" % data.hid) # Get the tool object tool_id = job.tool_id try:
participants (1)
-
Greg Von Kuster