From 62ee8e8404fb86155d9893a8eeab1cf58473d795 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 17 Feb 2017 11:19:05 -0500 Subject: [PATCH 1/2] Fix Python environment hack to allow "fixing" tool ids at some version. This is a less broken alternative to #3620 and something I intended to ultimately do anyway. sam-to-bam used to be broken but now it isn't, we need to express that. Ideally we would move most of the things from the unversioned list to the versioned list as they are fixed. xref https://github.com/galaxyproject/galaxy/pull/3620#issuecomment-280674067 xref https://github.com/galaxyproject/galaxy/commit/fe2a1d8ade4fbda158ae035c78133258d7fec099#commitcomment-20900607 xref #3351 xref galaxyproject/tools-iuc#1148 --- lib/galaxy/tools/__init__.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index ea1cba386d0..d4dcd3694db 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -11,6 +11,7 @@ import tempfile import threading from cgi import FieldStorage from datetime import datetime +from distutils.version import LooseVersion from xml.etree import ElementTree from mako.template import Template @@ -98,7 +99,7 @@ log = logging.getLogger( __name__ ) HELP_UNINITIALIZED = threading.Lock() MODEL_TOOLS_PATH = os.path.abspath(os.path.dirname(__file__)) # Tools that require Galaxy's Python environment to be preserved. -GALAXY_LIB_TOOLS = [ +GALAXY_LIB_TOOLS_UNVERSIONED = [ "upload1", # Legacy tools bundled with Galaxy. "vcf_to_maf_customtrack1", @@ -134,10 +135,14 @@ GALAXY_LIB_TOOLS = [ "sam_pileup", "find_diag_hits", "cufflinks", - "sam_to_bam", # This was fixed with version 1.1.3 of the tool - TODO add Galaxy to PYTHONPATH only for older versions # Tools improperly migrated to the tool shed (iuc) "tabular_to_dbnsfp", ] +# Tools that needed galaxy on the PATH in the past but no longer do along +# with the version at which they were fixed. +GALAXY_LIB_TOOLS_VERSIONED = { + "sam_to_bam": LooseVersion("1.1.3"), +} class ToolErrorLog: @@ -407,6 +412,10 @@ class Tool( object, Dictifiable ): self.history_manager = histories.HistoryManager( app ) self._view = views.DependencyResolversView(app) + @property + def version_object(self): + return LooseVersion(self.version) + @property def sa_session( self ): """Returns a SQLAlchemy session""" @@ -479,7 +488,13 @@ class Tool( object, Dictifiable ): elif preserve_python_environment == "legacy_and_local" and self.repository_id is None: return True else: - return self.old_id in GALAXY_LIB_TOOLS + unversioned_legacy_tool = self.old_id in GALAXY_LIB_TOOLS_UNVERSIONED + versioned_legacy_tool = self.old_id in GALAXY_LIB_TOOLS_VERSIONED + legacy_tool = unversioned_legacy_tool or versioned_legacy_tool + if not legacy_tool: + return False + else: + return unversioned_legacy_tool or self.version_object < GALAXY_LIB_TOOLS_VERSIONED[self.old_id] def __get_job_tool_configuration(self, job_params=None): """Generalized method for getting this tool's job configuration. From eb6c0e410e600171fa3ce4fffb78bc205aad5292 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 17 Feb 2017 15:34:52 -0500 Subject: [PATCH 2/2] Rework preserve python environment expression according to :eagle::eyes: suggestion. https://github.com/galaxyproject/galaxy/pull/3630#discussion_r101798306 --- lib/galaxy/tools/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index d4dcd3694db..7063b00169e 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -490,11 +490,9 @@ class Tool( object, Dictifiable ): else: unversioned_legacy_tool = self.old_id in GALAXY_LIB_TOOLS_UNVERSIONED versioned_legacy_tool = self.old_id in GALAXY_LIB_TOOLS_VERSIONED - legacy_tool = unversioned_legacy_tool or versioned_legacy_tool - if not legacy_tool: - return False - else: - return unversioned_legacy_tool or self.version_object < GALAXY_LIB_TOOLS_VERSIONED[self.old_id] + legacy_tool = unversioned_legacy_tool or \ + (versioned_legacy_tool and self.version_object < GALAXY_LIB_TOOLS_VERSIONED[self.old_id]) + return legacy_tool def __get_job_tool_configuration(self, job_params=None): """Generalized method for getting this tool's job configuration.