commit/galaxy-central: 7 new changesets
7 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/d3298df33143/ Changeset: d3298df33143 User: jmchilton Date: 2014-12-23 18:52:39+00:00 Summary: Make tool filters properties optional attributes of config. This way the tool shed doesn't need to pointlessly add them to its config object. Affected #: 2 files diff -r 3131a76ddd932911a80838d83aaf71baf26a3d6f -r d3298df33143d829bc9e9ed5d1cae0e1c39b60b1 lib/galaxy/tools/filters/__init__.py --- a/lib/galaxy/tools/filters/__init__.py +++ b/lib/galaxy/tools/filters/__init__.py @@ -20,9 +20,9 @@ self.default_filters = dict( tool=[ _not_hidden, _handle_requires_login ], section=[], label=[] ) # Add dynamic filters to these default filters. config = toolbox.app.config - self.__init_filters( "tool", config.tool_filters, self.default_filters ) - self.__init_filters( "section", config.tool_section_filters, self.default_filters ) - self.__init_filters( "label", config.tool_label_filters, self.default_filters ) + self.__init_filters( "tool", getattr( config, "tool_filters", "" ), self.default_filters ) + self.__init_filters( "section", getattr( config, "tool_section_filters", "" ), self.default_filters ) + self.__init_filters( "label", getattr( config, "tool_label_filters", "" ), self.default_filters ) def build_filters( self, trans, **kwds ): """ diff -r 3131a76ddd932911a80838d83aaf71baf26a3d6f -r d3298df33143d829bc9e9ed5d1cae0e1c39b60b1 lib/galaxy/webapps/tool_shed/config.py --- a/lib/galaxy/webapps/tool_shed/config.py +++ b/lib/galaxy/webapps/tool_shed/config.py @@ -50,9 +50,6 @@ self.test_conf = resolve_path( kwargs.get( "test_conf", "" ), self.root ) self.id_secret = kwargs.get( "id_secret", "USING THE DEFAULT IS NOT SECURE!" ) # Tool stuff - self.tool_filters = listify( kwargs.get( "tool_filters", [] ) ) - self.tool_label_filters = listify( kwargs.get( "tool_label_filters", [] ) ) - self.tool_section_filters = listify( kwargs.get( "tool_section_filters", [] ) ) self.tool_path = resolve_path( kwargs.get( "tool_path", "tools" ), self.root ) self.tool_secret = kwargs.get( "tool_secret", "" ) self.tool_data_path = resolve_path( kwargs.get( "tool_data_path", "shed-tool-data" ), os.getcwd() ) https://bitbucket.org/galaxy/galaxy-central/commits/175345aa482e/ Changeset: 175345aa482e User: jmchilton Date: 2014-12-23 18:52:39+00:00 Summary: Make use_tool_dependencies an optional attribute of config. This way the tool shed doesn't need to pointlessly configure this property to create a toolbox. Affected #: 2 files diff -r d3298df33143d829bc9e9ed5d1cae0e1c39b60b1 -r 175345aa482e4ef394e639b1a3688ee38ac84fc4 lib/galaxy/tools/deps/__init__.py --- a/lib/galaxy/tools/deps/__init__.py +++ b/lib/galaxy/tools/deps/__init__.py @@ -14,7 +14,7 @@ def build_dependency_manager( config ): - if config.use_tool_dependencies: + if getattr( config, "use_tool_dependencies", False ): dependency_manager_kwds = { 'default_base_path': config.tool_dependency_dir, 'conf_file': config.dependency_resolvers_config_file, diff -r d3298df33143d829bc9e9ed5d1cae0e1c39b60b1 -r 175345aa482e4ef394e639b1a3688ee38ac84fc4 lib/galaxy/webapps/tool_shed/config.py --- a/lib/galaxy/webapps/tool_shed/config.py +++ b/lib/galaxy/webapps/tool_shed/config.py @@ -59,13 +59,6 @@ self.ftp_upload_dir = kwargs.get( 'ftp_upload_dir', None ) # Install and test framework for testing tools contained in repositories. self.num_tool_test_results_saved = kwargs.get( 'num_tool_test_results_saved', 5 ) - # Location for dependencies - if 'tool_dependency_dir' in kwargs: - self.tool_dependency_dir = resolve_path( kwargs.get( "tool_dependency_dir" ), self.root ) - self.use_tool_dependencies = True - else: - self.tool_dependency_dir = None - self.use_tool_dependencies = False self.update_integrated_tool_panel = False # Galaxy flavor Docker Image self.enable_galaxy_flavor_docker_image = string_as_bool( kwargs.get( "enable_galaxy_flavor_docker_image", "False" ) ) https://bitbucket.org/galaxy/galaxy-central/commits/50150dc1e84a/ Changeset: 50150dc1e84a User: jmchilton Date: 2014-12-23 18:52:39+00:00 Summary: Update XML library use during tool parsing to elimiante FutureWarnings. Affected #: 5 files diff -r 175345aa482e4ef394e639b1a3688ee38ac84fc4 -r 50150dc1e84a33a2a5c9d73dd7e66c5b8fdc6eb8 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -742,13 +742,13 @@ root = getattr( tool_source, "root", None ) # TODO: mucking with the XML directly like this is terrible, # modify inputs directly post load if possible. - if root and hasattr( self.app, "job_config" ): # toolshed may not have job_config? - tool_id = root.get( 'id' ) if root else None + if root is not None and hasattr( self.app, "job_config" ): # toolshed may not have job_config? + tool_id = root.get( 'id' ) parameters = self.app.job_config.get_tool_resource_parameters( tool_id ) if parameters: inputs = root.find('inputs') # If tool has not inputs, create some so we can insert conditional - if not inputs: + if inputs is None: inputs = ElementTree.fromstring( "<inputs></inputs>") root.append( inputs ) # Insert a conditional allowing user to specify resource parameters. @@ -1563,7 +1563,7 @@ root = tool_source.root conf_parent_elem = root.find("configfiles") - if conf_parent_elem: + if conf_parent_elem is not None: for conf_elem in conf_parent_elem.findall( "configfile" ): name = conf_elem.get( "name" ) filename = conf_elem.get( "filename", None ) @@ -1697,7 +1697,7 @@ root = tool_source.root citations = [] citations_elem = root.find("citations") - if not citations_elem: + if citations_elem is None: return citations for citation_elem in citations_elem: diff -r 175345aa482e4ef394e639b1a3688ee38ac84fc4 -r 50150dc1e84a33a2a5c9d73dd7e66c5b8fdc6eb8 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -49,7 +49,7 @@ self.label = input_source.parse_label() self.help = input_source.parse_help() sanitizer_elem = input_source.parse_sanitizer_elem() - if sanitizer_elem: + if sanitizer_elem is not None: self.sanitizer = ToolParameterSanitizer.from_element( sanitizer_elem ) else: self.sanitizer = None diff -r 175345aa482e4ef394e639b1a3688ee38ac84fc4 -r 50150dc1e84a33a2a5c9d73dd7e66c5b8fdc6eb8 lib/galaxy/tools/parameters/input_translation.py --- a/lib/galaxy/tools/parameters/input_translation.py +++ b/lib/galaxy/tools/parameters/input_translation.py @@ -59,7 +59,7 @@ append_param = None value_trans_elem = req_param.find( 'value_translation' ) - if value_trans_elem: + if value_trans_elem is not None: for value_elem in value_trans_elem.findall( 'value' ): remote_value = value_elem.get( "remote_value" ) galaxy_value = value_elem.get( "galaxy_value" ) @@ -67,7 +67,7 @@ value_trans[ remote_value ] = galaxy_value append_param_elem = req_param.find( "append_param" ) - if append_param_elem: + if append_param_elem is not None: separator = append_param_elem.get( 'separator', ',' ) first_separator = append_param_elem.get( 'first_separator', None ) join_str = append_param_elem.get( 'join', '=' ) diff -r 175345aa482e4ef394e639b1a3688ee38ac84fc4 -r 50150dc1e84a33a2a5c9d73dd7e66c5b8fdc6eb8 lib/galaxy/tools/parameters/output.py --- a/lib/galaxy/tools/parameters/output.py +++ b/lib/galaxy/tools/parameters/output.py @@ -15,7 +15,7 @@ def __init__( self, parent, config_elem ): self.parent = parent self.actions = [] - if config_elem: + if config_elem is not None: for elem in config_elem: if elem.tag == "conditional": self.actions.append( ToolOutputActionConditional( self, elem ) ) diff -r 175345aa482e4ef394e639b1a3688ee38ac84fc4 -r 50150dc1e84a33a2a5c9d73dd7e66c5b8fdc6eb8 lib/galaxy/tools/parser/xml.py --- a/lib/galaxy/tools/parser/xml.py +++ b/lib/galaxy/tools/parser/xml.py @@ -604,7 +604,7 @@ def __init__(self, root): self.input_elem = root.find("inputs") page_sources = [] - if self.input_elem: + if self.input_elem is not None: pages_elem = self.input_elem.findall( "page" ) for page in ( pages_elem or [ self.input_elem ] ): page_sources.append(XmlPageSource(page)) https://bitbucket.org/galaxy/galaxy-central/commits/cf6352cc45a4/ Changeset: cf6352cc45a4 User: jmchilton Date: 2014-12-23 18:52:39+00:00 Summary: Start work on unit tests for galaxy.tools.ToolBox. Affected #: 2 files diff -r 50150dc1e84a33a2a5c9d73dd7e66c5b8fdc6eb8 -r cf6352cc45a45ffa3430d24944bd4ace50ba9c6a test/unit/tools/test_toolbox.py --- /dev/null +++ b/test/unit/tools/test_toolbox.py @@ -0,0 +1,75 @@ +import os +import unittest + +from galaxy.tools import ToolBox +from galaxy.model.tool_shed_install import mapping +import tools_support + + +class ToolBoxTestCase( unittest.TestCase, tools_support.UsesApp, tools_support.UsesTools ): + + def test_load_file( self ): + self._init_tool() + self.__add_config( """<toolbox><tool file="tool.xml" /></toolbox>""" ) + + toolbox = self.toolbox + assert toolbox.get_tool( "test_tool" ) is not None + assert toolbox.get_tool( "not_a_test_tool" ) is None + + def test_load_file_in_section( self ): + self._init_tool() + self.__add_config( """<toolbox><section id="t" name="test"><tool file="tool.xml" /></section></toolbox>""" ) + + toolbox = self.toolbox + assert toolbox.get_tool( "test_tool" ) is not None + assert toolbox.get_tool( "not_a_test_tool" ) is None + + def test_writes_integrate_tool_panel( self ): + self._init_tool() + self.__add_config( """<toolbox><tool file="tool.xml" /></toolbox>""" ) + + itp = os.path.join(self.test_directory, "integrated_tool_panel.xml") + + assert not os.path.exists( itp ) + self.toolbox + assert os.path.exists( itp ) + + def test_groups_tools( self ): + self._init_tool() + self.__add_config( """<toolbox><tool file="tool.xml" /></toolbox>""" ) + + def setUp( self ): + self.setup_app( mock_model=False ) + itp_config = os.path.join(self.test_directory, "integrated_tool_panel.xml") + self.app.config.integrated_tool_panel_config = itp_config + self.__toolbox = None + self.config_files = [] + + @property + def toolbox( self ): + if self.__toolbox is None: + self.__toolbox = SimplifiedToolBox( self ) + return self.__toolbox + + def __add_config( self, xml, name="tool_conf.xml" ): + path = os.path.join( self.test_directory, "tool_conf.xml" ) + with open( path, "w" ) as f: + f.write( xml ) + self.config_files.append( path ) + + +class SimplifiedToolBox( ToolBox ): + + def __init__( self, test_case ): + app = test_case.app + # Handle app/config stuff needed by toolbox but not by tools. + app.install_model = mapping.init( "sqlite:///:memory:", create_tables=True ) + app.job_config.get_tool_resource_parameters = lambda tool_id: None + app.config.update_integrated_tool_panel = True + config_files = test_case.config_files + tool_root_dir = test_case.test_directory + super( SimplifiedToolBox, self ).__init__( + config_files, + tool_root_dir, + app, + ) diff -r 50150dc1e84a33a2a5c9d73dd7e66c5b8fdc6eb8 -r cf6352cc45a45ffa3430d24944bd4ace50ba9c6a test/unit/tools_support.py --- a/test/unit/tools_support.py +++ b/test/unit/tools_support.py @@ -131,6 +131,7 @@ self.tool_data_tables = {} self.dataset_collections_service = None self.container_finder = NullContainerFinder() + self.name = "galaxy" class MockContext(object): https://bitbucket.org/galaxy/galaxy-central/commits/22151bb4fbca/ Changeset: 22151bb4fbca User: jmchilton Date: 2014-12-23 18:52:39+00:00 Summary: PEP-8 fixes to tool_shed.galaxy_install.tools.tool_panel_manager. Affected #: 1 file diff -r cf6352cc45a45ffa3430d24944bd4ace50ba9c6a -r 22151bb4fbca2519a7f97d71253b8890f5e9a472 lib/tool_shed/galaxy_install/tools/tool_panel_manager.py --- a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py +++ b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py @@ -1,5 +1,4 @@ import logging -import os import threading import galaxy.tools @@ -355,7 +354,7 @@ # If tool_panel_section_id is received, the section exists in the tool panel. In this # case, the value of the received tool_panel_section_id must be the id retrieved from a # tool panel config (e.g., tool_conf.xml, which may have getext). If new_tool_panel_section_label - # is received, a new section will be added to the tool panel. + # is received, a new section will be added to the tool panel. if new_tool_panel_section_label: section_id = str( new_tool_panel_section_label.lower().replace( ' ', '_' ) ) tool_panel_section_key, tool_section = \ @@ -396,7 +395,6 @@ tool_section_dicts = tool_panel_dict[ tool_panel_dict.keys()[ 0 ] ] tool_section_dict = tool_section_dicts[ 0 ] original_section_id = tool_section_dict[ 'id' ] - original_section_name = tool_section_dict[ 'name' ] if original_section_id: tool_panel_section_key, tool_section = \ self.get_or_create_tool_section( toolbox, https://bitbucket.org/galaxy/galaxy-central/commits/c161028f01af/ Changeset: c161028f01af User: jmchilton Date: 2014-12-23 18:52:39+00:00 Summary: Introduce abstraction for reindexing tool search. Fixes re-indexing after tool shed modifications for 5c44ac1 and reduces duplication. Affected #: 2 files diff -r 22151bb4fbca2519a7f97d71253b8890f5e9a472 -r c161028f01afc5a2aa3d5f701447fc84d1a9b578 lib/galaxy/config.py --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -706,10 +706,7 @@ from galaxy import tools self.toolbox = tools.ToolBox( tool_configs, self.config.tool_path, self ) - # Search support for tools - import galaxy.tools.search - index_help = getattr( self.config, "index_tool_help", True ) - self.toolbox_search = galaxy.tools.search.ToolBoxSearch( self.toolbox, index_help ) + self.reindex_tool_search() from galaxy.tools.deps import containers galaxy_root_dir = os.path.abspath(self.config.root) @@ -720,7 +717,13 @@ outputs_to_working_directory=self.config.outputs_to_working_directory, container_image_cache_path=self.config.container_image_cache_path, ) - self.container_finder = galaxy.tools.deps.containers.ContainerFinder(app_info) + self.container_finder = containers.ContainerFinder(app_info) + + def reindex_tool_search( self ): + # Call this when tools are added or removed. + import galaxy.tools.search + index_help = getattr( self.config, "index_tool_help", True ) + self.toolbox_search = galaxy.tools.search.ToolBoxSearch( self.toolbox, index_help ) def _configure_tool_data_tables( self, from_shed_config ): from galaxy.tools.data import ToolDataTableManager diff -r 22151bb4fbca2519a7f97d71253b8890f5e9a472 -r c161028f01afc5a2aa3d5f701447fc84d1a9b578 lib/tool_shed/galaxy_install/tools/tool_panel_manager.py --- a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py +++ b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py @@ -2,7 +2,6 @@ import threading import galaxy.tools -from galaxy.tools.search import ToolBoxSearch from xml.etree import ElementTree as XmlET from tool_shed.util import basic_util @@ -81,7 +80,7 @@ if self.app.config.update_integrated_tool_panel: # Write the current in-memory version of the integrated_tool_panel.xml file to disk. self.app.toolbox.write_integrated_tool_panel_config_file() - self.app.toolbox_search = ToolBoxSearch( self.app.toolbox ) + self.app.reindex_tool_search() def config_elems_to_xml_file( self, config_elems, config_filename, tool_path ): """ @@ -571,7 +570,7 @@ # Update the config_elems of the in-memory shed_tool_conf_dict. shed_tool_conf_dict[ 'config_elems' ] = config_elems self.app.toolbox.shed_tool_confs[ index ] = shed_tool_conf_dict - self.app.toolbox_search = ToolBoxSearch( self.app.toolbox ) + self.app.reindex_tool_search() if uninstall and self.app.config.update_integrated_tool_panel: # Write the current in-memory version of the integrated_tool_panel.xml file to disk. self.app.toolbox.write_integrated_tool_panel_config_file() https://bitbucket.org/galaxy/galaxy-central/commits/5328806e31ac/ Changeset: 5328806e31ac User: jmchilton Date: 2014-12-23 18:52:39+00:00 Summary: Introduce abstraction for updating ToolBox's shed configs. Hides some details of writing out integrated tool panel, reindexing, etc... from tool shed install code and reduces duplicatation in tool shed's tool_panel_manager. Add unit tests. Affected #: 3 files diff -r c161028f01afc5a2aa3d5f701447fc84d1a9b578 -r 5328806e31ac52e01f89b89d4d7873c38d9ae07b lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -244,6 +244,18 @@ return shed_config_dict return default + def update_shed_config( self, shed_conf_index, shed_conf, integrated_panel_changes=True ): + """ Update the in-memory descriptions of tools and write out the changes + to integrated tool panel unless we are just deactivating a tool (since + that doesn't affect that file). + """ + app = self.app + self.shed_tool_confs[ shed_conf_index ] = shed_conf + if integrated_panel_changes and app.config.update_integrated_tool_panel: + # Write the current in-memory version of the integrated_tool_panel.xml file to disk. + self.write_integrated_tool_panel_config_file() + app.reindex_tool_search() + def __resolve_tool_path(self, tool_path, config_filename): if not tool_path: # Default to backward compatible config setting. diff -r c161028f01afc5a2aa3d5f701447fc84d1a9b578 -r 5328806e31ac52e01f89b89d4d7873c38d9ae07b lib/tool_shed/galaxy_install/tools/tool_panel_manager.py --- a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py +++ b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py @@ -76,11 +76,7 @@ guid=guid ) # Replace the old list of in-memory config_elems with the new list for this shed_tool_conf_dict. shed_tool_conf_dict[ 'config_elems' ] = config_elems - self.app.toolbox.shed_tool_confs[ index ] = shed_tool_conf_dict - if self.app.config.update_integrated_tool_panel: - # Write the current in-memory version of the integrated_tool_panel.xml file to disk. - self.app.toolbox.write_integrated_tool_panel_config_file() - self.app.reindex_tool_search() + self.app.toolbox.update_shed_config( index, shed_tool_conf_dict ) def config_elems_to_xml_file( self, config_elems, config_filename, tool_path ): """ @@ -569,8 +565,4 @@ config_elems.remove( config_elem ) # Update the config_elems of the in-memory shed_tool_conf_dict. shed_tool_conf_dict[ 'config_elems' ] = config_elems - self.app.toolbox.shed_tool_confs[ index ] = shed_tool_conf_dict - self.app.reindex_tool_search() - if uninstall and self.app.config.update_integrated_tool_panel: - # Write the current in-memory version of the integrated_tool_panel.xml file to disk. - self.app.toolbox.write_integrated_tool_panel_config_file() + self.app.toolbox.update_shed_config( index, shed_tool_conf_dict, integrated_panel_changes=uninstall ) diff -r c161028f01afc5a2aa3d5f701447fc84d1a9b578 -r 5328806e31ac52e01f89b89d4d7873c38d9ae07b test/unit/tools/test_toolbox.py --- a/test/unit/tools/test_toolbox.py +++ b/test/unit/tools/test_toolbox.py @@ -28,23 +28,53 @@ self._init_tool() self.__add_config( """<toolbox><tool file="tool.xml" /></toolbox>""" ) - itp = os.path.join(self.test_directory, "integrated_tool_panel.xml") - - assert not os.path.exists( itp ) + self.assert_integerated_tool_panel(exists=False) self.toolbox - assert os.path.exists( itp ) + self.assert_integerated_tool_panel(exists=True) def test_groups_tools( self ): self._init_tool() self.__add_config( """<toolbox><tool file="tool.xml" /></toolbox>""" ) + def test_update_shed_conf(self): + self.__setup_shed_tool_conf() + self.toolbox.update_shed_config( 0, {} ) + assert self.reindexed + self.assert_integerated_tool_panel(exists=True) + + def test_update_shed_conf_deactivate_only(self): + self.__setup_shed_tool_conf() + self.toolbox.update_shed_config( 0, {}, integrated_panel_changes=False ) + assert self.reindexed + # No changes, should be regenerated + self.assert_integerated_tool_panel(exists=False) + def setUp( self ): + self.reindexed = False self.setup_app( mock_model=False ) + self.app.reindex_tool_search = self.__reindex itp_config = os.path.join(self.test_directory, "integrated_tool_panel.xml") self.app.config.integrated_tool_panel_config = itp_config self.__toolbox = None self.config_files = [] + def __reindex( self ): + self.reindexed = True + + def __remove_itp( self ): + os.remove( os.path) + + @property + def integerated_tool_panel_path( self ): + return os.path.join(self.test_directory, "integrated_tool_panel.xml") + + def assert_integerated_tool_panel( self, exists=True ): + does_exist = os.path.exists( self.integerated_tool_panel_path ) + if exists: + assert does_exist + else: + assert not does_exist + @property def toolbox( self ): if self.__toolbox is None: @@ -57,6 +87,14 @@ f.write( xml ) self.config_files.append( path ) + def __setup_shed_tool_conf( self ): + self.__add_config( """<toolbox tool_path="."></toolbox>""" ) + + self.toolbox # create toolbox + assert not self.reindexed + + os.remove( self.integerated_tool_panel_path ) + class SimplifiedToolBox( ToolBox ): 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)
-
commits-noreply@bitbucket.org