commit/galaxy-central: 4 new changesets
4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/a8cf78bd3629/ Changeset: a8cf78bd3629 User: jmchilton Date: 2015-01-01 15:02:23+00:00 Summary: PEP-8 fix for lib/tool_shed/tools/tool_version_manager.py. Affected #: 1 file diff -r bb548455022c7ad21c74ba61b4fe37b606737db7 -r a8cf78bd3629e4d9fa28e2641b670efb78ba2a56 lib/tool_shed/tools/tool_version_manager.py --- a/lib/tool_shed/tools/tool_version_manager.py +++ b/lib/tool_shed/tools/tool_version_manager.py @@ -1,5 +1,4 @@ import logging -import os from galaxy.model.orm import and_ https://bitbucket.org/galaxy/galaxy-central/commits/81a99e6f570e/ Changeset: 81a99e6f570e User: jmchilton Date: 2015-01-01 15:02:23+00:00 Summary: Unit test to verify tool panel handles multiple successive TS install... In particular that the integrated panel reflects all the installed tools but that they are groupped correctly in ToolBox._tool_panel. Affected #: 3 files diff -r a8cf78bd3629e4d9fa28e2641b670efb78ba2a56 -r 81a99e6f570ef0b0cb6511bfd9ee4dd767490fef test/unit/tool_shed_unit_tests/test_tool_panel_manager.py --- a/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py +++ b/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py @@ -5,6 +5,10 @@ from tools.test_toolbox import BaseToolBoxTestCase from tool_shed.galaxy_install.tools import tool_panel_manager +from tool_shed.tools import tool_version_manager + +DEFAULT_GUID = "123456" + class ToolPanelManagerTestCase( BaseToolBoxTestCase ): @@ -34,15 +38,14 @@ assert len( toolbox._tool_panel ) == 2 def test_add_tool_to_panel( self ): - self._init_tool() - self._add_config( """<toolbox tool_path="%s"></toolbox>""" % self.test_directory ) - tool_path = os.path.join(self.test_directory, "tool.xml") - self.tool.guid = "123456" - new_tools = [{"guid": "123456", "tool_config": tool_path}] + self._init_ts_tool( guid=DEFAULT_GUID ) + self._init_dynamic_tool_conf() + tool_path = self._tool_path() + new_tools = [{"guid": DEFAULT_GUID, "tool_config": tool_path}] repository_tools_tups = [ ( tool_path, - "123456", + DEFAULT_GUID, self.tool, ) ] @@ -63,6 +66,51 @@ ) self._verify_tool_confs() + def test_add_twice( self ): + self._init_dynamic_tool_conf() + tool_versions = {} + previous_guid = None + for v in "1", "2", "3": + changeset = "0123456789abcde%s" % v + guid = DEFAULT_GUID + ("v%s" % v) + tool = self._init_ts_tool( guid=guid, filename="tool_v%s.xml" % v ) + tool_path = self._tool_path( name="tool_v%s.xml" % v ) + new_tools = [{"guid": guid, "tool_config": tool_path}] + tool_shed_repository = self._repo_install( changeset ) + repository_tools_tups = [ + ( + tool_path, + guid, + tool, + ) + ] + _, section = self.toolbox.get_section("tid1", create_if_needed=True) + tpm = self.tpm + tool_panel_dict = tpm.generate_tool_panel_dict_for_new_install( + tool_dicts=new_tools, + tool_section=section, + ) + if previous_guid: + tool_versions[ guid ] = previous_guid + self.tvm.handle_tool_versions( [tool_versions], tool_shed_repository ) + tpm.add_to_tool_panel( + repository_name="example", + repository_clone_url="github.com", + changeset_revision=changeset, + repository_tools_tups=repository_tools_tups, + owner="galaxyproject", + shed_tool_conf="tool_conf.xml", + tool_panel_dict=tool_panel_dict, + ) + self._verify_tool_confs() + section = self.toolbox._tool_panel["tid1"] + # New GUID replaced old one in tool panel but both + # appear in integrated tool panel. + if previous_guid: + assert ("tool_%s" % previous_guid) not in section.panel_items() + assert ("tool_%s" % guid) in self.toolbox._integrated_tool_panel["tid1"].panel_items() + previous_guid = guid + def test_deactivate_in_section( self ): self._setup_two_versions_remove_one( section=True, uninstall=False ) self._verify_version_2_removed_from_panel( ) @@ -154,6 +202,19 @@ message = message_template % ( filename, open( filename, "r" ).read() ) raise AssertionError( message ) + def _init_dynamic_tool_conf( self ): + # Add a dynamic tool conf (such as a ToolShed managed one) to list of configs. + self._add_config( """<toolbox tool_path="%s"></toolbox>""" % self.test_directory ) + + def _init_ts_tool( self, guid=DEFAULT_GUID, **kwds ): + tool = self._init_tool( **kwds ) + tool.guid = guid + return tool + @property def tpm( self ): return tool_panel_manager.ToolPanelManager( self.app ) + + @property + def tvm( self ): + return tool_version_manager.ToolVersionManager( self.app ) diff -r a8cf78bd3629e4d9fa28e2641b670efb78ba2a56 -r 81a99e6f570ef0b0cb6511bfd9ee4dd767490fef test/unit/tools/test_toolbox.py --- a/test/unit/tools/test_toolbox.py +++ b/test/unit/tools/test_toolbox.py @@ -123,6 +123,10 @@ path = os.path.join( self.test_directory, name ) return path + def _tool_path( self, name="tool.xml" ): + path = os.path.join( self.test_directory, name ) + return path + def __reindex( self ): self.reindexed = True diff -r a8cf78bd3629e4d9fa28e2641b670efb78ba2a56 -r 81a99e6f570ef0b0cb6511bfd9ee4dd767490fef test/unit/tools_support.py --- a/test/unit/tools_support.py +++ b/test/unit/tools_support.py @@ -72,7 +72,7 @@ contents_template = string.Template( tool_contents ) tool_contents = contents_template.safe_substitute( dict( version=version ) ) self.__write_tool( tool_contents ) - self.__setup_tool( ) + return self.__setup_tool( ) def _init_app_for_tools( self ): self.app.config.drmaa_external_runjob_script = "" @@ -85,6 +85,7 @@ self.tool = Tool( self.tool_file, tool_source, self.app ) if getattr( self, "tool_action", None ): self.tool.tool_action = self.tool_action + return self.tool def __write_tool( self, contents ): open( self.tool_file, "w" ).write( contents ) https://bitbucket.org/galaxy/galaxy-central/commits/d3484078d199/ Changeset: d3484078d199 User: jmchilton Date: 2015-01-01 15:02:23+00:00 Summary: Tweak InstallManger handle_repository_contents to clarify... ... that this method is only used within this class. Affected #: 1 file diff -r 81a99e6f570ef0b0cb6511bfd9ee4dd767490fef -r d3484078d199cedc593d64e651a7c8c2d51d5f75 lib/tool_shed/galaxy_install/install_manager.py --- a/lib/tool_shed/galaxy_install/install_manager.py +++ b/lib/tool_shed/galaxy_install/install_manager.py @@ -501,8 +501,8 @@ repo_info_dicts = [ repo_info_dict ] return repository_revision_dict, repo_info_dicts - def handle_repository_contents( self, tool_shed_repository, tool_path, repository_clone_url, relative_install_dir, - tool_shed=None, tool_section=None, shed_tool_conf=None, reinstalling=False ): + def __handle_repository_contents( self, tool_shed_repository, tool_path, repository_clone_url, relative_install_dir, + tool_shed=None, tool_section=None, shed_tool_conf=None, reinstalling=False ): """ Generate the metadata for the installed tool shed repository, among other things. This method is called when an administrator is installing a new repository or @@ -839,14 +839,14 @@ create=False ) hg_util.pull_repository( repo, repository_clone_url, current_changeset_revision ) hg_util.update_repository( repo, ctx_rev=current_ctx_rev ) - self.handle_repository_contents( tool_shed_repository=tool_shed_repository, - tool_path=tool_path, - repository_clone_url=repository_clone_url, - relative_install_dir=relative_install_dir, - tool_shed=tool_shed_repository.tool_shed, - tool_section=tool_section, - shed_tool_conf=shed_tool_conf, - reinstalling=reinstalling ) + self.__handle_repository_contents( tool_shed_repository=tool_shed_repository, + tool_path=tool_path, + repository_clone_url=repository_clone_url, + relative_install_dir=relative_install_dir, + tool_shed=tool_shed_repository.tool_shed, + tool_section=tool_section, + shed_tool_conf=shed_tool_conf, + reinstalling=reinstalling ) self.install_model.context.refresh( tool_shed_repository ) metadata = tool_shed_repository.metadata if 'tools' in metadata: https://bitbucket.org/galaxy/galaxy-central/commits/84d5a7279073/ Changeset: 84d5a7279073 User: jmchilton Date: 2015-01-01 15:02:23+00:00 Summary: Bugfix: Populte tool lineage stuff prior to install. During tool shed tool installs populate lineage information in tool shed install database prior to adding tool to the tool panel so that the lineage information may be used to group tools. Previously I believe these tools would only be correctly groupped after restarting Galaxy. Affected #: 1 file diff -r d3484078d199cedc593d64e651a7c8c2d51d5f75 -r 84d5a72790735ae4da03f27735c52182bb925d9b lib/tool_shed/galaxy_install/install_manager.py --- a/lib/tool_shed/galaxy_install/install_manager.py +++ b/lib/tool_shed/galaxy_install/install_manager.py @@ -40,6 +40,8 @@ log = logging.getLogger( __name__ ) +FAILED_TO_FETCH_VERSIONS = object() + class InstallToolDependencyManager( object ): @@ -502,7 +504,8 @@ return repository_revision_dict, repo_info_dicts def __handle_repository_contents( self, tool_shed_repository, tool_path, repository_clone_url, relative_install_dir, - tool_shed=None, tool_section=None, shed_tool_conf=None, reinstalling=False ): + tool_shed=None, tool_section=None, shed_tool_conf=None, reinstalling=False, + tool_versions_response=None ): """ Generate the metadata for the installed tool shed repository, among other things. This method is called when an administrator is installing a new repository or @@ -530,6 +533,10 @@ tool_shed_repository.tool_shed_status = tool_shed_status_dict self.install_model.context.add( tool_shed_repository ) self.install_model.context.flush() + if tool_versions_response and tool_versions_response is not FAILED_TO_FETCH_VERSIONS: + tool_version_dicts = tool_versions_response + tvm = tool_version_manager.ToolVersionManager( self.app ) + tvm.handle_tool_versions( tool_version_dicts, tool_shed_repository ) if 'tool_dependencies' in irmm_metadata_dict and not reinstalling: tool_dependency_util.create_tool_dependency_objects( self.app, tool_shed_repository, @@ -839,6 +846,7 @@ create=False ) hg_util.pull_repository( repo, repository_clone_url, current_changeset_revision ) hg_util.update_repository( repo, ctx_rev=current_ctx_rev ) + tool_versions_response = fetch_tool_versions( self.app, tool_shed_repository ) self.__handle_repository_contents( tool_shed_repository=tool_shed_repository, tool_path=tool_path, repository_clone_url=repository_clone_url, @@ -846,6 +854,7 @@ tool_shed=tool_shed_repository.tool_shed, tool_section=tool_section, shed_tool_conf=shed_tool_conf, + tool_versions_response=tool_versions_response, reinstalling=reinstalling ) self.install_model.context.refresh( tool_shed_repository ) metadata = tool_shed_repository.metadata @@ -853,18 +862,7 @@ # Get the tool_versions from the tool shed for each tool in the installed change set. self.update_tool_shed_repository_status( tool_shed_repository, self.install_model.ToolShedRepository.installation_status.SETTING_TOOL_VERSIONS ) - tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( self.app, str( tool_shed_repository.tool_shed ) ) - params = '?name=%s&owner=%s&changeset_revision=%s' % ( str( tool_shed_repository.name ), - str( tool_shed_repository.owner ), - str( tool_shed_repository.changeset_revision ) ) - url = common_util.url_join( tool_shed_url, - '/repository/get_tool_versions%s' % params ) - text = common_util.tool_shed_get( self.app, tool_shed_url, url ) - if text: - tool_version_dicts = json.loads( text ) - tvm = tool_version_manager.ToolVersionManager( self.app ) - tvm.handle_tool_versions( tool_version_dicts, tool_shed_repository ) - else: + if tool_versions_response is FAILED_TO_FETCH_VERSIONS: if not error_message: error_message = "" error_message += "Version information for the tools included in the <b>%s</b> repository is missing. " % tool_shed_repository.name @@ -958,3 +956,27 @@ tool_shed_repository.error_message = str( error_message ) self.install_model.context.add( tool_shed_repository ) self.install_model.context.flush() + + +def fetch_tool_versions( app, tool_shed_repository ): + """ Fetch a data structure describing tool shed versions from the tool shed + corresponding to a tool_shed_repository object. + """ + failed_to_fetch = False + try: + tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( app, str( tool_shed_repository.tool_shed ) ) + params = '?name=%s&owner=%s&changeset_revision=%s' % ( str( tool_shed_repository.name ), + str( tool_shed_repository.owner ), + str( tool_shed_repository.changeset_revision ) ) + url = common_util.url_join( tool_shed_url, + '/repository/get_tool_versions%s' % params ) + text = common_util.tool_shed_get( app, tool_shed_url, url ) + if text: + return json.loads( text ) + else: + failed_to_fetch = True + except Exception: + failed_to_fetch = True + if failed_to_fetch: + log.exception("Failed to fetch tool shed repository verion information.") + return FAILED_TO_FETCH_VERSIONS 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