commit/galaxy-central: greg: Fix the DataTableManager to handle directories other than ~/tool-data.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/b761471d7590/ changeset: b761471d7590 user: greg date: 2012-06-14 20:33:21 summary: Fix the DataTableManager to handle directories other than ~/tool-data. affected #: 4 files diff -r bef69fd3fcc191b9a9a4d140876a6ee932e9fc3e -r b761471d759097f03c0fb904e9543f02ed5096c9 lib/galaxy/jobs/deferred/genome_transfer.py --- a/lib/galaxy/jobs/deferred/genome_transfer.py +++ b/lib/galaxy/jobs/deferred/genome_transfer.py @@ -34,7 +34,7 @@ self.tool = app.toolbox.tools_by_id['__GENOME_INDEX__'] self.sa_session = app.model.context.current tdtman = ToolDataTableManager() - xmltree = tdtman.load_from_config_file(app.config.tool_data_table_config_path) + xmltree = tdtman.load_from_config_file( app.config.tool_data_table_config_path, app.config.tool_data_path ) for node in xmltree: table = node.get('name') location = node.findall('file')[0].get('path') diff -r bef69fd3fcc191b9a9a4d140876a6ee932e9fc3e -r b761471d759097f03c0fb904e9543f02ed5096c9 lib/galaxy/tools/data/__init__.py --- a/lib/galaxy/tools/data/__init__.py +++ b/lib/galaxy/tools/data/__init__.py @@ -24,7 +24,7 @@ return self.data_tables.__getitem__( key ) def __contains__( self, key ): return self.data_tables.__contains__( key ) - def load_from_config_file( self, config_filename ): + def load_from_config_file( self, config_filename, tool_data_path ): tree = util.parse_xml( config_filename ) root = tree.getroot() table_elems = [] @@ -36,12 +36,12 @@ if table_elem_name and table_elem_name not in self.data_table_elem_names: self.data_table_elem_names.append( table_elem_name ) self.data_table_elems.append( table_elem ) - table = tool_data_table_types[ type ]( table_elem ) + table = tool_data_table_types[ type ]( table_elem, tool_data_path ) if table.name not in self.data_tables: self.data_tables[ table.name ] = table log.debug( "Loaded tool data table '%s'", table.name ) return table_elems - def add_new_entries_from_config_file( self, config_filename, tool_data_table_config_path, persist=False ): + def add_new_entries_from_config_file( self, config_filename, tool_data_path, tool_data_table_config_path, persist=False ): """ This method is called when a tool shed repository that includes a tool_data_table_conf.xml.sample file is being installed into a local galaxy instance. We have 2 cases to handle, files whose root tag is <tables>, for example: @@ -64,7 +64,7 @@ # Make a copy of the current list of data_table_elem_names so we can persist later if changes to the config file are necessary. original_data_table_elem_names = [ name for name in self.data_table_elem_names ] if root.tag == 'tables': - table_elems = self.load_from_config_file( config_filename ) + table_elems = self.load_from_config_file( config_filename, tool_data_path ) else: table_elems = [] type = root.get( 'type', 'tabular' ) @@ -74,7 +74,7 @@ if table_elem_name and table_elem_name not in self.data_table_elem_names: self.data_table_elem_names.append( table_elem_name ) self.data_table_elems.append( root ) - table = tool_data_table_types[ type ]( root ) + table = tool_data_table_types[ type ]( root, tool_data_path ) if table.name not in self.data_tables: self.data_tables[ table.name ] = table log.debug( "Added new tool data table '%s'", table.name ) @@ -97,8 +97,9 @@ os.chmod( full_path, 0644 ) class ToolDataTable( object ): - def __init__( self, config_element ): + def __init__( self, config_element, tool_data_path ): self.name = config_element.get( 'name' ) + self.tool_data_path = tool_data_path self.missing_index_file = None class TabularToolDataTable( ToolDataTable ): @@ -115,8 +116,8 @@ type_key = 'tabular' - def __init__( self, config_element ): - super( TabularToolDataTable, self ).__init__( config_element ) + def __init__( self, config_element, tool_data_path ): + super( TabularToolDataTable, self ).__init__( config_element, tool_data_path ) self.configure_and_load( config_element ) def configure_and_load( self, config_element ): """ @@ -128,11 +129,24 @@ self.parse_column_spec( config_element ) # Read every file all_rows = [] + found = False for file_element in config_element.findall( 'file' ): filename = file_element.get( 'path' ) if os.path.exists( filename ): + found = True all_rows.extend( self.parse_file_fields( open( filename ) ) ) else: + # Since the path attribute can include a hard-coded path to a specific directory + # (e.g., <file path="tool-data/cg_crr_files.loc" />) which may not be the same value + # as self.tool_data_path, we'll parse the path to get the filename and see if it is + # in self.tool_data_path. + file_path, file_name = os.path.split( filename ) + if file_path and file_path != self.tool_data_path: + corrected_filename = os.path.join( self.tool_data_path, file_name ) + if os.path.exists( corrected_filename ): + found = True + all_rows.extend( self.parse_file_fields( open( corrected_filename ) ) ) + if not found: self.missing_index_file = filename log.warn( "Cannot find index file '%s' for tool data table '%s'" % ( filename, self.name ) ) self.data = all_rows diff -r bef69fd3fcc191b9a9a4d140876a6ee932e9fc3e -r b761471d759097f03c0fb904e9543f02ed5096c9 lib/galaxy/tools/genome_index/__init__.py --- a/lib/galaxy/tools/genome_index/__init__.py +++ b/lib/galaxy/tools/genome_index/__init__.py @@ -67,7 +67,7 @@ if gitd: destination = None tdtman = ToolDataTableManager() - xmltree = tdtman.load_from_config_file(app.config.tool_data_table_config_path) + xmltree = tdtman.load_from_config_file( app.config.tool_data_table_config_path, app.config.tool_data_path ) for node in xmltree: table = node.get('name') location = node.findall('file')[0].get('path') diff -r bef69fd3fcc191b9a9a4d140876a6ee932e9fc3e -r b761471d759097f03c0fb904e9543f02ed5096c9 lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ b/lib/galaxy/webapps/community/controllers/common.py @@ -427,12 +427,12 @@ if datatypes_config: metadata_dict = generate_datatypes_metadata( datatypes_config, metadata_dict ) sample_files, deleted_sample_files = get_list_of_copied_sample_files( repo, ctx, dir=work_dir ) + if sample_files: + trans.app.config.tool_data_path = work_dir # Handle the tool_data_table_conf.xml.sample file if it is included in the repository. if 'tool_data_table_conf.xml.sample' in sample_files: tool_data_table_config = copy_file_from_manifest( repo, ctx, 'tool_data_table_conf.xml.sample', work_dir ) error, correction_msg = handle_sample_tool_data_table_conf_file( trans.app, tool_data_table_config ) - if sample_files: - trans.app.config.tool_data_path = work_dir for filename in ctx: # Find all tool configs. ctx_file_name = strip_path( filename ) 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