Skip to content

Commit

Permalink
Merge pull request #3630 from jmchilton/python_hack_scalpel
Browse files Browse the repository at this point in the history
[17.01] Fix Python environment hack to allow "fixing" tool ids at some version.
  • Loading branch information
martenson committed Feb 22, 2017
2 parents 49ef352 + eb6c0e4 commit 9ebe2d2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/galaxy/tools/__init__.py
Expand Up @@ -11,6 +11,7 @@
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
Expand Down Expand Up @@ -98,7 +99,7 @@
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",
Expand Down Expand Up @@ -134,10 +135,14 @@
"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:
Expand Down Expand Up @@ -407,6 +412,10 @@ def __init__( self, config_file, tool_source, app, guid=None, repository_id=None
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"""
Expand Down Expand Up @@ -479,7 +488,11 @@ def requires_galaxy_python_environment(self):
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 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.
Expand Down

0 comments on commit 9ebe2d2

Please sign in to comment.