galaxy-commits
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 15302 discussions
5 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d62272c55cf4/
Changeset: d62272c55cf4
User: jmchilton
Date: 2014-12-30 04:07:01+00:00
Summary: Override ToolSectionLabel.to_dict so don't need to_dict_helper.
I feel this is cleaner and it makes ToolSection and ToolSectionLabel easier to move into a new module.
Affected #: 1 file
diff -r fa404b077f67ff492db5d8c3405ea57cdb2d1420 -r d62272c55cf4d99fcb5f22111de7a4b5e104190e lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -113,16 +113,6 @@
pass
-def to_dict_helper( obj, kwargs ):
- """ Helper function that provides the appropriate kwargs to to_dict an object. """
-
- # Label.to_dict cannot have kwargs.
- if isinstance( obj, ToolSectionLabel ):
- kwargs = {}
-
- return obj.to_dict( **kwargs )
-
-
class ToolBox( object, Dictifiable ):
"""Container for a collection of tools"""
@@ -1189,7 +1179,7 @@
link_details=True
)
for elt in panel_elts:
- rval.append( to_dict_helper( elt, kwargs ) )
+ rval.append( elt.to_dict( **kwargs ) )
else:
tools = []
for id, tool in self._tools_by_id.items():
@@ -1311,7 +1301,7 @@
link_details=link_details
)
for elt in self.elems.values():
- section_elts.append( to_dict_helper( elt, kwargs ) )
+ section_elts.append( elt.to_dict( **kwargs ) )
section_dict[ 'elems' ] = section_elts
return section_dict
@@ -1333,6 +1323,9 @@
self.id = elem.get( "id" )
self.version = elem.get( "version" ) or ''
+ def to_dict( self, **kwds ):
+ return super( ToolSectionLabel, self ).to_dict()
+
class DefaultToolState( object ):
"""
https://bitbucket.org/galaxy/galaxy-central/commits/7b64cb79e2b0/
Changeset: 7b64cb79e2b0
User: jmchilton
Date: 2014-12-30 04:07:01+00:00
Summary: Various ToolBox filtering improvements and tests.
- Allow overriding the base module location for ToolBox filters (needed for OS packages, etc...).
- Allow scanning multiple base modules for filters.
- Unit tests for module loading functionality, custom tool, label, and section filters, default hidden and require_login filters.
Affected #: 5 files
diff -r d62272c55cf4d99fcb5f22111de7a4b5e104190e -r 7b64cb79e2b0fc3a7bd2366ca8af6f140ed78a08 lib/galaxy/config.py
--- a/lib/galaxy/config.py
+++ b/lib/galaxy/config.py
@@ -83,6 +83,7 @@
# The value of migrated_tools_config is the file reserved for containing only those tools that have been eliminated from the distribution
# and moved to the tool shed.
self.integrated_tool_panel_config = resolve_path( kwargs.get( 'integrated_tool_panel_config', 'integrated_tool_panel.xml' ), self.root )
+ self.toolbox_filter_base_modules = listify( kwargs.get( "toolbox_filter_base_modules", "galaxy.tools.filters" ) )
self.tool_filters = listify( kwargs.get( "tool_filters", [] ), do_strip=True )
self.tool_label_filters = listify( kwargs.get( "tool_label_filters", [] ), do_strip=True )
self.tool_section_filters = listify( kwargs.get( "tool_section_filters", [] ), do_strip=True )
diff -r d62272c55cf4d99fcb5f22111de7a4b5e104190e -r 7b64cb79e2b0fc3a7bd2366ca8af6f140ed78a08 lib/galaxy/tools/filters/__init__.py
--- a/lib/galaxy/tools/filters/__init__.py
+++ b/lib/galaxy/tools/filters/__init__.py
@@ -1,6 +1,8 @@
+from copy import deepcopy
+import sys
import logging
+
from galaxy.util import listify
-from copy import deepcopy
log = logging.getLogger( __name__ )
@@ -20,6 +22,7 @@
self.default_filters = dict( tool=[ _not_hidden, _handle_requires_login ], section=[], label=[] )
# Add dynamic filters to these default filters.
config = toolbox.app.config
+ self.__base_modules = listify( getattr( config, "toolbox_filter_base_modules", "galaxy.tools.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 )
@@ -65,14 +68,27 @@
if ":" in filter_name:
# Should be a submodule of filters (e.g. examples:restrict_development_tools)
(module_name, function_name) = filter_name.rsplit(":", 1)
- module = __import__( module_name.strip(), globals() )
- function = getattr( module, function_name.strip() )
+ function = self._import_filter( module_name, function_name )
else:
# No module found, just load a function from this file or
# one that has be explicitly imported.
function = getattr( globals(), filter_name.strip() )
return function
+ def _import_filter( self, module_name, function_name ):
+ function_name = function_name.strip()
+ for base_module in self.__base_modules:
+ full_module_name = "%s.%s" % ( base_module, module_name.strip() )
+ try:
+ __import__( full_module_name )
+ except ImportError:
+ # log.debug("Failed to load module.", exc_info=True)
+ continue
+ module = sys.modules[ full_module_name ]
+ if hasattr( module, function_name ):
+ return getattr( module, function_name )
+ raise Exception("Failed to find filter %s.%s" % (module_name, function_name))
+
## Stock Filter Functions
def _not_hidden( context, tool ):
diff -r d62272c55cf4d99fcb5f22111de7a4b5e104190e -r 7b64cb79e2b0fc3a7bd2366ca8af6f140ed78a08 test/unit/tools/filter_modules/filtermod.py
--- /dev/null
+++ b/test/unit/tools/filter_modules/filtermod.py
@@ -0,0 +1,22 @@
+""" Test filters used by test_toolbox_filters.py.
+"""
+
+
+def filter_tool( context, tool ):
+ """Test Filter Tool"""
+ return False
+
+
+def filter_section( context, section ):
+ """Test Filter Section"""
+ return False
+
+
+def filter_label_1( context, label ):
+ """Test Filter Label 1"""
+ return False
+
+
+def filter_label_2( context, label ):
+ """Test Filter Label 2"""
+ return False
diff -r d62272c55cf4d99fcb5f22111de7a4b5e104190e -r 7b64cb79e2b0fc3a7bd2366ca8af6f140ed78a08 test/unit/tools/test_toolbox_filters.py
--- /dev/null
+++ b/test/unit/tools/test_toolbox_filters.py
@@ -0,0 +1,79 @@
+from galaxy.util.bunch import Bunch
+
+from galaxy.tools.filters import FilterFactory
+
+
+def test_stock_filtering_requires_login_tools( ):
+ anonymous_user_trans = mock_trans( has_user=False )
+ filters = filter_factory( {} ).build_filters( mock_trans() )[ 'tool' ]
+ assert not is_filtered( filters, anonymous_user_trans, mock_tool( require_login=False ) )
+ assert is_filtered( filters, anonymous_user_trans, mock_tool( require_login=True ) )
+
+ logged_in_trans = mock_trans( has_user=True )
+ filters = filter_factory( {} ).build_filters( logged_in_trans )[ 'tool' ]
+ assert not is_filtered( filters, logged_in_trans, mock_tool( require_login=True ) )
+
+
+def test_stock_filtering_hidden_tools( ):
+ filters = filter_factory( {} ).build_filters( mock_trans() )[ 'tool' ]
+ assert not is_filtered( filters, mock_trans(), mock_tool( hidden=False ) )
+ assert is_filtered( filters, mock_trans(), mock_tool( hidden=True ) )
+
+
+def test_trackster_filtering( ):
+ filters = filter_factory( {} ).build_filters( mock_trans(), trackster=True )[ 'tool' ]
+ # Ekkk... is trackster_conf broken? Why is it showing up.
+ # assert is_filtered( filters, mock_trans(), mock_tool( trackster_conf=False ) )
+ assert not is_filtered( filters, mock_trans(), mock_tool( trackster_conf=True ) )
+
+
+def test_custom_filters():
+ filters = filter_factory().build_filters( mock_trans() )
+ tool_filters = filters[ "tool" ]
+ # TODO: the fact that -1 is the custom filter is an implementation
+ # detail that should not be tested here.
+ assert tool_filters[ -1 ].__doc__ == "Test Filter Tool"
+
+ section_filters = filters[ "section" ]
+ assert section_filters[ 0 ].__doc__ == "Test Filter Section"
+
+ label_filters = filters[ "label" ]
+ assert label_filters[ 0 ].__doc__ == "Test Filter Label 1"
+ assert label_filters[ 1 ].__doc__ == "Test Filter Label 2"
+
+
+def filter_factory(config_dict=None):
+ if config_dict is None:
+ config_dict = dict(
+ tool_filters=["filtermod:filter_tool"],
+ tool_section_filters=["filtermod:filter_section"],
+ tool_label_filters=["filtermod:filter_label_1", "filtermod:filter_label_2"],
+ )
+ config = Bunch( **config_dict )
+ config.toolbox_filter_base_modules = "galaxy.tools.filters,tools.filter_modules"
+ app = Bunch(config=config)
+ toolbox = Bunch(app=app)
+ return FilterFactory(toolbox)
+
+
+def is_filtered( filters, trans, tool ):
+ context = Bunch( trans=trans )
+ return not all( map( lambda filter: filter( context, tool ), filters ) )
+
+
+def mock_tool( require_login=False, hidden=False, trackster_conf=False ):
+ tool = Bunch(
+ require_login=require_login,
+ hidden=hidden,
+ trackster_conf=trackster_conf,
+ )
+ return tool
+
+
+def mock_trans( has_user=True ):
+ trans = Bunch( )
+ if has_user:
+ trans.user = Bunch(preferences={})
+ else:
+ trans.user = None
+ return trans
https://bitbucket.org/galaxy/galaxy-central/commits/4a96516a503c/
Changeset: 4a96516a503c
User: jmchilton
Date: 2014-12-30 04:07:01+00:00
Summary: Move galaxy.tools.watcher into galaxy.tools.toolbox.watcher.
Affected #: 4 files
diff -r 7b64cb79e2b0fc3a7bd2366ca8af6f140ed78a08 -r 4a96516a503cc3bfae4d26b431f8ad8c67496074 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -32,7 +32,7 @@
from galaxy import jobs, model
from galaxy.datatypes.metadata import JobExternalOutputMetadataWrapper
from galaxy import exceptions
-from galaxy.tools import watcher
+from galaxy.tools.toolbox import watcher
from galaxy.tools.actions import DefaultToolAction
from galaxy.tools.actions.upload import UploadToolAction
from galaxy.tools.actions.data_source import DataSourceToolAction
diff -r 7b64cb79e2b0fc3a7bd2366ca8af6f140ed78a08 -r 4a96516a503cc3bfae4d26b431f8ad8c67496074 lib/galaxy/tools/toolbox/watcher.py
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/watcher.py
@@ -0,0 +1,99 @@
+import os.path
+try:
+ from watchdog.events import FileSystemEventHandler
+ from watchdog.observers import Observer
+ can_watch = True
+except ImportError:
+ FileSystemEventHandler = object
+ can_watch = False
+
+import logging
+log = logging.getLogger( __name__ )
+
+
+def get_watcher(toolbox, config):
+ watch_tools = getattr(config, "watch_tools", False)
+ if watch_tools:
+ return ToolWatcher(toolbox)
+ else:
+ return NullWatcher()
+
+
+class ToolWatcher(object):
+
+ def __init__(self, toolbox):
+ if not can_watch:
+ raise Exception("Watchdog library unavailble, cannot watch tools.")
+ self.toolbox = toolbox
+ self.tool_file_ids = {}
+ self.tool_dir_callbacks = {}
+ self.monitored_dirs = {}
+ self.observer = Observer()
+ self.event_handler = ToolFileEventHandler(self)
+ self.start()
+
+ def start(self):
+ self.observer.start()
+
+ def monitor(self, dir):
+ self.observer.schedule(self.event_handler, dir, recursive=False)
+
+ def watch_file(self, tool_file, tool_id):
+ tool_file = os.path.abspath( tool_file )
+ self.tool_file_ids[tool_file] = tool_id
+ tool_dir = os.path.dirname( tool_file )
+ if tool_dir not in self.monitored_dirs:
+ self.monitored_dirs[ tool_dir ] = tool_dir
+ self.monitor( tool_dir )
+
+ def watch_directory(self, tool_dir, callback):
+ tool_dir = os.path.abspath( tool_dir )
+ self.tool_dir_callbacks[tool_dir] = callback
+ if tool_dir not in self.monitored_dirs:
+ self.monitored_dirs[ tool_dir ] = tool_dir
+ self.monitor( tool_dir )
+
+
+class ToolFileEventHandler(FileSystemEventHandler):
+
+ def __init__(self, tool_watcher):
+ self.tool_watcher = tool_watcher
+
+ def on_any_event(self, event):
+ self._handle(event)
+
+ def _handle(self, event):
+ # modified events will only have src path, move events will
+ # have dest_path and src_path but we only care about dest. So
+ # look at dest if it exists else use src.
+ path = getattr( event, 'dest_path', None ) or event.src_path
+ path = os.path.abspath( path )
+ tool_id = self.tool_watcher.tool_file_ids.get( path, None )
+ if tool_id:
+ try:
+ self.tool_watcher.toolbox.reload_tool_by_id(tool_id)
+ except Exception:
+ pass
+ elif path.endswith(".xml"):
+ directory = os.path.dirname( path )
+ dir_callback = self.tool_watcher.tool_dir_callbacks.get( directory, None )
+ if dir_callback:
+ tool_file = event.src_path
+ tool_id = dir_callback( tool_file )
+ if tool_id:
+ self.tool_watcher.tool_file_ids[ tool_file ] = tool_id
+
+
+class NullWatcher(object):
+
+ def start(self):
+ pass
+
+ def shutdown(self):
+ pass
+
+ def watch_file(self, tool_file, tool_id):
+ pass
+
+ def watch_directory(self, tool_dir, callback):
+ pass
diff -r 7b64cb79e2b0fc3a7bd2366ca8af6f140ed78a08 -r 4a96516a503cc3bfae4d26b431f8ad8c67496074 lib/galaxy/tools/watcher.py
--- a/lib/galaxy/tools/watcher.py
+++ /dev/null
@@ -1,99 +0,0 @@
-import os.path
-try:
- from watchdog.events import FileSystemEventHandler
- from watchdog.observers import Observer
- can_watch = True
-except ImportError:
- FileSystemEventHandler = object
- can_watch = False
-
-import logging
-log = logging.getLogger( __name__ )
-
-
-def get_watcher(toolbox, config):
- watch_tools = getattr(config, "watch_tools", False)
- if watch_tools:
- return ToolWatcher(toolbox)
- else:
- return NullWatcher()
-
-
-class ToolWatcher(object):
-
- def __init__(self, toolbox):
- if not can_watch:
- raise Exception("Watchdog library unavailble, cannot watch tools.")
- self.toolbox = toolbox
- self.tool_file_ids = {}
- self.tool_dir_callbacks = {}
- self.monitored_dirs = {}
- self.observer = Observer()
- self.event_handler = ToolFileEventHandler(self)
- self.start()
-
- def start(self):
- self.observer.start()
-
- def monitor(self, dir):
- self.observer.schedule(self.event_handler, dir, recursive=False)
-
- def watch_file(self, tool_file, tool_id):
- tool_file = os.path.abspath( tool_file )
- self.tool_file_ids[tool_file] = tool_id
- tool_dir = os.path.dirname( tool_file )
- if tool_dir not in self.monitored_dirs:
- self.monitored_dirs[ tool_dir ] = tool_dir
- self.monitor( tool_dir )
-
- def watch_directory(self, tool_dir, callback):
- tool_dir = os.path.abspath( tool_dir )
- self.tool_dir_callbacks[tool_dir] = callback
- if tool_dir not in self.monitored_dirs:
- self.monitored_dirs[ tool_dir ] = tool_dir
- self.monitor( tool_dir )
-
-
-class ToolFileEventHandler(FileSystemEventHandler):
-
- def __init__(self, tool_watcher):
- self.tool_watcher = tool_watcher
-
- def on_any_event(self, event):
- self._handle(event)
-
- def _handle(self, event):
- # modified events will only have src path, move events will
- # have dest_path and src_path but we only care about dest. So
- # look at dest if it exists else use src.
- path = getattr( event, 'dest_path', None ) or event.src_path
- path = os.path.abspath( path )
- tool_id = self.tool_watcher.tool_file_ids.get( path, None )
- if tool_id:
- try:
- self.tool_watcher.toolbox.reload_tool_by_id(tool_id)
- except Exception:
- pass
- elif path.endswith(".xml"):
- directory = os.path.dirname( path )
- dir_callback = self.tool_watcher.tool_dir_callbacks.get( directory, None )
- if dir_callback:
- tool_file = event.src_path
- tool_id = dir_callback( tool_file )
- if tool_id:
- self.tool_watcher.tool_file_ids[ tool_file ] = tool_id
-
-
-class NullWatcher(object):
-
- def start(self):
- pass
-
- def shutdown(self):
- pass
-
- def watch_file(self, tool_file, tool_id):
- pass
-
- def watch_directory(self, tool_dir, callback):
- pass
diff -r 7b64cb79e2b0fc3a7bd2366ca8af6f140ed78a08 -r 4a96516a503cc3bfae4d26b431f8ad8c67496074 test/unit/tools/test_watcher.py
--- a/test/unit/tools/test_watcher.py
+++ b/test/unit/tools/test_watcher.py
@@ -4,7 +4,7 @@
import tempfile
import time
-from galaxy.tools import watcher
+from galaxy.tools.toolbox import watcher
from galaxy.util import bunch
https://bitbucket.org/galaxy/galaxy-central/commits/507483359a67/
Changeset: 507483359a67
User: jmchilton
Date: 2014-12-30 04:07:01+00:00
Summary: Remove lib/galaxy/tools/filters/examples.py likely incorrectly added in d816d66.
Affected #: 1 file
diff -r 4a96516a503cc3bfae4d26b431f8ad8c67496074 -r 507483359a67da800ce7a56536d31b7911211474 lib/galaxy/tools/filters/examples.py
--- a/lib/galaxy/tools/filters/examples.py
+++ /dev/null
@@ -1,115 +0,0 @@
-import logging
-log = logging.getLogger( __name__ )
-
-
-def restrict_encode( content, tool ):
- """
- Disable the random interval ENCODE tool
-
- This tool filter will disable all the ENCODE tool when enabled.
- """
- if tool.id == 'random_intervals1':
- return False
- return True
-
-
-def restrict_text( content, section ):
- """
- Disable Text sections
-
- This tool filter will disable all Tools groups under a 'Text' section when enabled.
- """
- if section.name.find('Text') != -1:
- return False
- return True
-
-
-def restrict_upload_to_admins( context, tool ):
- """
- Disable Upload tool for all non-admin users.
-
- This tool filter will hide the upload tool from all users except admin
- users.
-
- This can be enabled by renaming this file to examples.py and adding
- the following to the ``app:main`` section of ``galaxy.ini``:
-
- tool_filters = examples:restrict_upload_to_admins
- """
- if tool.name == "Upload File":
- return context.trans.user_is_admin()
- return True
-
-
-def disable_gatk( context, tool ):
- """
- This tool filter will disable all gatk tools when enabled.
-
- This can be enabled by renaming this file to examples.py and adding the following to the
- ``app:main`` section of ``galaxy.ini``:
-
- tool_filters = examples:disable_gatk
- """
- return not any( [ requirement.name == "gatk" for requirement in tool.requirements ] )
-
-
-def explicit_user_mapping( context, section ):
- """
- This tool section filter uses an explicit mapping to describe what users can view
- which tool sections. Anonymous users will only be able to view the "Get Data"
- tool section (with id getext). This can be enabled by renaming this file to
- examples.py and adding the following to the ``app:main`` section of
- ``galaxy.ini``:
-
- tool_section_filters = examples:explicit_user_mapping
- """
- users_sections = {
- None: [ "getext" ],
- "bob(a)example.com": [ "getext", "textutil", "filter" ],
- "mary(a)example.com": [ "getext", "textutil", "filter", "ngs" ],
- }
- user = context.trans.user
- email = user and user.email
- valid_sections = users_sections.get( email, [] )
- return section.id in valid_sections
-
-
-DEVELOPERS = [ "mary(a)example.com" ]
-
-
-def restrict_development_tools( context, tool ):
- """
- This tool filter will disable all tools with the string alpha appearing in
- the version for all users except those explicitly appearing in the DEVELOPERS list
- defined above. This can be enabled by renaming this file to examples.py and
- adding the following to the ``app:main`` section of ``galaxy.ini``:
-
- tool_filters = examples:restrict_development_tools
- """
- version = tool.version
- user = context.trans.user
- email = user and user.email
- return "alpha" not in version or email in DEVELOPERS
-
-
-def per_host_tool_sections( context, section ):
- """
- This tool section filter results in different sections being display based on
- the URL the user is making the request to. This could allow a single Galaxy instance
- to seem like several different instances hosting different tools based on the URL used
- to access the Galxy. This can be enabled by renaming this file to examples.py and adding
- the following to the ``app:main`` section of ``galaxy.ini``:
-
- tool_section_filters = examples:per_host_tool_sections
- """
- host = context.trans.request.host
- # Core tools used by all virtual hosts.
- valid_sections = [ "getext", "textutil", "filter" ]
- if "ngs.galaxy.example.com" in host:
- valid_sections += [ "ngs" ]
- elif "microarray.galaxy.example.com" in host:
- valid_sections += [ "microarray" ]
- elif "proteomics.galaxy.example.com" in host:
- valid_sections += [ "proteomics" ]
- return section.id in valid_sections
-
https://bitbucket.org/galaxy/galaxy-central/commits/878259151169/
Changeset: 878259151169
User: jmchilton
Date: 2014-12-30 04:07:01+00:00
Summary: Move galaxy.tools.filters to galaxy.tools.toolbox.filters.
Leave empty module in galaxy.tools.filters and modify config to ensure backward compatibility (filters in this old directory will continue to work for now).
Update config/galaxy.ini.sample with more discussion of ToolBox filter.
Affected #: 8 files
diff -r 507483359a67da800ce7a56536d31b7911211474 -r 87825915116972a38b2f0d18943ef2959d674f97 config/galaxy.ini.sample
--- a/config/galaxy.ini.sample
+++ b/config/galaxy.ini.sample
@@ -910,17 +910,27 @@
#cache_user_job_count = False
# ToolBox filtering
-# Modules from lib/galaxy/tools/filters/ can be specified in the following lines.
-# tool_* filters will be applied for all users and can not be changed by them.
-# user_tool_* filters will be shown under user preferences and can be toogled
-# on and off by runtime
-#tool_filters
-#tool_label_filters
-#tool_section_filters
+
+# Modules from lib/galaxy/tools/toolbox/filters/ can be specified in
+# the following lines. tool_* filters will be applied for all users
+# and can not be changed by them. user_tool_* filters will be shown
+# under user preferences and can be toogled on and off by
+# runtime. Example shown below are not real defaults (no custom
+# filters applied by defualt) but can be enabled with by renaming the
+# example.py.sample in the filters directory to example.py.
+
+#tool_filters =
+#tool_label_filters =
+#tool_section_filters =
#user_tool_filters = examples:restrict_upload_to_admins, examples:restrict_encode
#user_tool_section_filters = examples:restrict_text
#user_tool_label_filters = examples:restrict_upload_to_admins, examples:restrict_encode
+# The base modules that are searched for modules as described above
+# can be modified and modules external to Galaxy can be searched by
+# modifying the following option.
+#toolbox_filter_base_modules = galaxy.tools.toolbox.filters,galaxy.tools.filters
+
# Galaxy Application Internal Message Queue
# Galaxy uses AMQP internally TODO more documentation on what for.
diff -r 507483359a67da800ce7a56536d31b7911211474 -r 87825915116972a38b2f0d18943ef2959d674f97 lib/galaxy/config.py
--- a/lib/galaxy/config.py
+++ b/lib/galaxy/config.py
@@ -83,7 +83,7 @@
# The value of migrated_tools_config is the file reserved for containing only those tools that have been eliminated from the distribution
# and moved to the tool shed.
self.integrated_tool_panel_config = resolve_path( kwargs.get( 'integrated_tool_panel_config', 'integrated_tool_panel.xml' ), self.root )
- self.toolbox_filter_base_modules = listify( kwargs.get( "toolbox_filter_base_modules", "galaxy.tools.filters" ) )
+ self.toolbox_filter_base_modules = listify( kwargs.get( "toolbox_filter_base_modules", "galaxy.tools.filters,galaxy.tools.toolbox.filters" ) )
self.tool_filters = listify( kwargs.get( "tool_filters", [] ), do_strip=True )
self.tool_label_filters = listify( kwargs.get( "tool_label_filters", [] ), do_strip=True )
self.tool_section_filters = listify( kwargs.get( "tool_section_filters", [] ), do_strip=True )
diff -r 507483359a67da800ce7a56536d31b7911211474 -r 87825915116972a38b2f0d18943ef2959d674f97 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -48,7 +48,7 @@
from galaxy.tools.parameters.input_translation import ToolInputTranslator
from galaxy.tools.parameters.output import ToolOutputActionGroup
from galaxy.tools.parameters.validation import LateValidationError
-from galaxy.tools.filters import FilterFactory
+from galaxy.tools.toolbox.filters import FilterFactory
from galaxy.tools.test import parse_tests
from galaxy.tools.parser import get_tool_source
from galaxy.tools.parser.xml import XmlPageSource
diff -r 507483359a67da800ce7a56536d31b7911211474 -r 87825915116972a38b2f0d18943ef2959d674f97 lib/galaxy/tools/filters/__init__.py
--- a/lib/galaxy/tools/filters/__init__.py
+++ b/lib/galaxy/tools/filters/__init__.py
@@ -1,103 +1,5 @@
-from copy import deepcopy
-import sys
-import logging
+"""Deprecated module for toolbox filters.
-from galaxy.util import listify
-
-log = logging.getLogger( __name__ )
-
-
-class FilterFactory( object ):
- """
- An instance of this class is responsible for filtering the list
- of tools presented to a given user in a given context.
- """
-
- def __init__( self, toolbox ):
- self.toolbox = toolbox
-
- # Prepopulate dict containing filters that are always checked,
- # other filters that get checked depending on context (e.g. coming from
- # trackster or no user found are added in build filters).
- self.default_filters = dict( tool=[ _not_hidden, _handle_requires_login ], section=[], label=[] )
- # Add dynamic filters to these default filters.
- config = toolbox.app.config
- self.__base_modules = listify( getattr( config, "toolbox_filter_base_modules", "galaxy.tools.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 ):
- """
- Build list of filters to check tools against given current context.
- """
- filters = deepcopy( self.default_filters )
- if trans.user:
- for name, value in trans.user.preferences.items():
- if value.strip():
- user_filters = listify( value, do_strip=True )
- category = ''
- if name == 'toolbox_tool_filters':
- category = "tool"
- elif name == 'toolbox_section_filters':
- category = "section"
- elif name == 'toolbox_label_filters':
- category = "label"
- if category:
- validate = getattr( trans.app.config, 'user_%s_filters' % category, [] )
- self.__init_filters( category, user_filters, filters, validate=validate )
- else:
- if kwds.get( "trackster", False ):
- filters[ "tool" ].append( _has_trackster_conf )
-
- return filters
-
- def __init_filters( self, key, filters, toolbox_filters, validate=None ):
- for filter in filters:
- if validate is None or filter in validate or filter in self.default_filters:
- filter_function = self.__build_filter_function( filter )
- toolbox_filters[ key ].append( filter_function )
- else:
- log.warning( "Refusing to load %s filter '%s' which is not defined in config", key, filter )
- return toolbox_filters
-
- def __build_filter_function( self, filter_name ):
- """Obtain python function (importing a submodule if needed)
- corresponding to filter_name.
- """
- if ":" in filter_name:
- # Should be a submodule of filters (e.g. examples:restrict_development_tools)
- (module_name, function_name) = filter_name.rsplit(":", 1)
- function = self._import_filter( module_name, function_name )
- else:
- # No module found, just load a function from this file or
- # one that has be explicitly imported.
- function = getattr( globals(), filter_name.strip() )
- return function
-
- def _import_filter( self, module_name, function_name ):
- function_name = function_name.strip()
- for base_module in self.__base_modules:
- full_module_name = "%s.%s" % ( base_module, module_name.strip() )
- try:
- __import__( full_module_name )
- except ImportError:
- # log.debug("Failed to load module.", exc_info=True)
- continue
- module = sys.modules[ full_module_name ]
- if hasattr( module, function_name ):
- return getattr( module, function_name )
- raise Exception("Failed to find filter %s.%s" % (module_name, function_name))
-
-
-## Stock Filter Functions
-def _not_hidden( context, tool ):
- return not tool.hidden
-
-
-def _handle_requires_login( context, tool ):
- return not tool.require_login or context.trans.user
-
-
-def _has_trackster_conf( context, tool ):
- return tool.trackster_conf
+Filters placed in this module will still work - but filters should be
+moved to lib/galaxy/tools/toolbox/filters.
+"""
diff -r 507483359a67da800ce7a56536d31b7911211474 -r 87825915116972a38b2f0d18943ef2959d674f97 lib/galaxy/tools/filters/examples.py.sample
--- a/lib/galaxy/tools/filters/examples.py.sample
+++ /dev/null
@@ -1,87 +0,0 @@
-import logging
-log = logging.getLogger( __name__ )
-
-
-def restrict_upload_to_admins( context, tool ):
- """
- This tool filter will hide the upload tool from all users except admin
- users. This can be enabled by renaming this file to examples.py and adding
- the following to the ``app:main`` section of ``galaxy.ini``:
-
- tool_filters = examples:restrict_upload_to_admins
- """
- if tool.name == "Upload File":
- return context.trans.user_is_admin()
- return True
-
-
-def disable_gatk( context, tool ):
- """
- This tool filter will disable all gatk tools when enabled. This can be
- enabled by renaming this file to examples.py and adding the following to the
- ``app:main`` section of ``galaxy.ini``:
-
- tool_filters = examples:disable_gatk
- """
- return not any( [ requirement.name == "gatk" for requirement in tool.requirements ] )
-
-
-def explicit_user_mapping( context, section ):
- """
- This tool section filter uses an explicit mapping to describe what users can view
- which tool sections. Anonymous users will only be able to view the "Get Data"
- tool section (with id getext). This can be enabled by renaming this file to
- examples.py and adding the following to the ``app:main`` section of
- ``galaxy.ini``:
-
- tool_section_filters = examples:explicit_user_mapping
- """
- users_sections = {
- None: [ "getext" ],
- "bob(a)example.com": [ "getext", "textutil", "filter" ],
- "mary(a)example.com": [ "getext", "textutil", "filter", "ngs" ],
- }
- user = context.trans.user
- email = user and user.email
- valid_sections = users_sections.get( email, [] )
- return section.id in valid_sections
-
-
-DEVELOPERS = [ "mary(a)example.com" ]
-
-
-def restrict_development_tools( context, tool ):
- """
- This tool filter will disable all tools with the string alpha appearing in
- the version for all users except those explicitly appearing in the DEVELOPERS list
- defined above. This can be enabled by renaming this file to examples.py and
- adding the following to the ``app:main`` section of ``galaxy.ini``:
-
- tool_filters = examples:restrict_development_tools
- """
- version = tool.version
- user = context.trans.user
- email = user and user.email
- return "alpha" not in version or email in DEVELOPERS
-
-
-def per_host_tool_sections( context, section ):
- """
- This tool section filter results in different sections being display based on
- the URL the user is making the request to. This could allow a single Galaxy instance
- to seem like several different instances hosting different tools based on the URL used
- to access the Galxy. This can be enabled by renaming this file to examples.py and adding
- the following to the ``app:main`` section of ``galaxy.ini``:
-
- tool_section_filters = examples:per_host_tool_sections
- """
- host = context.trans.request.host
- # Core tools used by all virtual hosts.
- valid_sections = [ "getext", "textutil", "filter" ]
- if "ngs.galaxy.example.com" in host:
- valid_sections += [ "ngs" ]
- elif "microarray.galaxy.example.com" in host:
- valid_sections += [ "microarray" ]
- elif "proteomics.galaxy.example.com" in host:
- valid_sections += [ "proteomics" ]
- return section.id in valid_sections
diff -r 507483359a67da800ce7a56536d31b7911211474 -r 87825915116972a38b2f0d18943ef2959d674f97 lib/galaxy/tools/toolbox/filters/__init__.py
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/filters/__init__.py
@@ -0,0 +1,103 @@
+from copy import deepcopy
+import sys
+import logging
+
+from galaxy.util import listify
+
+log = logging.getLogger( __name__ )
+
+
+class FilterFactory( object ):
+ """
+ An instance of this class is responsible for filtering the list
+ of tools presented to a given user in a given context.
+ """
+
+ def __init__( self, toolbox ):
+ self.toolbox = toolbox
+
+ # Prepopulate dict containing filters that are always checked,
+ # other filters that get checked depending on context (e.g. coming from
+ # trackster or no user found are added in build filters).
+ self.default_filters = dict( tool=[ _not_hidden, _handle_requires_login ], section=[], label=[] )
+ # Add dynamic filters to these default filters.
+ config = toolbox.app.config
+ self.__base_modules = listify( getattr( config, "toolbox_filter_base_modules", "galaxy.tools.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 ):
+ """
+ Build list of filters to check tools against given current context.
+ """
+ filters = deepcopy( self.default_filters )
+ if trans.user:
+ for name, value in trans.user.preferences.items():
+ if value.strip():
+ user_filters = listify( value, do_strip=True )
+ category = ''
+ if name == 'toolbox_tool_filters':
+ category = "tool"
+ elif name == 'toolbox_section_filters':
+ category = "section"
+ elif name == 'toolbox_label_filters':
+ category = "label"
+ if category:
+ validate = getattr( trans.app.config, 'user_%s_filters' % category, [] )
+ self.__init_filters( category, user_filters, filters, validate=validate )
+ else:
+ if kwds.get( "trackster", False ):
+ filters[ "tool" ].append( _has_trackster_conf )
+
+ return filters
+
+ def __init_filters( self, key, filters, toolbox_filters, validate=None ):
+ for filter in filters:
+ if validate is None or filter in validate or filter in self.default_filters:
+ filter_function = self.__build_filter_function( filter )
+ toolbox_filters[ key ].append( filter_function )
+ else:
+ log.warning( "Refusing to load %s filter '%s' which is not defined in config", key, filter )
+ return toolbox_filters
+
+ def __build_filter_function( self, filter_name ):
+ """Obtain python function (importing a submodule if needed)
+ corresponding to filter_name.
+ """
+ if ":" in filter_name:
+ # Should be a submodule of filters (e.g. examples:restrict_development_tools)
+ (module_name, function_name) = filter_name.rsplit(":", 1)
+ function = self._import_filter( module_name, function_name )
+ else:
+ # No module found, just load a function from this file or
+ # one that has be explicitly imported.
+ function = getattr( globals(), filter_name.strip() )
+ return function
+
+ def _import_filter( self, module_name, function_name ):
+ function_name = function_name.strip()
+ for base_module in self.__base_modules:
+ full_module_name = "%s.%s" % ( base_module, module_name.strip() )
+ try:
+ __import__( full_module_name )
+ except ImportError:
+ # log.debug("Failed to load module.", exc_info=True)
+ continue
+ module = sys.modules[ full_module_name ]
+ if hasattr( module, function_name ):
+ return getattr( module, function_name )
+ raise Exception("Failed to find filter %s.%s" % (module_name, function_name))
+
+
+## Stock Filter Functions
+def _not_hidden( context, tool ):
+ return not tool.hidden
+
+
+def _handle_requires_login( context, tool ):
+ return not tool.require_login or context.trans.user
+
+
+def _has_trackster_conf( context, tool ):
+ return tool.trackster_conf
diff -r 507483359a67da800ce7a56536d31b7911211474 -r 87825915116972a38b2f0d18943ef2959d674f97 lib/galaxy/tools/toolbox/filters/examples.py.sample
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/filters/examples.py.sample
@@ -0,0 +1,87 @@
+import logging
+log = logging.getLogger( __name__ )
+
+
+def restrict_upload_to_admins( context, tool ):
+ """
+ This tool filter will hide the upload tool from all users except admin
+ users. This can be enabled by renaming this file to examples.py and adding
+ the following to the ``app:main`` section of ``galaxy.ini``:
+
+ tool_filters = examples:restrict_upload_to_admins
+ """
+ if tool.name == "Upload File":
+ return context.trans.user_is_admin()
+ return True
+
+
+def disable_gatk( context, tool ):
+ """
+ This tool filter will disable all gatk tools when enabled. This can be
+ enabled by renaming this file to examples.py and adding the following to the
+ ``app:main`` section of ``galaxy.ini``:
+
+ tool_filters = examples:disable_gatk
+ """
+ return not any( [ requirement.name == "gatk" for requirement in tool.requirements ] )
+
+
+def explicit_user_mapping( context, section ):
+ """
+ This tool section filter uses an explicit mapping to describe what users can view
+ which tool sections. Anonymous users will only be able to view the "Get Data"
+ tool section (with id getext). This can be enabled by renaming this file to
+ examples.py and adding the following to the ``app:main`` section of
+ ``galaxy.ini``:
+
+ tool_section_filters = examples:explicit_user_mapping
+ """
+ users_sections = {
+ None: [ "getext" ],
+ "bob(a)example.com": [ "getext", "textutil", "filter" ],
+ "mary(a)example.com": [ "getext", "textutil", "filter", "ngs" ],
+ }
+ user = context.trans.user
+ email = user and user.email
+ valid_sections = users_sections.get( email, [] )
+ return section.id in valid_sections
+
+
+DEVELOPERS = [ "mary(a)example.com" ]
+
+
+def restrict_development_tools( context, tool ):
+ """
+ This tool filter will disable all tools with the string alpha appearing in
+ the version for all users except those explicitly appearing in the DEVELOPERS list
+ defined above. This can be enabled by renaming this file to examples.py and
+ adding the following to the ``app:main`` section of ``galaxy.ini``:
+
+ tool_filters = examples:restrict_development_tools
+ """
+ version = tool.version
+ user = context.trans.user
+ email = user and user.email
+ return "alpha" not in version or email in DEVELOPERS
+
+
+def per_host_tool_sections( context, section ):
+ """
+ This tool section filter results in different sections being display based on
+ the URL the user is making the request to. This could allow a single Galaxy instance
+ to seem like several different instances hosting different tools based on the URL used
+ to access the Galxy. This can be enabled by renaming this file to examples.py and adding
+ the following to the ``app:main`` section of ``galaxy.ini``:
+
+ tool_section_filters = examples:per_host_tool_sections
+ """
+ host = context.trans.request.host
+ # Core tools used by all virtual hosts.
+ valid_sections = [ "getext", "textutil", "filter" ]
+ if "ngs.galaxy.example.com" in host:
+ valid_sections += [ "ngs" ]
+ elif "microarray.galaxy.example.com" in host:
+ valid_sections += [ "microarray" ]
+ elif "proteomics.galaxy.example.com" in host:
+ valid_sections += [ "proteomics" ]
+ return section.id in valid_sections
diff -r 507483359a67da800ce7a56536d31b7911211474 -r 87825915116972a38b2f0d18943ef2959d674f97 test/unit/tools/test_toolbox_filters.py
--- a/test/unit/tools/test_toolbox_filters.py
+++ b/test/unit/tools/test_toolbox_filters.py
@@ -1,6 +1,6 @@
from galaxy.util.bunch import Bunch
-from galaxy.tools.filters import FilterFactory
+from galaxy.tools.toolbox.filters import FilterFactory
def test_stock_filtering_requires_login_tools( ):
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.
1
0
commit/galaxy-central: jmchilton: Bugfix for 267fa4b when tool tags are enabled.
by commits-noreply@bitbucket.org 29 Dec '14
by commits-noreply@bitbucket.org 29 Dec '14
29 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/fa404b077f67/
Changeset: fa404b077f67
User: jmchilton
Date: 2014-12-29 19:25:12+00:00
Summary: Bugfix for 267fa4b when tool tags are enabled.
Thanks to JJ for the bug report - apparently at least one person has tool tags enabled :).
Affected #: 1 file
diff -r e84f0ccd8533d76d3ee3f5b7fa739f096e9aeb41 -r fa404b077f67ff492db5d8c3405ea57cdb2d1420 lib/galaxy/tools/toolbox/tags.py
--- a/lib/galaxy/tools/toolbox/tags.py
+++ b/lib/galaxy/tools/toolbox/tags.py
@@ -44,7 +44,7 @@
def __init__( self, app ):
self.app = app
- self.sa_session = app.sa_session
+ self.sa_session = app.model.context
def reset_tags( self ):
log.info("removing all tool tag associations (" + str( self.sa_session.query( self.app.model.ToolTagAssociation ).count() ) + ")" )
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.
1
0
commit/galaxy-central: guerler: Add classic hidden_data field to tool form
by commits-noreply@bitbucket.org 29 Dec '14
by commits-noreply@bitbucket.org 29 Dec '14
29 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/e84f0ccd8533/
Changeset: e84f0ccd8533
User: guerler
Date: 2014-12-29 19:08:35+00:00
Summary: Add classic hidden_data field to tool form
Affected #: 3 files
diff -r dc14223818bd8b8a908e056f361f2be1e8972d91 -r e84f0ccd8533d76d3ee3f5b7fa739f096e9aeb41 client/galaxy/scripts/mvc/tools/tools-section.js
--- a/client/galaxy/scripts/mvc/tools/tools-section.js
+++ b/client/galaxy/scripts/mvc/tools/tools-section.js
@@ -316,6 +316,11 @@
field = this._fieldHidden(input_def);
break;
+ // hidden field
+ case 'hidden_data':
+ field = this._fieldHidden(input_def);
+ break;
+
// integer field
case 'integer':
field = this._fieldSlider(input_def);
diff -r dc14223818bd8b8a908e056f361f2be1e8972d91 -r e84f0ccd8533d76d3ee3f5b7fa739f096e9aeb41 static/scripts/mvc/tools/tools-section.js
--- a/static/scripts/mvc/tools/tools-section.js
+++ b/static/scripts/mvc/tools/tools-section.js
@@ -316,6 +316,11 @@
field = this._fieldHidden(input_def);
break;
+ // hidden field
+ case 'hidden_data':
+ field = this._fieldHidden(input_def);
+ break;
+
// integer field
case 'integer':
field = this._fieldSlider(input_def);
diff -r dc14223818bd8b8a908e056f361f2be1e8972d91 -r e84f0ccd8533d76d3ee3f5b7fa739f096e9aeb41 static/scripts/packed/mvc/tools/tools-section.js
--- a/static/scripts/packed/mvc/tools/tools-section.js
+++ b/static/scripts/packed/mvc/tools/tools-section.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.trigger("refresh")};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.trigger("refresh")}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.trigger("refresh")}});var h=o.min;var q=_.size(o.cache);for(var l=0;l<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,l>=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_collection":i=this._fieldData(h);break;case"data_column":h.error_text="Missing columns in referenced dataset.";i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.trigger("refresh")}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,error_text:h.error_text||"No options available",multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.trigger("refresh")}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.trigger("refresh")}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.trigger("refresh")}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.trigger("refresh")};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.trigger("refresh")}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.trigger("refresh")}});var h=o.min;var q=_.size(o.cache);for(var l=0;l<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,l>=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_collection":i=this._fieldData(h);break;case"data_column":h.error_text="Missing columns in referenced dataset.";i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"hidden_data":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.trigger("refresh")}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,error_text:h.error_text||"No options available",multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.trigger("refresh")}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.trigger("refresh")}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.trigger("refresh")}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}});
\ No newline at end of file
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.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/68daf6dfc8b4/
Changeset: 68daf6dfc8b4
User: jmchilton
Date: 2014-12-29 17:23:55+00:00
Summary: Update attribute and method names in ToolBox to reflect encapsulation efforts.
Using ToolBox._xxx instead of ToolBox.__xxx because realistically ToolBox is still much to large to grok and so I imagine it will need to be broken up even more (base class focused on just the panel details perhaps - or mixins - etc...).
Affected #: 3 files
diff -r 6268351b242feb5c2167b35996e264e8a51c11a9 -r 68daf6dfc8b405acbdfc64fd21d520178aff1ac4 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -131,49 +131,50 @@
Create a toolbox from the config files named by `config_filenames`, using
`tool_root_dir` as the base directory for finding individual tool config files.
"""
- # The shed_tool_confs list contains dictionaries storing information about the tools defined in each
- # shed-related shed_tool_conf.xml file.
- self.shed_tool_confs = []
- self.tools_by_id = {}
- self.workflows_by_id = {}
+ # The _dynamic_tool_confs list contains dictionaries storing
+ # information about the tools defined in each shed-related
+ # shed_tool_conf.xml file.
+ self._dynamic_tool_confs = []
+ self._tools_by_id = {}
+ self._workflows_by_id = {}
# In-memory dictionary that defines the layout of the tool panel.
- self.tool_panel = odict()
- self.index = 0
+ self._tool_panel = odict()
+ self._index = 0
self.data_manager_tools = odict()
- self.lineage_map = LineageMap( app )
+ self._lineage_map = LineageMap( app )
# File that contains the XML section and tool tags from all tool panel config files integrated into a
# single file that defines the tool panel layout. This file can be changed by the Galaxy administrator
# (in a way similar to the single tool_conf.xml file in the past) to alter the layout of the tool panel.
- self.integrated_tool_panel_config = app.config.integrated_tool_panel_config
+ self._integrated_tool_panel_config = app.config.integrated_tool_panel_config
# In-memory dictionary that defines the layout of the tool_panel.xml file on disk.
- self.integrated_tool_panel = odict()
- self.integrated_tool_panel_config_has_contents = os.path.exists( self.integrated_tool_panel_config ) and os.stat( self.integrated_tool_panel_config ).st_size > 0
- if self.integrated_tool_panel_config_has_contents:
- self.load_integrated_tool_panel_keys()
+ self._integrated_tool_panel = odict()
+ self._integrated_tool_panel_config_has_contents = os.path.exists( self._integrated_tool_panel_config ) and os.stat( self._integrated_tool_panel_config ).st_size > 0
+ if self._integrated_tool_panel_config_has_contents:
+ self._load_integrated_tool_panel_keys()
# The following refers to the tool_path config setting for backward compatibility. The shed-related
# (e.g., shed_tool_conf.xml) files include the tool_path attribute within the <toolbox> tag.
- self.tool_root_dir = tool_root_dir
+ self._tool_root_dir = tool_root_dir
self.app = app
- self.tool_watcher = watcher.get_watcher( self, app.config )
- self.filter_factory = FilterFactory( self )
- self.init_dependency_manager()
- self.tool_tag_manager = tool_tag_manager( app )
- self.init_tools_from_configs( config_filenames )
- if self.app.name == 'galaxy' and self.integrated_tool_panel_config_has_contents:
- # Load self.tool_panel based on the order in self.integrated_tool_panel.
- self.load_tool_panel()
+ self._tool_watcher = watcher.get_watcher( self, app.config )
+ self._filter_factory = FilterFactory( self )
+ self._init_dependency_manager()
+ self._tool_tag_manager = tool_tag_manager( app )
+ self._init_tools_from_configs( config_filenames )
+ if self.app.name == 'galaxy' and self._integrated_tool_panel_config_has_contents:
+ # Load self._tool_panel based on the order in self._integrated_tool_panel.
+ self._load_tool_panel()
if app.config.update_integrated_tool_panel:
# Write the current in-memory integrated_tool_panel to the integrated_tool_panel.xml file.
# This will cover cases where the Galaxy administrator manually edited one or more of the tool panel
# config files, adding or removing locally developed tools or workflows. The value of integrated_tool_panel
# will be False when things like functional tests are the caller.
- self.write_integrated_tool_panel_config_file()
-
- def init_tools_from_configs( self, config_filenames ):
+ self._write_integrated_tool_panel_config_file()
+
+ def _init_tools_from_configs( self, config_filenames ):
""" Read through all tool config files and initialize tools in each
with init_tools_from_config below.
"""
- self.tool_tag_manager.reset_tags()
+ self._tool_tag_manager.reset_tags()
config_filenames = listify( config_filenames )
for config_filename in config_filenames:
if os.path.isdir( config_filename ):
@@ -183,11 +184,11 @@
config_filenames.extend( directory_config_files )
for config_filename in config_filenames:
try:
- self.init_tools_from_config( config_filename )
+ self._init_tools_from_config( config_filename )
except:
log.exception( "Error loading tools defined in config %s", config_filename )
- def init_tools_from_config( self, config_filename ):
+ def _init_tools_from_config( self, config_filename ):
"""
Read the configuration file and load each tool. The following tags are currently supported:
@@ -218,10 +219,10 @@
parsing_shed_tool_conf = False
tool_path = self.__resolve_tool_path(tool_path, config_filename)
# Only load the panel_dict under certain conditions.
- load_panel_dict = not self.integrated_tool_panel_config_has_contents
+ load_panel_dict = not self._integrated_tool_panel_config_has_contents
for _, elem in enumerate( root ):
- index = self.index
- self.index += 1
+ index = self._index
+ self._index += 1
if parsing_shed_tool_conf:
config_elems.append( elem )
self.load_item(
@@ -237,7 +238,7 @@
shed_tool_conf_dict = dict( config_filename=config_filename,
tool_path=tool_path,
config_elems=config_elems )
- self.shed_tool_confs.append( shed_tool_conf_dict )
+ self._dynamic_tool_confs.append( shed_tool_conf_dict )
def load_item( self, elem, tool_path, panel_dict=None, integrated_panel_dict=None, load_panel_dict=True, guid=None, index=None, internal=False ):
item_type = elem.tag
@@ -247,22 +248,22 @@
return
if panel_dict is None:
- panel_dict = self.tool_panel
+ panel_dict = self._tool_panel
if integrated_panel_dict is None:
- integrated_panel_dict = self.integrated_tool_panel
+ integrated_panel_dict = self._integrated_tool_panel
if item_type == 'tool':
- self.load_tool_tag_set( elem, panel_dict=panel_dict, integrated_panel_dict=integrated_panel_dict, tool_path=tool_path, load_panel_dict=load_panel_dict, guid=guid, index=index )
+ self._load_tool_tag_set( elem, panel_dict=panel_dict, integrated_panel_dict=integrated_panel_dict, tool_path=tool_path, load_panel_dict=load_panel_dict, guid=guid, index=index )
elif item_type == 'workflow':
- self.load_workflow_tag_set( elem, panel_dict=panel_dict, integrated_panel_dict=integrated_panel_dict, load_panel_dict=load_panel_dict, index=index )
+ self._load_workflow_tag_set( elem, panel_dict=panel_dict, integrated_panel_dict=integrated_panel_dict, load_panel_dict=load_panel_dict, index=index )
elif item_type == 'section':
- self.load_section_tag_set( elem, tool_path=tool_path, load_panel_dict=load_panel_dict, index=index )
+ self._load_section_tag_set( elem, tool_path=tool_path, load_panel_dict=load_panel_dict, index=index )
elif item_type == 'label':
- self.load_label_tag_set( elem, panel_dict=panel_dict, integrated_panel_dict=integrated_panel_dict, load_panel_dict=load_panel_dict, index=index )
+ self._load_label_tag_set( elem, panel_dict=panel_dict, integrated_panel_dict=integrated_panel_dict, load_panel_dict=load_panel_dict, index=index )
elif item_type == 'tool_dir':
- self.load_tooldir_tag_set( elem, panel_dict, tool_path, integrated_panel_dict, load_panel_dict=load_panel_dict )
+ self._load_tooldir_tag_set( elem, panel_dict, tool_path, integrated_panel_dict, load_panel_dict=load_panel_dict )
def get_shed_config_dict_by_filename( self, filename, default=None ):
- for shed_config_dict in self.shed_tool_confs:
+ for shed_config_dict in self._dynamic_tool_confs:
if shed_config_dict[ 'config_filename' ] == filename:
return shed_config_dict
return default
@@ -273,22 +274,22 @@
that doesn't affect that file).
"""
app = self.app
- for index, my_shed_tool_conf in enumerate( self.shed_tool_confs ):
+ for index, my_shed_tool_conf in enumerate( self._dynamic_tool_confs ):
if shed_conf['config_filename'] == my_shed_tool_conf['config_filename']:
- self.shed_tool_confs[ index ] = shed_conf
+ self._dynamic_tool_confs[ 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()
+ self._write_integrated_tool_panel_config_file()
app.reindex_tool_search()
def get_section( self, section_id, new_label=None, create_if_needed=False ):
tool_panel_section_key = str( section_id )
- if tool_panel_section_key in self.tool_panel:
- # Appending a tool to an existing section in toolbox.tool_panel
- tool_section = self.tool_panel[ tool_panel_section_key ]
+ if tool_panel_section_key in self._tool_panel:
+ # Appending a tool to an existing section in toolbox._tool_panel
+ tool_section = self._tool_panel[ tool_panel_section_key ]
log.debug( "Appending to tool panel section: %s" % str( tool_section.name ) )
elif create_if_needed:
- # Appending a new section to toolbox.tool_panel
+ # Appending a new section to toolbox._tool_panel
if new_label is None:
# This might add an ugly section label to the tool panel, but, oh well...
new_label = section_id
@@ -298,7 +299,7 @@
'version': '',
}
tool_section = ToolSection( section_dict )
- self.tool_panel[ tool_panel_section_key ] = tool_section
+ self._tool_panel[ tool_panel_section_key ] = tool_section
log.debug( "Loading new tool panel section: %s" % str( tool_section.name ) )
else:
tool_section = None
@@ -306,7 +307,7 @@
def get_integrated_section_for_tool( self, tool ):
tool_id = tool.id
- for key, item in self.integrated_tool_panel.items():
+ for key, item in self._integrated_tool_panel.items():
if item:
if isinstance( item, Tool ):
if item.id == tool_id:
@@ -324,7 +325,7 @@
def __resolve_tool_path(self, tool_path, config_filename):
if not tool_path:
# Default to backward compatible config setting.
- tool_path = self.tool_root_dir
+ tool_path = self._tool_root_dir
else:
# Allow use of __tool_conf_dir__ in toolbox config files.
tool_conf_dir = os.path.dirname(config_filename)
@@ -335,9 +336,9 @@
def __add_tool_to_tool_panel( self, tool, panel_component, section=False ):
# See if a version of this tool is already loaded into the tool panel.
# The value of panel_component will be a ToolSection (if the value of
- # section=True) or self.tool_panel (if section=False).
+ # section=True) or self._tool_panel (if section=False).
tool_id = str( tool.id )
- tool = self.tools_by_id[ tool_id ]
+ tool = self._tools_by_id[ tool_id ]
if section:
panel_dict = panel_component.elems
else:
@@ -355,7 +356,7 @@
inserted = False
key = 'tool_%s' % tool.id
# The value of panel_component is the in-memory tool panel dictionary.
- for index, integrated_panel_key in enumerate( self.integrated_tool_panel.keys() ):
+ for index, integrated_panel_key in enumerate( self._integrated_tool_panel.keys() ):
if key == integrated_panel_key:
panel_dict.insert( index, key, tool )
inserted = True
@@ -363,7 +364,7 @@
# Check the tool's installed versions.
for lineage_id in tool.lineage_ids:
lineage_id_key = 'tool_%s' % lineage_id
- for index, integrated_panel_key in enumerate( self.integrated_tool_panel.keys() ):
+ for index, integrated_panel_key in enumerate( self._integrated_tool_panel.keys() ):
if lineage_id_key == integrated_panel_key:
panel_dict.insert( index, key, tool )
inserted = True
@@ -383,27 +384,28 @@
log.debug( "Loaded tool id: %s, version: %s into tool panel.." % ( tool.id, tool.version ) )
else:
# We are in the process of installing the tool.
- tool_lineage = self.lineage_map.get( tool_id )
+
+ tool_lineage = self._lineage_map.get( tool_id )
already_loaded = self._lineage_in_panel( panel_dict, tool_lineage=tool_lineage ) is not None
if not already_loaded:
# If the tool is not defined in integrated_tool_panel.xml, append it to the tool panel.
panel_dict[ key ] = tool
log.debug( "Loaded tool id: %s, version: %s into tool panel...." % ( tool.id, tool.version ) )
- def load_tool_panel( self ):
- for key, val in self.integrated_tool_panel.items():
+ def _load_tool_panel( self ):
+ for key, val in self._integrated_tool_panel.items():
if isinstance( val, Tool ):
tool_id = key.replace( 'tool_', '', 1 )
- if tool_id in self.tools_by_id:
- self.__add_tool_to_tool_panel( val, self.tool_panel, section=False )
+ if tool_id in self._tools_by_id:
+ self.__add_tool_to_tool_panel( val, self._tool_panel, section=False )
elif isinstance( val, Workflow ):
workflow_id = key.replace( 'workflow_', '', 1 )
- if workflow_id in self.workflows_by_id:
- workflow = self.workflows_by_id[ workflow_id ]
- self.tool_panel[ key ] = workflow
+ if workflow_id in self._workflows_by_id:
+ workflow = self._workflows_by_id[ workflow_id ]
+ self._tool_panel[ key ] = workflow
log.debug( "Loaded workflow: %s %s" % ( workflow_id, workflow.name ) )
elif isinstance( val, ToolSectionLabel ):
- self.tool_panel[ key ] = val
+ self._tool_panel[ key ] = val
elif isinstance( val, ToolSection ):
section_dict = {
'id': val.id or '',
@@ -415,36 +417,36 @@
for section_key, section_val in val.elems.items():
if isinstance( section_val, Tool ):
tool_id = section_key.replace( 'tool_', '', 1 )
- if tool_id in self.tools_by_id:
+ if tool_id in self._tools_by_id:
self.__add_tool_to_tool_panel( section_val, section, section=True )
elif isinstance( section_val, Workflow ):
workflow_id = section_key.replace( 'workflow_', '', 1 )
- if workflow_id in self.workflows_by_id:
- workflow = self.workflows_by_id[ workflow_id ]
+ if workflow_id in self._workflows_by_id:
+ workflow = self._workflows_by_id[ workflow_id ]
section.elems[ section_key ] = workflow
log.debug( "Loaded workflow: %s %s" % ( workflow_id, workflow.name ) )
elif isinstance( section_val, ToolSectionLabel ):
if section_val:
section.elems[ section_key ] = section_val
log.debug( "Loaded label: %s" % ( section_val.text ) )
- self.tool_panel[ key ] = section
-
- def load_integrated_tool_panel_keys( self ):
+ self._tool_panel[ key ] = section
+
+ def _load_integrated_tool_panel_keys( self ):
"""
Load the integrated tool panel keys, setting values for tools and
workflows to None. The values will be reset when the various tool
panel config files are parsed, at which time the tools and workflows
are loaded.
"""
- tree = parse_xml( self.integrated_tool_panel_config )
+ tree = parse_xml( self._integrated_tool_panel_config )
root = tree.getroot()
for elem in root:
if elem.tag == 'tool':
key = 'tool_%s' % elem.get( 'id' )
- self.integrated_tool_panel[ key ] = None
+ self._integrated_tool_panel[ key ] = None
elif elem.tag == 'workflow':
key = 'workflow_%s' % elem.get( 'id' )
- self.integrated_tool_panel[ key ] = None
+ self._integrated_tool_panel[ key ] = None
elif elem.tag == 'section':
section = ToolSection( elem )
for section_elem in elem:
@@ -458,12 +460,12 @@
key = 'label_%s' % section_elem.get( 'id' )
section.elems[ key ] = None
key = elem.get( 'id' )
- self.integrated_tool_panel[ key ] = section
+ self._integrated_tool_panel[ key ] = section
elif elem.tag == 'label':
key = 'label_%s' % elem.get( 'id' )
- self.integrated_tool_panel[ key ] = None
-
- def write_integrated_tool_panel_config_file( self ):
+ self._integrated_tool_panel[ key ] = None
+
+ def _write_integrated_tool_panel_config_file( self ):
"""
Write the current in-memory version of the integrated_tool_panel.xml file to disk. Since Galaxy administrators
use this file to manage the tool panel, we'll not use xml_to_string() since it doesn't write XML quite right.
@@ -474,7 +476,7 @@
os.write( fd, ' <!--\n ')
os.write( fd, '\n '.join( [ l for l in INTEGRATED_TOOL_PANEL_DESCRIPTION.split("\n") if l ] ) )
os.write( fd, '\n -->\n')
- for key, item in self.integrated_tool_panel.items():
+ for key, item in self._integrated_tool_panel.items():
if item:
if isinstance( item, Tool ):
os.write( fd, ' <tool id="%s" />\n' % item.id )
@@ -506,28 +508,28 @@
os.write( fd, ' </section>\n' )
os.write( fd, '</toolbox>\n' )
os.close( fd )
- shutil.move( filename, os.path.abspath( self.integrated_tool_panel_config ) )
- os.chmod( self.integrated_tool_panel_config, 0644 )
+ shutil.move( filename, os.path.abspath( self._integrated_tool_panel_config ) )
+ os.chmod( self._integrated_tool_panel_config, 0644 )
def get_tool( self, tool_id, tool_version=None, get_all_versions=False, exact=False ):
"""Attempt to locate a tool in the tool box."""
if get_all_versions and exact:
raise AssertionError("Cannot specify get_tool with both get_all_versions and exact as True")
- if tool_id in self.tools_by_id and not get_all_versions:
+ if tool_id in self._tools_by_id and not get_all_versions:
#tool_id exactly matches an available tool by id (which is 'old' tool_id or guid)
- return self.tools_by_id[ tool_id ]
+ return self._tools_by_id[ tool_id ]
#exact tool id match not found, or all versions requested, search for other options, e.g. migrated tools or different versions
rval = []
- tool_lineage = self.lineage_map.get( tool_id )
+ tool_lineage = self._lineage_map.get( tool_id )
if tool_lineage:
tool_version_ids = tool_lineage.get_version_ids( )
for tool_version_id in tool_version_ids:
- if tool_version_id in self.tools_by_id:
- rval.append( self.tools_by_id[ tool_version_id ] )
+ if tool_version_id in self._tools_by_id:
+ rval.append( self._tools_by_id[ tool_version_id ] )
if not rval:
#still no tool, do a deeper search and try to match by old ids
- for tool in self.tools_by_id.itervalues():
+ for tool in self._tools_by_id.itervalues():
if tool.old_id == tool_id:
rval.append( tool )
if rval:
@@ -543,8 +545,8 @@
return rval[0]
#We now likely have a Toolshed guid passed in, but no supporting database entries
#If the tool exists by exact id and is loaded then provide exact match within a list
- if tool_id in self.tools_by_id:
- return[ self.tools_by_id[ tool_id ] ]
+ if tool_id in self._tools_by_id:
+ return[ self._tools_by_id[ tool_id ] ]
return None
def has_tool( self, tool_id, exact=False ):
@@ -556,7 +558,7 @@
tools (using get_tool for inexact matches which currently returns the oldest
tool shed installed tool with the same short id).
"""
- if tool_id not in self.tools_by_id:
+ if tool_id not in self._tools_by_id:
tool = self.get_tool( tool_id )
if tool:
tool_id = tool.id
@@ -567,22 +569,22 @@
def get_loaded_tools_by_lineage( self, tool_id ):
"""Get all loaded tools associated by lineage to the tool whose id is tool_id."""
- tool_lineage = self.lineage_map.get( tool_id )
+ tool_lineage = self._lineage_map.get( tool_id )
if tool_lineage:
tool_version_ids = tool_lineage.get_version_ids( )
available_tool_versions = []
for tool_version_id in tool_version_ids:
- if tool_version_id in self.tools_by_id:
- available_tool_versions.append( self.tools_by_id[ tool_version_id ] )
+ if tool_version_id in self._tools_by_id:
+ available_tool_versions.append( self._tools_by_id[ tool_version_id ] )
return available_tool_versions
else:
- if tool_id in self.tools_by_id:
- tool = self.tools_by_id[ tool_id ]
+ if tool_id in self._tools_by_id:
+ tool = self._tools_by_id[ tool_id ]
return [ tool ]
return []
def tools( self ):
- return self.tools_by_id.iteritems()
+ return self._tools_by_id.iteritems()
def __elem_to_tool_shed_repository( self, elem ):
# The tool is contained in an installed tool shed repository, so load
@@ -637,7 +639,7 @@
def dynamic_confs( self, include_migrated_tool_conf=False ):
confs = []
- for dynamic_tool_conf_dict in self.shed_tool_confs:
+ for dynamic_tool_conf_dict in self._dynamic_tool_confs:
dynamic_tool_conf_filename = dynamic_tool_conf_dict[ 'config_filename' ]
if include_migrated_tool_conf or (dynamic_tool_conf_filename != self.app.config.migrated_tools_config):
confs.append( dynamic_tool_conf_dict )
@@ -712,11 +714,11 @@
if section_key:
_, tool_section = self.get_section( section_key )
if tool_section:
- remove_from_dict( tool_section.elems, self.integrated_tool_panel.get( section_key, {} ) )
+ remove_from_dict( tool_section.elems, self._integrated_tool_panel.get( section_key, {} ) )
else:
- remove_from_dict( self.tool_panel, self.integrated_tool_panel )
-
- def load_tool_tag_set( self, elem, panel_dict, integrated_panel_dict, tool_path, load_panel_dict, guid=None, index=None ):
+ remove_from_dict( self._tool_panel, self._integrated_tool_panel )
+
+ def _load_tool_tag_set( self, elem, panel_dict, integrated_panel_dict, tool_path, load_panel_dict, guid=None, index=None ):
try:
path = elem.get( "file" )
repository_id = None
@@ -746,11 +748,11 @@
tool.guid = guid
tool.version = elem.find( "version" ).text
# Make sure the tool has a tool_version.
- tool_lineage = self.lineage_map.register( tool, tool_shed_repository=tool_shed_repository )
+ tool_lineage = self._lineage_map.register( tool, tool_shed_repository=tool_shed_repository )
# Load the tool's lineage ids.
tool.lineage = tool_lineage
tool.lineage_ids = tool_lineage.get_version_ids( )
- self.tool_tag_manager.handle_tags( tool.id, elem )
+ self._tool_tag_manager.handle_tags( tool.id, elem )
self.__add_tool( tool, load_panel_dict, panel_dict )
# Always load the tool into the integrated_panel_dict, or it will not be included in the integrated_tool_panel.xml file.
if key in integrated_panel_dict or index is None:
@@ -769,18 +771,18 @@
# administrator has retrieved updates to the installed repository. In
# this case, the tool may have been updated, but the version was not
# changed, so the tool should always be reloaded here. We used to
- # only load the tool if it was not found in self.tools_by_id, but
+ # only load the tool if it was not found in self._tools_by_id, but
# performing that check did not enable this scenario.
self.register_tool( tool )
if load_panel_dict:
self.__add_tool_to_tool_panel( tool, panel_dict, section=isinstance( panel_dict, ToolSection ) )
- def load_workflow_tag_set( self, elem, panel_dict, integrated_panel_dict, load_panel_dict, index=None ):
+ def _load_workflow_tag_set( self, elem, panel_dict, integrated_panel_dict, load_panel_dict, index=None ):
try:
# TODO: should id be encoded?
workflow_id = elem.get( 'id' )
- workflow = self.load_workflow( workflow_id )
- self.workflows_by_id[ workflow_id ] = workflow
+ workflow = self._load_workflow( workflow_id )
+ self._workflows_by_id[ workflow_id ] = workflow
key = 'workflow_' + workflow_id
if load_panel_dict:
panel_dict[ key ] = workflow
@@ -792,7 +794,7 @@
except:
log.exception( "Error loading workflow: %s" % workflow_id )
- def load_label_tag_set( self, elem, panel_dict, integrated_panel_dict, load_panel_dict, index=None ):
+ def _load_label_tag_set( self, elem, panel_dict, integrated_panel_dict, load_panel_dict, index=None ):
label = ToolSectionLabel( elem )
key = 'label_' + label.id
if load_panel_dict:
@@ -802,16 +804,16 @@
else:
integrated_panel_dict.insert( index, key, label )
- def load_section_tag_set( self, elem, tool_path, load_panel_dict, index=None ):
+ def _load_section_tag_set( self, elem, tool_path, load_panel_dict, index=None ):
key = elem.get( "id" )
- if key in self.tool_panel:
- section = self.tool_panel[ key ]
+ if key in self._tool_panel:
+ section = self._tool_panel[ key ]
elems = section.elems
else:
section = ToolSection( elem )
elems = section.elems
- if key in self.integrated_tool_panel:
- integrated_section = self.integrated_tool_panel[ key ]
+ if key in self._integrated_tool_panel:
+ integrated_section = self._integrated_tool_panel[ key ]
integrated_elems = integrated_section.elems
else:
integrated_section = ToolSection( elem )
@@ -828,14 +830,14 @@
internal=True,
)
if load_panel_dict:
- self.tool_panel[ key ] = section
+ self._tool_panel[ key ] = section
# Always load sections into the integrated_tool_panel.
- if key in self.integrated_tool_panel or index is None:
- self.integrated_tool_panel[ key ] = integrated_section
+ if key in self._integrated_tool_panel or index is None:
+ self._integrated_tool_panel[ key ] = integrated_section
else:
- self.integrated_tool_panel.insert( index, key, integrated_section )
-
- def load_tooldir_tag_set(self, sub_elem, elems, tool_path, integrated_elems, load_panel_dict):
+ self._integrated_tool_panel.insert( index, key, integrated_section )
+
+ def _load_tooldir_tag_set(self, sub_elem, elems, tool_path, integrated_elems, load_panel_dict):
directory = os.path.join( tool_path, sub_elem.attrib.get("dir") )
recursive = string_as_bool( sub_elem.attrib.get("recursive", True) )
self.__watch_directory( directory, elems, integrated_elems, load_panel_dict, recursive )
@@ -851,14 +853,14 @@
integrated_elems[ key ] = tool
if async:
- self.load_tool_panel()
+ self._load_tool_panel()
if self.app.config.update_integrated_tool_panel:
# Write the current in-memory integrated_tool_panel to the integrated_tool_panel.xml file.
# This will cover cases where the Galaxy administrator manually edited one or more of the tool panel
# config files, adding or removing locally developed tools or workflows. The value of integrated_tool_panel
# will be False when things like functional tests are the caller.
- self.write_integrated_tool_panel_config_file()
+ self._write_integrated_tool_panel_config_file()
return tool.id
except Exception:
log.exception("Failed to load potential tool %s." % tool_file)
@@ -873,7 +875,7 @@
quick_load( child_path, async=False )
tool_loaded = True
if tool_loaded:
- self.tool_watcher.watch_directory( directory, quick_load )
+ self._tool_watcher.watch_directory( directory, quick_load )
def load_tool( self, config_file, guid=None, repository_id=None, **kwds ):
"""Load a single tool from the file named by `config_file` and return an instance of `Tool`."""
@@ -916,19 +918,19 @@
if not tool_id.startswith("__"):
# do not monitor special tools written to tmp directory - no reason
# to monitor such a large directory.
- self.tool_watcher.watch_file( config_file, tool.id )
+ self._tool_watcher.watch_file( config_file, tool.id )
return tool
def load_hidden_tool( self, config_file, **kwds ):
""" Load a hidden tool (in this context meaning one that does not
- appear in the tool panel) and register it in tools_by_id.
+ appear in the tool panel) and register it in _tools_by_id.
"""
tool = self.load_tool( config_file, **kwds )
self.register_tool( tool )
return tool
def register_tool( self, tool ):
- self.tools_by_id[ tool.id ] = tool
+ self._tools_by_id[ tool.id ] = tool
def package_tool( self, trans, tool_id ):
"""
@@ -938,10 +940,10 @@
:returns: tuple of tarball filename, success True/False, message/None
"""
# Make sure the tool is actually loaded.
- if tool_id not in self.tools_by_id:
+ if tool_id not in self._tools_by_id:
return None, False, "No tool with id %s" % escape( tool_id )
else:
- tool = self.tools_by_id[ tool_id ]
+ tool = self._tools_by_id[ tool_id ]
tarball_files = []
temp_files = []
tool_xml = file( os.path.abspath( tool.config_file ), 'r' ).read()
@@ -1048,11 +1050,11 @@
Attempt to reload the tool identified by 'tool_id', if successful
replace the old tool.
"""
- if tool_id not in self.tools_by_id:
+ if tool_id not in self._tools_by_id:
message = "No tool with id %s" % escape( tool_id )
status = 'error'
else:
- old_tool = self.tools_by_id[ tool_id ]
+ old_tool = self._tools_by_id[ tool_id ]
new_tool = self.load_tool( old_tool.config_file )
# The tool may have been installed from a tool shed, so set the tool shed attributes.
# Since the tool version may have changed, we don't override it here.
@@ -1063,17 +1065,17 @@
new_tool.repository_owner = old_tool.repository_owner
new_tool.installed_changeset_revision = old_tool.installed_changeset_revision
new_tool.old_id = old_tool.old_id
- # Replace old_tool with new_tool in self.tool_panel
+ # Replace old_tool with new_tool in self._tool_panel
tool_key = 'tool_' + tool_id
- for key, val in self.tool_panel.items():
+ for key, val in self._tool_panel.items():
if key == tool_key:
- self.tool_panel[ key ] = new_tool
+ self._tool_panel[ key ] = new_tool
break
elif key.startswith( 'section' ):
if tool_key in val.elems:
- self.tool_panel[ key ].elems[ tool_key ] = new_tool
+ self._tool_panel[ key ].elems[ tool_key ] = new_tool
break
- self.tools_by_id[ tool_id ] = new_tool
+ self._tools_by_id[ tool_id ] = new_tool
message = "Reloaded the tool:<br/>"
message += "<b>name:</b> %s<br/>" % old_tool.name
message += "<b>id:</b> %s<br/>" % old_tool.id
@@ -1089,21 +1091,21 @@
promoting the next newest version of the tool into the panel
if needed.
"""
- if tool_id not in self.tools_by_id:
+ if tool_id not in self._tools_by_id:
message = "No tool with id %s" % escape( tool_id )
status = 'error'
else:
- tool = self.tools_by_id[ tool_id ]
- del self.tools_by_id[ tool_id ]
+ tool = self._tools_by_id[ tool_id ]
+ del self._tools_by_id[ tool_id ]
if remove_from_panel:
tool_key = 'tool_' + tool_id
- for key, val in self.tool_panel.items():
+ for key, val in self._tool_panel.items():
if key == tool_key:
- del self.tool_panel[ key ]
+ del self._tool_panel[ key ]
break
elif key.startswith( 'section' ):
if tool_key in val.elems:
- del self.tool_panel[ key ].elems[ tool_key ]
+ del self._tool_panel[ key ].elems[ tool_key ]
break
if tool_id in self.data_manager_tools:
del self.data_manager_tools[ tool_id ]
@@ -1116,7 +1118,7 @@
return message, status
def get_sections( self ):
- for k, v in self.tool_panel.items():
+ for k, v in self._tool_panel.items():
if isinstance( v, ToolSection ):
yield (v.id, v.name)
@@ -1128,17 +1130,17 @@
if not tool_panel_section_id:
tool_panel_section_id = ''
else:
- if tool_panel_section_id not in self.tool_panel:
+ if tool_panel_section_id not in self._tool_panel:
# Hack introduced without comment in a29d54619813d5da992b897557162a360b8d610c-
# not sure why it is needed.
fixed_tool_panel_section_id = 'section_%s' % tool_panel_section_id
- if fixed_tool_panel_section_id in self.tool_panel:
+ if fixed_tool_panel_section_id in self._tool_panel:
tool_panel_section_id = fixed_tool_panel_section_id
else:
tool_panel_section_id = ''
return tool_panel_section_id
- def load_workflow( self, workflow_id ):
+ def _load_workflow( self, workflow_id ):
"""
Return an instance of 'Workflow' identified by `id`,
which is encoded in the tool panel.
@@ -1147,13 +1149,13 @@
stored = self.app.model.context.query( self.app.model.StoredWorkflow ).get( id )
return stored.latest_workflow
- def init_dependency_manager( self ):
+ def _init_dependency_manager( self ):
self.dependency_manager = build_dependency_manager( self.app.config )
def handle_datatypes_changed( self ):
""" Refresh upload tools when new datatypes are added. """
- for tool_id in self.tools_by_id:
- tool = self.tools_by_id[ tool_id ]
+ for tool_id in self._tools_by_id:
+ tool = self._tools_by_id[ tool_id ]
if isinstance( tool.tool_action, UploadToolAction ):
self.reload_tool_by_id( tool_id )
@@ -1168,8 +1170,8 @@
""" Filter tool_panel contents for displaying for user.
"""
context = Bunch( toolbox=self, trans=trans )
- filters = self.filter_factory.build_filters( trans )
- for elt in self.tool_panel.itervalues():
+ filters = self._filter_factory.build_filters( trans )
+ for elt in self._tool_panel.itervalues():
elt = _filter_for_panel( elt, filters, context )
if elt:
yield elt
@@ -1190,7 +1192,7 @@
rval.append( to_dict_helper( elt, kwargs ) )
else:
tools = []
- for id, tool in self.tools_by_id.items():
+ for id, tool in self._tools_by_id.items():
tools.append( tool.to_dict( trans, link_details=True ) )
rval = tools
@@ -1205,7 +1207,7 @@
tool_lineage = tool.lineage
lineage_ids = tool_lineage.get_version_ids( reverse=True )
for lineage_id in lineage_ids:
- if lineage_id in self.tools_by_id:
+ if lineage_id in self._tools_by_id:
loaded_version_key = 'tool_%s' % lineage_id
if loaded_version_key in panel_dict:
return panel_dict[ loaded_version_key ]
diff -r 6268351b242feb5c2167b35996e264e8a51c11a9 -r 68daf6dfc8b405acbdfc64fd21d520178aff1ac4 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
@@ -18,20 +18,20 @@
assert section_id == "tid"
assert len( section.elems ) == 1 # tool.xml
assert section.id == "tid"
- assert len( toolbox.tool_panel ) == 1
+ assert len( toolbox._tool_panel ) == 1
section_id, section = tpm.handle_tool_panel_section( toolbox, new_tool_panel_section_label="tid2" )
assert section_id == "tid2"
assert len( section.elems ) == 0 # new section
assert section.id == "tid2"
- assert len( toolbox.tool_panel ) == 2
+ assert len( toolbox._tool_panel ) == 2
# Test re-fetch new section by same id.
section_id, section = tpm.handle_tool_panel_section( toolbox, new_tool_panel_section_label="tid2" )
assert section_id == "tid2"
assert len( section.elems ) == 0 # new section
assert section.id == "tid2"
- assert len( toolbox.tool_panel ) == 2
+ assert len( toolbox._tool_panel ) == 2
def test_add_tool_to_panel( self ):
self._init_tool()
@@ -77,7 +77,7 @@
assert not all_versions
# Check that tool panel has reverted to old value...
- section = self.toolbox.tool_panel["tid"]
+ section = self.toolbox._tool_panel["tid"]
assert len(section.elems) == 0
def test_uninstall_in_section( self ):
@@ -85,7 +85,7 @@
self._verify_version_2_removed_from_panel( )
# Not in tool conf because it was uninstalled.
assert "github.com/galaxyproject/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
- assert "tool_github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel["tid"].elems
+ assert "tool_github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox._integrated_tool_panel["tid"].elems
self._verify_tool_confs()
def test_deactivate_outside_section( self ):
@@ -109,7 +109,7 @@
assert not all_versions
# Check that tool panel has reverted to old value...
- section = self.toolbox.tool_panel["tid"]
+ section = self.toolbox._tool_panel["tid"]
assert len(section.elems) == 0
def _setup_two_versions_remove_one( self, section, uninstall ):
@@ -126,14 +126,14 @@
# Check that tool panel has reverted to old value...
if section:
- section = self.toolbox.tool_panel["tid"]
+ section = self.toolbox._tool_panel["tid"]
assert len(section.elems) == 1
assert section.elems.values()[0].id == "github.com/galaxyproject/example/test_tool/0.1"
- assert "github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel["tid"].elems
+ assert "github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox._integrated_tool_panel["tid"].elems
else:
- self.toolbox.tool_panel.values()[0].id == "github.com/galaxyproject/example/test_tool/0.1"
- assert "github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel
+ self.toolbox._tool_panel.values()[0].id == "github.com/galaxyproject/example/test_tool/0.1"
+ assert "github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox._integrated_tool_panel
def _remove_guids( self, guids, uninstall, shed_tool_conf="tool_conf.xml" ):
self.tpm.remove_guids(
diff -r 6268351b242feb5c2167b35996e264e8a51c11a9 -r 68daf6dfc8b405acbdfc64fd21d520178aff1ac4 test/unit/tools/test_toolbox.py
--- a/test/unit/tools/test_toolbox.py
+++ b/test/unit/tools/test_toolbox.py
@@ -182,7 +182,7 @@
self.__verify_two_test_tools( )
# Assert only newer version of the tool loaded into the panel.
- section = self.toolbox.tool_panel["tid"]
+ section = self.toolbox._tool_panel["tid"]
assert len(section.elems) == 1
assert section.elems.values()[0].id == "github.com/galaxyproject/example/test_tool/0.2"
@@ -193,7 +193,7 @@
self.__verify_two_test_tools( )
# Assert tools merged in tool panel.
- assert len( self.toolbox.tool_panel ) == 1
+ assert len( self.toolbox._tool_panel ) == 1
def test_update_shed_conf(self):
self.__setup_shed_tool_conf()
@@ -228,8 +228,8 @@
stored_workflow = self.__test_workflow()
encoded_id = self.app.security.encode_id( stored_workflow.id )
self._add_config( """<toolbox><workflow id="%s" /></toolbox>""" % encoded_id )
- assert len( self.toolbox.tool_panel ) == 1
- panel_workflow = self.toolbox.tool_panel.values()[ 0 ]
+ assert len( self.toolbox._tool_panel ) == 1
+ panel_workflow = self.toolbox._tool_panel.values()[ 0 ]
assert panel_workflow == stored_workflow.latest_workflow
# TODO: test to_dict with workflows
@@ -237,21 +237,21 @@
stored_workflow = self.__test_workflow()
encoded_id = self.app.security.encode_id( stored_workflow.id )
self._add_config( """<toolbox><section id="tid" name="TID"><workflow id="%s" /></section></toolbox>""" % encoded_id )
- assert len( self.toolbox.tool_panel ) == 1
- section = self.toolbox.tool_panel[ 'tid' ]
+ assert len( self.toolbox._tool_panel ) == 1
+ section = self.toolbox._tool_panel[ 'tid' ]
assert len( section.elems ) == 1
panel_workflow = section.elems.values()[ 0 ]
assert panel_workflow == stored_workflow.latest_workflow
def test_label_in_panel( self ):
self._add_config( """<toolbox><label id="lab1" text="Label 1" /><label id="lab2" text="Label 2" /></toolbox>""" )
- assert len( self.toolbox.tool_panel ) == 2
- self.__check_test_labels( self.toolbox.tool_panel )
+ assert len( self.toolbox._tool_panel ) == 2
+ self.__check_test_labels( self.toolbox._tool_panel )
def test_label_in_section( self ):
self._add_config( """<toolbox><section id="tid" name="TID"><label id="lab1" text="Label 1" /><label id="lab2" text="Label 2" /></section></toolbox>""" )
- assert len( self.toolbox.tool_panel ) == 1
- section = self.toolbox.tool_panel[ 'tid' ]
+ assert len( self.toolbox._tool_panel ) == 1
+ section = self.toolbox._tool_panel[ 'tid' ]
self.__check_test_labels( section.elems )
def __check_test_labels( self, panel_dict ):
https://bitbucket.org/galaxy/galaxy-central/commits/dc14223818bd/
Changeset: dc14223818bd
User: jmchilton
Date: 2014-12-29 17:50:27+00:00
Summary: Hack to fix bug introduced in 806202d.
I may be trying to juggle to many competing branches working on same component.
Affected #: 1 file
diff -r 68daf6dfc8b405acbdfc64fd21d520178aff1ac4 -r dc14223818bd8b8a908e056f361f2be1e8972d91 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -1204,6 +1204,8 @@
"""
if tool_lineage is None:
assert tool is not None
+ if not hasattr( tool, "lineage" ):
+ return None
tool_lineage = tool.lineage
lineage_ids = tool_lineage.get_version_ids( reverse=True )
for lineage_id in lineage_ids:
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.
1
0
commit/galaxy-central: jmchilton: Shield ToolBox details from Tool.
by commits-noreply@bitbucket.org 29 Dec '14
by commits-noreply@bitbucket.org 29 Dec '14
29 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/6268351b242f/
Changeset: 6268351b242f
User: jmchilton
Date: 2014-12-29 17:14:41+00:00
Summary: Shield ToolBox details from Tool.
Better seperation of concerns.
Affected #: 1 file
diff -r 069b1c6c5f67e74c88d8109ba89cb52ed28deee4 -r 6268351b242feb5c2167b35996e264e8a51c11a9 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -304,6 +304,23 @@
tool_section = None
return tool_panel_section_key, tool_section
+ def get_integrated_section_for_tool( self, tool ):
+ tool_id = tool.id
+ for key, item in self.integrated_tool_panel.items():
+ if item:
+ if isinstance( item, Tool ):
+ if item.id == tool_id:
+ return '', ''
+ if isinstance( item, ToolSection ):
+ section_id = item.id or ''
+ section_name = item.name or ''
+ for section_key, section_item in item.elems.items():
+ if isinstance( section_item, Tool ):
+ if section_item:
+ if section_item.id == tool_id:
+ return section_id, section_name
+ return None, None
+
def __resolve_tool_path(self, tool_path, config_filename):
if not tool_path:
# Default to backward compatible config setting.
@@ -1553,20 +1570,7 @@
return self.app.job_config.get_destination(self.__get_job_tool_configuration(job_params=job_params).destination)
def get_panel_section( self ):
- for key, item in self.app.toolbox.integrated_tool_panel.items():
- if item:
- if isinstance( item, Tool ):
- if item.id == self.id:
- return '', ''
- if isinstance( item, ToolSection ):
- section_id = item.id or ''
- section_name = item.name or ''
- for section_key, section_item in item.elems.items():
- if isinstance( section_item, Tool ):
- if section_item:
- if section_item.id == self.id:
- return section_id, section_name
- return None, None
+ return self.app.toolbox.get_integrated_section_for_tool( self )
def parse( self, tool_source, guid=None ):
"""
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.
1
0
commit/galaxy-central: jmchilton: Bugfix: Apply tool panel filtering in workflow editor.
by commits-noreply@bitbucket.org 29 Dec '14
by commits-noreply@bitbucket.org 29 Dec '14
29 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/069b1c6c5f67/
Changeset: 069b1c6c5f67
User: jmchilton
Date: 2014-12-29 16:48:38+00:00
Summary: Bugfix: Apply tool panel filtering in workflow editor.
Bug originally reported by Eric here - http://dev.list.galaxyproject.org/Bug-Toolbox-filters-not-applied-in-workfl… (though this only fixes the superficial bug of them showing up in the workflow editor - and does not yet implement "strong" toolbox filters as requested).
This is actually a broader change that centralizes logic for listing out tool panel contents when displaying components to the user and the added filtering comes about from that. It also eliminates the last places Galaxy was accessing toolbox.tool_panel directly (in those mako templates).
Affected #: 4 files
diff -r ad5094376c1042a3c5aeab793e326cebcc9818b9 -r 069b1c6c5f67e74c88d8109ba89cb52ed28deee4 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -1147,24 +1147,22 @@
"""
return self.app.model.context
+ def tool_panel_contents( self, trans, **kwds ):
+ """ Filter tool_panel contents for displaying for user.
+ """
+ context = Bunch( toolbox=self, trans=trans )
+ filters = self.filter_factory.build_filters( trans )
+ for elt in self.tool_panel.itervalues():
+ elt = _filter_for_panel( elt, filters, context )
+ if elt:
+ yield elt
+
def to_dict( self, trans, in_panel=True, **kwds ):
"""
to_dict toolbox.
"""
-
- context = Bunch( toolbox=self, trans=trans, **kwds )
if in_panel:
- panel_elts = [ val for val in self.tool_panel.itervalues() ]
-
- filters = self.filter_factory.build_filters( trans, **kwds )
-
- filtered_panel_elts = []
- for index, elt in enumerate( panel_elts ):
- elt = _filter_for_panel( elt, filters, context )
- if elt:
- filtered_panel_elts.append( elt )
- panel_elts = filtered_panel_elts
-
+ panel_elts = list( self.tool_panel_contents( trans, **kwds ) )
# Produce panel.
rval = []
kwargs = dict(
diff -r ad5094376c1042a3c5aeab793e326cebcc9818b9 -r 069b1c6c5f67e74c88d8109ba89cb52ed28deee4 templates/admin/package_tool.mako
--- a/templates/admin/package_tool.mako
+++ b/templates/admin/package_tool.mako
@@ -26,7 +26,7 @@
Tool to bundle:
</label><select name="tool_id">
- %for key, val in toolbox.tool_panel.items():
+ %for val in toolbox.tool_panel_contents( trans ):
%if isinstance( val, Tool ):
<option value="${val.id|h}">${val.name|h}</option>
%elif isinstance( val, ToolSection ):
diff -r ad5094376c1042a3c5aeab793e326cebcc9818b9 -r 069b1c6c5f67e74c88d8109ba89cb52ed28deee4 templates/admin/reload_tool.mako
--- a/templates/admin/reload_tool.mako
+++ b/templates/admin/reload_tool.mako
@@ -26,7 +26,7 @@
Tool to reload:
</label><select name="tool_id">
- %for key, val in toolbox.tool_panel.items():
+ %for val in toolbox.tool_panel_contents( trans ):
%if isinstance( val, Tool ):
<option value="${val.id}">${val.name|h}</option>
%elif isinstance( val, ToolSection ):
diff -r ad5094376c1042a3c5aeab793e326cebcc9818b9 -r 069b1c6c5f67e74c88d8109ba89cb52ed28deee4 templates/webapps/galaxy/workflow/editor.mako
--- a/templates/webapps/galaxy/workflow/editor.mako
+++ b/templates/webapps/galaxy/workflow/editor.mako
@@ -284,7 +284,7 @@
<img src="${h.url_for('/static/images/loading_small_white_bg.gif')}" id="search-spinner" class="search-spinner" /></div><div class="toolSectionList">
- %for key, val in app.toolbox.tool_panel.items():
+ %for val in app.toolbox.tool_panel_contents( trans ):
<div class="toolSectionWrapper">
%if isinstance( val, Tool ):
${render_tool( val, False )}
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.
1
0
commit/galaxy-central: jmchilton: Fix unit tests for 7cee92f.
by commits-noreply@bitbucket.org 29 Dec '14
by commits-noreply@bitbucket.org 29 Dec '14
29 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/ad5094376c10/
Changeset: ad5094376c10
User: jmchilton
Date: 2014-12-29 16:10:41+00:00
Summary: Fix unit tests for 7cee92f.
Affected #: 1 file
diff -r 806202db57a7502c2aa5476f2db46f7aae75f439 -r ad5094376c1042a3c5aeab793e326cebcc9818b9 test/unit/tools/test_toolbox.py
--- a/test/unit/tools/test_toolbox.py
+++ b/test/unit/tools/test_toolbox.py
@@ -197,13 +197,13 @@
def test_update_shed_conf(self):
self.__setup_shed_tool_conf()
- self.toolbox.update_shed_config( 0, {} )
+ self.toolbox.update_shed_config( { "config_filename": "tool_conf.xml" } )
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 )
+ self.toolbox.update_shed_config( { "config_filename": "tool_conf.xml" }, integrated_panel_changes=False )
assert self.reindexed
# No changes, should be regenerated
self.assert_integerated_tool_panel(exists=False)
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.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/b26dc879b09c/
Changeset: b26dc879b09c
User: jmchilton
Date: 2014-12-29 15:28:37+00:00
Summary: Abstract tool lineage handling out of ToolBox.
Start work on infrastructure to support tool lineages not defined within the tool shed install model.
Affected #: 5 files
diff -r 68255ebe3f54500aa26db814c41f67f382731462 -r b26dc879b09c639b47c76cb97b067073a3c956e6 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -53,6 +53,7 @@
from galaxy.tools.parser import get_tool_source
from galaxy.tools.parser.xml import XmlPageSource
from galaxy.tools.toolbox import tool_tag_manager
+from galaxy.tools.toolbox.lineages import LineageMap
from galaxy.util import listify, parse_xml, rst_to_html, string_as_bool, string_to_object
from galaxy.tools.parameters.meta import expand_meta_parameters
from galaxy.util.bunch import Bunch
@@ -139,6 +140,7 @@
self.tool_panel = odict()
self.index = 0
self.data_manager_tools = odict()
+ self.lineage_map = LineageMap( app )
# File that contains the XML section and tool tags from all tool panel config files integrated into a
# single file that defines the tool panel layout. This file can be changed by the Galaxy administrator
# (in a way similar to the single tool_conf.xml file in the past) to alter the layout of the tool panel.
@@ -371,8 +373,8 @@
log.debug( "Loaded tool id: %s, version: %s into tool panel.." % ( tool.id, tool.version ) )
else:
# We are in the process of installing the tool.
- tool_version = self.__get_tool_version( tool_id )
- tool_lineage_ids = tool_version.get_version_ids( self.app, reverse=True )
+ tool_lineage = self.lineage_map.get( tool_id )
+ tool_lineage_ids = tool_lineage.get_version_ids( reverse=True )
for lineage_id in tool_lineage_ids:
if lineage_id in self.tools_by_id:
loaded_version_key = 'tool_%s' % lineage_id
@@ -512,9 +514,9 @@
return self.tools_by_id[ tool_id ]
#exact tool id match not found, or all versions requested, search for other options, e.g. migrated tools or different versions
rval = []
- tv = self.__get_tool_version( tool_id )
- if tv:
- tool_version_ids = tv.get_version_ids( self.app )
+ tool_lineage = self.lineage_map.get( tool_id )
+ if tool_lineage:
+ tool_version_ids = tool_lineage.get_version_ids( )
for tool_version_id in tool_version_ids:
if tool_version_id in self.tools_by_id:
rval.append( self.tools_by_id[ tool_version_id ] )
@@ -560,9 +562,9 @@
def get_loaded_tools_by_lineage( self, tool_id ):
"""Get all loaded tools associated by lineage to the tool whose id is tool_id."""
- tv = self.__get_tool_version( tool_id )
- if tv:
- tool_version_ids = tv.get_version_ids( self.app )
+ tool_lineage = self.lineage_map.get( tool_id )
+ if tool_lineage:
+ tool_version_ids = tool_lineage.get_version_ids( )
available_tool_versions = []
for tool_version_id in tool_version_ids:
if tool_version_id in self.tools_by_id:
@@ -574,12 +576,6 @@
return [ tool ]
return []
- def __get_tool_version( self, tool_id ):
- """Return a ToolVersion if one exists for the tool_id"""
- return self.app.install_model.context.query( self.app.install_model.ToolVersion ) \
- .filter( self.app.install_model.ToolVersion.table.c.tool_id == tool_id ) \
- .first()
-
def tools( self ):
return self.tools_by_id.iteritems()
@@ -745,12 +741,10 @@
tool.guid = guid
tool.version = elem.find( "version" ).text
# Make sure the tool has a tool_version.
- if not self.__get_tool_version( tool.id ):
- tool_version = self.app.install_model.ToolVersion( tool_id=tool.id, tool_shed_repository=tool_shed_repository )
- self.app.install_model.context.add( tool_version )
- self.app.install_model.context.flush()
+ tool_lineage = self.lineage_map.register( tool, tool_shed_repository=tool_shed_repository )
# Load the tool's lineage ids.
- tool.lineage_ids = tool.tool_version.get_version_ids( self.app )
+ tool.lineage = tool_lineage
+ tool.lineage_ids = tool_lineage.get_version_ids( )
self.tool_tag_manager.handle_tags( tool.id, elem )
self.__add_tool( tool, load_panel_dict, panel_dict )
# Always load the tool into the integrated_panel_dict, or it will not be included in the integrated_tool_panel.xml file.
@@ -1493,14 +1487,6 @@
return []
@property
- def tool_version_ids( self ):
- # If we have versions, return a list of their tool_ids.
- tool_version = self.tool_version
- if tool_version:
- return tool_version.get_version_ids( self.app )
- return []
-
- @property
def tool_shed_repository( self ):
# If this tool is included in an installed tool shed repository, return it.
if self.tool_shed:
diff -r 68255ebe3f54500aa26db814c41f67f382731462 -r b26dc879b09c639b47c76cb97b067073a3c956e6 lib/galaxy/tools/toolbox/lineages/__init__.py
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/lineages/__init__.py
@@ -0,0 +1,5 @@
+from .factory import LineageMap
+from .interface import ToolLineage
+
+
+__all__ = ["LineageMap", "ToolLineage"]
diff -r 68255ebe3f54500aa26db814c41f67f382731462 -r b26dc879b09c639b47c76cb97b067073a3c956e6 lib/galaxy/tools/toolbox/lineages/factory.py
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/lineages/factory.py
@@ -0,0 +1,28 @@
+from .tool_shed import ToolShedLineage
+
+
+class LineageMap(object):
+ """ Map each unique tool id to a lineage object.
+ """
+
+ def __init__(self, app):
+ self.lineage_map = {}
+ self.app = app
+
+ def register(self, tool, **kwds):
+ tool_id = tool.id
+ if tool_id not in self.lineage_map:
+ tool_shed_repository = kwds.get("tool_shed_repository", None)
+ lineage = ToolShedLineage.from_tool(self.app, tool, tool_shed_repository)
+ self.lineage_map[tool_id] = lineage
+ return self.lineage_map[tool_id]
+
+ def get(self, tool_id):
+ if tool_id not in self.lineage_map:
+ lineage = ToolShedLineage.from_tool_id( self.app, tool_id )
+ if lineage:
+ self.lineage_map[tool_id] = lineage
+
+ return self.lineage_map.get(tool_id, None)
+
+__all__ = ["LineageMap"]
diff -r 68255ebe3f54500aa26db814c41f67f382731462 -r b26dc879b09c639b47c76cb97b067073a3c956e6 lib/galaxy/tools/toolbox/lineages/interface.py
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/lineages/interface.py
@@ -0,0 +1,14 @@
+from abc import ABCMeta
+from abc import abstractmethod
+
+
+class ToolLineage(object):
+ """
+ """
+ __metaclass__ = ABCMeta
+
+ @abstractmethod
+ def get_version_ids( self, reverse=False ):
+ """ Return an ordered list of lineages in this chain, from
+ oldest to newest.
+ """
diff -r 68255ebe3f54500aa26db814c41f67f382731462 -r b26dc879b09c639b47c76cb97b067073a3c956e6 lib/galaxy/tools/toolbox/lineages/tool_shed.py
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/lineages/tool_shed.py
@@ -0,0 +1,43 @@
+from .interface import ToolLineage
+
+from galaxy.model.tool_shed_install import ToolVersion
+
+
+class ToolShedLineage(ToolLineage):
+ """ Representation of tool lineage derived from tool shed repository
+ installations. """
+
+ def __init__(self, app, tool_version):
+ self.app = app
+ self.tool_version_id = tool_version.id
+
+ @staticmethod
+ def from_tool( app, tool, tool_shed_repository ):
+ # Make sure the tool has a tool_version.
+ if not get_install_tool_version( app, tool.id ):
+ tool_version = ToolVersion( tool_id=tool.id, tool_shed_repository=tool_shed_repository )
+ app.install_model.context.add( tool_version )
+ app.install_model.context.flush()
+ return ToolShedLineage( app, tool.tool_version )
+
+ @staticmethod
+ def from_tool_id( app, tool_id ):
+ tool_version = get_install_tool_version( app, tool_id )
+ if tool_version:
+ return ToolShedLineage( app, tool_version )
+ else:
+ return None
+
+ def get_version_ids( self, reverse=False ):
+ tool_version = self.app.install_model.context.query( ToolVersion ).get( self.tool_version_id )
+ return tool_version.get_version_ids( self.app, reverse=reverse )
+
+
+def get_install_tool_version( app, tool_id ):
+ return app.install_model.context.query(
+ app.install_model.ToolVersion
+ ).filter(
+ app.install_model.ToolVersion.table.c.tool_id == tool_id
+ ).first()
+
+__all__ = [ "ToolShedLineage" ]
https://bitbucket.org/galaxy/galaxy-central/commits/806202db57a7/
Changeset: 806202db57a7
User: jmchilton
Date: 2014-12-29 15:28:37+00:00
Summary: Abstract out higher-level helpers in ToolBox for lineage reasoning.
Reduces code duplication slightly and simplifies __add_tool_to_tool_panel (cyclomatic complexity reduced from 20 to 14).
Affected #: 1 file
diff -r b26dc879b09c639b47c76cb97b067073a3c956e6 -r 806202db57a7502c2aa5476f2db46f7aae75f439 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -325,20 +325,13 @@
panel_dict = panel_component.elems
else:
panel_dict = panel_component
- already_loaded = False
- loaded_version_key = None
- lineage_id = None
- for lineage_id in tool.lineage_ids:
- if lineage_id in self.tools_by_id:
- loaded_version_key = 'tool_%s' % lineage_id
- if loaded_version_key in panel_dict:
- already_loaded = True
- break
- if already_loaded:
- if tool.lineage_ids.index( tool_id ) > tool.lineage_ids.index( lineage_id ):
+ related_tool = self._lineage_in_panel( panel_dict, tool=tool )
+ if related_tool:
+ if self._newer_tool( tool, related_tool ):
+ lineage_id = "tool_%s" % related_tool.id
+ index = panel_dict.keys().index( lineage_id )
+ del panel_dict[ lineage_id ]
key = 'tool_%s' % tool.id
- index = panel_dict.keys().index( loaded_version_key )
- del panel_dict[ loaded_version_key ]
panel_dict.insert( index, key, tool )
log.debug( "Loaded tool id: %s, version: %s into tool panel." % ( tool.id, tool.version ) )
else:
@@ -374,12 +367,7 @@
else:
# We are in the process of installing the tool.
tool_lineage = self.lineage_map.get( tool_id )
- tool_lineage_ids = tool_lineage.get_version_ids( reverse=True )
- for lineage_id in tool_lineage_ids:
- if lineage_id in self.tools_by_id:
- loaded_version_key = 'tool_%s' % lineage_id
- if loaded_version_key in panel_dict:
- already_loaded = True
+ already_loaded = self._lineage_in_panel( panel_dict, tool_lineage=tool_lineage ) is not None
if not already_loaded:
# If the tool is not defined in integrated_tool_panel.xml, append it to the tool panel.
panel_dict[ key ] = tool
@@ -1193,6 +1181,27 @@
return rval
+ def _lineage_in_panel( self, panel_dict, tool=None, tool_lineage=None ):
+ """ If tool with same lineage already in panel (or section) - find
+ and return it. Otherwise return None.
+ """
+ if tool_lineage is None:
+ assert tool is not None
+ tool_lineage = tool.lineage
+ lineage_ids = tool_lineage.get_version_ids( reverse=True )
+ for lineage_id in lineage_ids:
+ if lineage_id in self.tools_by_id:
+ loaded_version_key = 'tool_%s' % lineage_id
+ if loaded_version_key in panel_dict:
+ return panel_dict[ loaded_version_key ]
+ return None
+
+ def _newer_tool( self, tool1, tool2 ):
+ """ Return True if tool1 is considered "newer" given its own lineage
+ description.
+ """
+ return tool1.lineage_ids.index( tool1.id ) > tool1.lineage_ids.index( tool2.id )
+
def _filter_for_panel( item, filters, context ):
"""
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.
1
0
12 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/8896bf67ff7a/
Changeset: 8896bf67ff7a
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Correct sample value for migrated tool config.
Affected #: 1 file
diff -r bfd679408c84a4c6f1d2b1a09eec1dab9c2d212b -r 8896bf67ff7ae6f4379ff0e18c30559a20cf6584 config/galaxy.ini.sample
--- a/config/galaxy.ini.sample
+++ b/config/galaxy.ini.sample
@@ -148,7 +148,7 @@
# Tool config maintained by tool migration scripts. If you use the migration
# scripts to install tools that have been migrated to the tool shed upon a new
# release, they will be added to this tool config file.
-#migrated_tools_config = migrated_tools_conf.xml
+#migrated_tools_config = config/migrated_tools_conf.xml
# File that contains the XML section and tool tags from all tool panel config
# files integrated into a single file that defines the tool panel layout. This
https://bitbucket.org/galaxy/galaxy-central/commits/d87f3d474c9a/
Changeset: d87f3d474c9a
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Small simplification to tool_panel_manager.py.
Affected #: 1 file
diff -r 8896bf67ff7ae6f4379ff0e18c30559a20cf6584 -r d87f3d474c9ab798e88286f80c09cef2bc41451a 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
@@ -243,22 +243,13 @@
tool_file_path, tup_guid, tool = repository_tool_tup
if tup_guid == guid:
break
- if inside_section:
- tool_elem = self.generate_tool_elem( tool_shed,
- repository_name,
- changeset_revision,
- owner,
- tool_file_path,
- tool,
- tool_section )
- else:
- tool_elem = self.generate_tool_elem( tool_shed,
- repository_name,
- changeset_revision,
- owner,
- tool_file_path,
- tool,
- None )
+ tool_elem = self.generate_tool_elem( tool_shed,
+ repository_name,
+ changeset_revision,
+ owner,
+ tool_file_path,
+ tool,
+ tool_section if inside_section else None )
if inside_section:
if section_in_elem_list:
elem_list[ index ] = tool_section
https://bitbucket.org/galaxy/galaxy-central/commits/000cd07f16f9/
Changeset: 000cd07f16f9
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Reused get_section method to hide ToolBox.tool_panel from install_manager.py.
Affected #: 4 files
diff -r d87f3d474c9ab798e88286f80c09cef2bc41451a -r 000cd07f16f991cb78025e23f0872bafd58b9daf lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -277,13 +277,13 @@
self.write_integrated_tool_panel_config_file()
app.reindex_tool_search()
- def get_or_create_section( self, section_id, new_label=None ):
+ def get_section( self, section_id, new_label=None, create_if_needed=False ):
tool_panel_section_key = str( section_id )
if tool_panel_section_key in self.tool_panel:
# Appending a tool to an existing section in toolbox.tool_panel
tool_section = self.tool_panel[ tool_panel_section_key ]
log.debug( "Appending to tool panel section: %s" % str( tool_section.name ) )
- else:
+ elif create_if_needed:
# Appending a new section to toolbox.tool_panel
if new_label is None:
# This might add an ugly section label to the tool panel, but, oh well...
@@ -296,6 +296,8 @@
tool_section = ToolSection( section_dict )
self.tool_panel[ tool_panel_section_key ] = tool_section
log.debug( "Loading new tool panel section: %s" % str( tool_section.name ) )
+ else:
+ tool_section = None
return tool_panel_section_key, tool_section
def __resolve_tool_path(self, tool_path, config_filename):
diff -r d87f3d474c9ab798e88286f80c09cef2bc41451a -r 000cd07f16f991cb78025e23f0872bafd58b9daf 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
@@ -809,12 +809,10 @@
def install_tool_shed_repository( self, tool_shed_repository, repo_info_dict, tool_panel_section_key, shed_tool_conf, tool_path,
install_tool_dependencies, reinstalling=False ):
if tool_panel_section_key:
- try:
- tool_section = self.app.toolbox.tool_panel[ tool_panel_section_key ]
- except KeyError:
+ _, tool_section = self.app.toolbox.get_section( tool_panel_section_key )
+ if tool_section is None:
log.debug( 'Invalid tool_panel_section_key "%s" specified. Tools will be loaded outside of sections in the tool panel.',
str( tool_panel_section_key ) )
- tool_section = None
else:
tool_section = None
if isinstance( repo_info_dict, basestring ):
diff -r d87f3d474c9ab798e88286f80c09cef2bc41451a -r 000cd07f16f991cb78025e23f0872bafd58b9daf 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
@@ -297,7 +297,7 @@
return tool_section
def get_or_create_tool_section( self, toolbox, tool_panel_section_id, new_tool_panel_section_label=None ):
- return toolbox.get_or_create_section( section_id=tool_panel_section_id, new_label=new_tool_panel_section_label )
+ return toolbox.get_section( section_id=tool_panel_section_id, new_label=new_tool_panel_section_label, create_if_needed=True )
def get_shed_tool_conf_dict( self, shed_tool_conf ):
"""
diff -r d87f3d474c9ab798e88286f80c09cef2bc41451a -r 000cd07f16f991cb78025e23f0872bafd58b9daf 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
@@ -46,7 +46,7 @@
self.tool,
)
]
- _, section = self.toolbox.get_or_create_section("tid1")
+ _, 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,
https://bitbucket.org/galaxy/galaxy-central/commits/739ca42b8555/
Changeset: 739ca42b8555
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: PEP-8 fixes for various Tool Shed components.
- lib/tool_shed/util/tool_util.py
- lib/tool_shed/galaxy_install/tool_migration_manager.py.
- lib/tool_shed/util/shed_util_common.py.
- lib/galaxy/model/tool_shed_install/__init__.py.
Affected #: 4 files
diff -r 000cd07f16f991cb78025e23f0872bafd58b9daf -r 739ca42b855530e8293cbb25298e1d4f6ef03d15 lib/galaxy/model/tool_shed_install/__init__.py
--- a/lib/galaxy/model/tool_shed_install/__init__.py
+++ b/lib/galaxy/model/tool_shed_install/__init__.py
@@ -11,9 +11,9 @@
class ToolShedRepository( object ):
dict_collection_visible_keys = ( 'id', 'tool_shed', 'name', 'owner', 'installed_changeset_revision', 'changeset_revision', 'ctx_rev', 'includes_datatypes',
- 'tool_shed_status', 'deleted', 'uninstalled', 'dist_to_shed', 'status', 'error_message' )
+ 'tool_shed_status', 'deleted', 'uninstalled', 'dist_to_shed', 'status', 'error_message' )
dict_element_visible_keys = ( 'id', 'tool_shed', 'name', 'owner', 'installed_changeset_revision', 'changeset_revision', 'ctx_rev', 'includes_datatypes',
- 'tool_shed_status', 'deleted', 'uninstalled', 'dist_to_shed', 'status', 'error_message' )
+ 'tool_shed_status', 'deleted', 'uninstalled', 'dist_to_shed', 'status', 'error_message' )
installation_status = Bunch( NEW='New',
CLONING='Cloning',
SETTING_TOOL_VERSIONS='Setting tool versions',
@@ -356,12 +356,12 @@
for rd_tup in rd_tups:
if len( rd_tup ) == 5:
tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td = \
- common_util.parse_repository_dependency_tuple( rd_tup, contains_error=False )
+ common_util.parse_repository_dependency_tuple( rd_tup, contains_error=False )
if asbool( prior_installation_required ):
required_rd_tups_that_must_be_installed.append( ( tool_shed, name, owner, changeset_revision, 'True', 'False' ) )
elif len( rd_tup ) == 6:
tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td = \
- common_util.parse_repository_dependency_tuple( rd_tup, contains_error=False )
+ common_util.parse_repository_dependency_tuple( rd_tup, contains_error=False )
# The repository dependency will only be required to be previously installed if it does not fall into the category of
# a repository that must be installed only so that its contained tool dependency can be used for compiling the tool
# dependency of the dependent repository.
@@ -493,12 +493,14 @@
class RepositoryRepositoryDependencyAssociation( object ):
+
def __init__( self, tool_shed_repository_id=None, repository_dependency_id=None ):
self.tool_shed_repository_id = tool_shed_repository_id
self.repository_dependency_id = repository_dependency_id
class RepositoryDependency( object ):
+
def __init__( self, tool_shed_repository_id=None ):
self.tool_shed_repository_id = tool_shed_repository_id
@@ -647,6 +649,7 @@
class ToolVersionAssociation( object ):
+
def __init__( self, id=None, tool_id=None, parent_id=None ):
self.id = id
self.tool_id = tool_id
@@ -654,6 +657,7 @@
class MigrateTools( object ):
+
def __init__( self, repository_id=None, repository_path=None, version=None ):
self.repository_id = repository_id
self.repository_path = repository_path
diff -r 000cd07f16f991cb78025e23f0872bafd58b9daf -r 739ca42b855530e8293cbb25298e1d4f6ef03d15 lib/tool_shed/galaxy_install/tool_migration_manager.py
--- a/lib/tool_shed/galaxy_install/tool_migration_manager.py
+++ b/lib/tool_shed/galaxy_install/tool_migration_manager.py
@@ -171,8 +171,6 @@
clone_dir = os.path.join( self.tool_path, relative_clone_dir )
if not self.__iscloned( clone_dir ):
repository_clone_url = os.path.join( self.tool_shed_url, 'repos', owner, name )
- relative_install_dir = os.path.join( relative_clone_dir, name )
- install_dir = os.path.join( clone_dir, name )
ctx_rev = suc.get_ctx_rev( self.app, self.tool_shed_url, name, owner, changeset_revision )
tool_shed_repository = suc.create_or_update_tool_shed_repository( app=self.app,
name=name,
@@ -406,7 +404,7 @@
tool_configs_to_filter.append( tool_config )
else:
print 'The tool "%s" (%s) has not been enabled because it is not defined in a proprietary tool config (%s).' \
- % ( guid, tool_config, ", ".join( self.proprietary_tool_confs or [] ) )
+ % ( guid, tool_config, ", ".join( self.proprietary_tool_confs or [] ) )
if tool_configs_to_filter:
lock = threading.Lock()
lock.acquire( True )
@@ -421,7 +419,7 @@
repository=tool_shed_repository,
changeset_revision=tool_shed_repository.changeset_revision,
repository_clone_url=repository_clone_url,
- shed_config_dict = self.shed_config_dict,
+ shed_config_dict=self.shed_config_dict,
relative_install_dir=relative_install_dir,
repository_files_dir=None,
resetting_all_metadata_on_repository=False,
@@ -504,11 +502,11 @@
datatypes_config = hg_util.get_config_from_disk( suc.DATATYPES_CONFIG_FILENAME, repo_install_dir )
# Load proprietary data types required by tools. The value of override is not
# important here since the Galaxy server will be started after this installation
- #completes.
+ # completes.
converter_path, display_path = \
cdl.alter_config_and_load_prorietary_datatypes( datatypes_config,
repo_install_dir,
- override=False )
+ override=False )
if converter_path or display_path:
# Create a dictionary of tool shed repository related information.
repository_dict = \
@@ -583,23 +581,23 @@
tool_version_dicts = json.loads( text )
tvm.handle_tool_versions( tool_version_dicts, tool_shed_repository )
else:
- # Set the tool versions since they seem to be missing for this repository in the tool shed.
- # CRITICAL NOTE: These default settings may not properly handle all parent/child associations.
+ # Set the tool versions since they seem to be missing
+ # for this repository in the tool shed. CRITICAL NOTE:
+ # These default settings may not properly handle all
+ # parent/child associations.
for tool_dict in metadata_dict[ 'tools' ]:
- flush_needed = False
tool_id = tool_dict[ 'guid' ]
old_tool_id = tool_dict[ 'id' ]
- tool_version = tool_dict[ 'version' ]
tool_version_using_old_id = tvm.get_tool_version( old_tool_id )
tool_version_using_guid = tvm.get_tool_version( tool_id )
if not tool_version_using_old_id:
tool_version_using_old_id = self.app.install_model.ToolVersion( tool_id=old_tool_id,
- tool_shed_repository=tool_shed_repository )
+ tool_shed_repository=tool_shed_repository )
self.app.install_model.context.add( tool_version_using_old_id )
self.app.install_model.context.flush()
if not tool_version_using_guid:
tool_version_using_guid = self.app.install_model.ToolVersion( tool_id=tool_id,
- tool_shed_repository=tool_shed_repository )
+ tool_shed_repository=tool_shed_repository )
self.app.install_model.context.add( tool_version_using_guid )
self.app.install_model.context.flush()
# Associate the two versions as parent / child.
@@ -640,7 +638,6 @@
ordered_tsr_ids = []
processed_tsr_ids = []
prior_install_required_dict = self.get_prior_install_required_dict( tool_shed_repositories, repository_dependencies_dict )
- tsr_ids = [ tool_shed_repository.id for tool_shed_repository in tool_shed_repositories ]
while len( processed_tsr_ids ) != len( prior_install_required_dict.keys() ):
tsr_id = suc.get_next_prior_import_or_install_required_dict_entry( prior_install_required_dict, processed_tsr_ids )
processed_tsr_ids.append( tsr_id )
diff -r 000cd07f16f991cb78025e23f0872bafd58b9daf -r 739ca42b855530e8293cbb25298e1d4f6ef03d15 lib/tool_shed/util/shed_util_common.py
--- a/lib/tool_shed/util/shed_util_common.py
+++ b/lib/tool_shed/util/shed_util_common.py
@@ -3,6 +3,7 @@
import os
import re
import shutil
+import socket
import string
import sqlalchemy.orm.exc
@@ -81,6 +82,7 @@
'${host}'
"""
+
def create_or_update_tool_shed_repository( app, name, description, installed_changeset_revision, ctx_rev, repository_clone_url,
metadata_dict, status, current_changeset_revision=None, owner='', dist_to_shed=False ):
"""
@@ -118,8 +120,8 @@
owner,
installed_changeset_revision )
if tool_shed_repository:
- log.debug( "Updating an existing row for repository '%s' in the tool_shed_repository table, status set to '%s'." % \
- ( str( name ), str( status ) ) )
+ log.debug( "Updating an existing row for repository '%s' in the tool_shed_repository table, status set to '%s'." %
+ ( str( name ), str( status ) ) )
tool_shed_repository.description = description
tool_shed_repository.changeset_revision = current_changeset_revision
tool_shed_repository.ctx_rev = ctx_rev
@@ -129,8 +131,8 @@
tool_shed_repository.uninstalled = uninstalled
tool_shed_repository.status = status
else:
- log.debug( "Adding new row for repository '%s' in the tool_shed_repository table, status set to '%s'." % \
- ( str( name ), str( status ) ) )
+ log.debug( "Adding new row for repository '%s' in the tool_shed_repository table, status set to '%s'." %
+ ( str( name ), str( status ) ) )
tool_shed_repository = \
app.install_model.ToolShedRepository( tool_shed=tool_shed,
name=name,
@@ -149,6 +151,7 @@
context.flush()
return tool_shed_repository
+
def extract_components_from_tuple( repository_components_tuple ):
'''Extract the repository components from the provided tuple in a backward-compatible manner.'''
toolshed = repository_components_tuple[ 0 ]
@@ -164,6 +167,7 @@
components_list = [ toolshed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td ]
return components_list
+
def generate_sharable_link_for_repository_in_tool_shed( repository, changeset_revision=None ):
"""Generate the URL for sharing a repository that is in the tool shed."""
base_url = url_for( '/', qualified=True ).rstrip( '/' )
@@ -173,6 +177,7 @@
sharable_url += '/%s' % changeset_revision
return sharable_url
+
def generate_tool_guid( repository_clone_url, tool ):
"""
Generate a guid for the installed tool. It is critical that this guid matches the guid for
@@ -182,6 +187,7 @@
tmp_url = common_util.remove_protocol_and_user_from_clone_url( repository_clone_url )
return '%s/%s/%s' % ( tmp_url, tool.id, tool.version )
+
def generate_tool_shed_repository_install_dir( repository_clone_url, changeset_revision ):
"""
Generate a repository installation directory that guarantees repositories with the same
@@ -196,6 +202,7 @@
tool_shed_url = common_util.remove_port_from_tool_shed_url( tool_shed_url )
return common_util.url_join( tool_shed_url, 'repos', repo_path, changeset_revision )
+
def get_absolute_path_to_file_in_repository( repo_files_dir, file_name ):
"""Return the absolute path to a specified disk file contained in a repository."""
stripped_file_name = basic_util.strip_path( file_name )
@@ -207,19 +214,22 @@
return os.path.abspath( os.path.join( root, name ) )
return file_path
+
def get_categories( app ):
"""Get all categories from the database."""
sa_session = app.model.context.current
return sa_session.query( app.model.Category ) \
- .filter( app.model.Category.table.c.deleted==False ) \
+ .filter( app.model.Category.table.c.deleted == False ) \
.order_by( app.model.Category.table.c.name ) \
.all()
+
def get_category( app, id ):
"""Get a category from the database."""
sa_session = app.model.context.current
return sa_session.query( app.model.Category ).get( app.security.decode_id( id ) )
+
def get_category_by_name( app, name ):
"""Get a category from the database via name."""
sa_session = app.model.context.current
@@ -228,6 +238,7 @@
except sqlalchemy.orm.exc.NoResultFound:
return None
+
def get_ctx_rev( app, tool_shed_url, name, owner, changeset_revision ):
"""
Send a request to the tool shed to retrieve the ctx_rev for a repository defined by the
@@ -240,6 +251,7 @@
ctx_rev = common_util.tool_shed_get( app, tool_shed_url, url )
return ctx_rev
+
def get_current_repository_metadata_for_changeset_revision( app, repository, changeset_revision ):
encoded_repository_id = app.security.encode_id( repository.id )
repository_metadata = get_repository_metadata_by_changeset_revision( app,
@@ -261,6 +273,7 @@
return repository_metadata
return None
+
def get_ids_of_tool_shed_repositories_being_installed( app, as_string=False ):
installing_repository_ids = []
new_status = app.install_model.ToolShedRepository.installation_status.NEW
@@ -280,6 +293,7 @@
return ','.join( installing_repository_ids )
return installing_repository_ids
+
def get_latest_downloadable_changeset_revision( app, repository, repo ):
repository_tip = repository.tip( app )
repository_metadata = get_repository_metadata_by_changeset_revision( app, app.security.encode_id( repository.id ), repository_tip )
@@ -290,6 +304,7 @@
return changeset_revisions[ -1 ]
return hg_util.INITIAL_CHANGELOG_HASH
+
def get_next_downloadable_changeset_revision( repository, repo, after_changeset_revision ):
"""
Return the installable changeset_revision in the repository changelog after the changeset to which
@@ -311,6 +326,7 @@
found_after_changeset_revision = True
return None
+
def get_next_prior_import_or_install_required_dict_entry( prior_required_dict, processed_tsr_ids ):
"""
This method is used in the Tool Shed when exporting a repository and its dependencies, and in Galaxy
@@ -344,6 +360,7 @@
continue
return key
+
def get_ordered_metadata_changeset_revisions( repository, repo, downloadable=True ):
"""
Return an ordered list of changeset_revisions that are associated with metadata
@@ -366,6 +383,7 @@
sorted_changeset_revisions = [ str( changeset_tup[ 1 ] ) for changeset_tup in sorted_changeset_tups ]
return sorted_changeset_revisions
+
def get_prior_import_or_install_required_dict( app, tsr_ids, repo_info_dicts ):
"""
This method is used in the Tool Shed when exporting a repository and its dependencies,
@@ -390,6 +408,7 @@
prior_import_or_install_required_dict[ encoded_repository_id ] = prior_import_or_install_ids
return prior_import_or_install_required_dict
+
def get_repo_info_tuple_contents( repo_info_tuple ):
"""Take care in handling the repo_info_tuple as it evolves over time as new tool shed features are introduced."""
if len( repo_info_tuple ) == 6:
@@ -399,6 +418,7 @@
description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies = repo_info_tuple
return description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies
+
def get_repository_and_repository_dependencies_from_repo_info_dict( app, repo_info_dict ):
"""Return a tool_shed_repository or repository record defined by the information in the received repo_info_dict."""
repository_name = repo_info_dict.keys()[ 0 ]
@@ -414,6 +434,7 @@
repository = get_repository_by_name_and_owner( app, repository_name, repository_owner )
return repository, repository_dependencies
+
def get_repository_by_id( app, id ):
"""Get a repository from the database via id."""
if is_tool_shed_client( app ):
@@ -422,28 +443,31 @@
sa_session = app.model.context.current
return sa_session.query( app.model.Repository ).get( app.security.decode_id( id ) )
+
def get_repository_by_name( app, name ):
"""Get a repository from the database via name."""
repository_query = get_repository_query( app )
return repository_query.filter_by( name=name ).first()
+
def get_repository_by_name_and_owner( app, name, owner ):
"""Get a repository from the database via name and owner"""
repository_query = get_repository_query( app )
if is_tool_shed_client( app ):
return repository_query \
- .filter( and_( app.install_model.ToolShedRepository.table.c.name == name,
- app.install_model.ToolShedRepository.table.c.owner == owner ) ) \
- .first()
+ .filter( and_( app.install_model.ToolShedRepository.table.c.name == name,
+ app.install_model.ToolShedRepository.table.c.owner == owner ) ) \
+ .first()
# We're in the tool shed.
user = get_user_by_username( app, owner )
if user:
return repository_query \
- .filter( and_( app.model.Repository.table.c.name == name,
- app.model.Repository.table.c.user_id == user.id ) ) \
- .first()
+ .filter( and_( app.model.Repository.table.c.name == name,
+ app.model.Repository.table.c.user_id == user.id ) ) \
+ .first()
return None
+
def get_repository_dependency_types( repository_dependencies ):
"""
Inspect the received list of repository_dependencies tuples and return boolean values
@@ -470,6 +494,7 @@
break
return has_repository_dependencies, has_repository_dependencies_only_if_compiling_contained_td
+
def get_repository_for_dependency_relationship( app, tool_shed, name, owner, changeset_revision ):
"""
Return an installed tool_shed_repository database record that is defined by either the current changeset
@@ -509,6 +534,7 @@
changeset_revision=text )
return repository
+
def get_repository_file_contents( file_path ):
"""Return the display-safe contents of a repository file for display in a browser."""
if checkers.is_gzip( file_path ):
@@ -543,6 +569,7 @@
beginning_on_size_error=True )
return safe_str
+
def get_repository_files( folder_path ):
"""Return the file hierarchy of a tool shed repository."""
contents = []
@@ -558,6 +585,7 @@
contents.sort()
return contents
+
def get_repository_from_refresh_on_change( app, **kwd ):
# The changeset_revision_select_field in several grids performs a refresh_on_change which sends in request parameters like
# changeset_revison_1, changeset_revision_2, etc. One of the many select fields on the grid performed the refresh_on_change,
@@ -575,6 +603,7 @@
# This should never be reached - raise an exception?
return v, None
+
def get_repository_ids_requiring_prior_import_or_install( app, tsr_ids, repository_dependencies ):
"""
This method is used in the Tool Shed when exporting a repository and its dependencies,
@@ -593,11 +622,11 @@
continue
for rd_tup in rd_tups:
tool_shed, \
- name, \
- owner, \
- changeset_revision, \
- prior_installation_required, \
- only_if_compiling_contained_td = \
+ name, \
+ owner, \
+ changeset_revision, \
+ prior_installation_required, \
+ only_if_compiling_contained_td = \
common_util.parse_repository_dependency_tuple( rd_tup )
# If only_if_compiling_contained_td is False, then the repository dependency
# is not required to be installed prior to the dependent repository even if
@@ -626,11 +655,13 @@
prior_tsr_ids.append( encoded_repository_id )
return prior_tsr_ids
+
def get_repository_in_tool_shed( app, id ):
"""Get a repository on the tool shed side from the database via id."""
sa_session = app.model.context.current
return sa_session.query( app.model.Repository ).get( app.security.decode_id( id ) )
+
def get_repository_metadata_by_changeset_revision( app, id, changeset_revision ):
"""Get metadata for a specified repository change set from the database."""
# Make sure there are no duplicate records, and return the single unique record for the changeset_revision.
@@ -652,6 +683,7 @@
return all_metadata_records[ 0 ]
return None
+
def get_repository_owner( cleaned_repository_url ):
"""Gvien a "cleaned" repository clone URL, return the owner of the repository."""
items = cleaned_repository_url.split( '/repos/' )
@@ -660,12 +692,13 @@
repo_path = repo_path.replace( '/', '', 1 )
return repo_path.lstrip( '/' ).split( '/' )[ 0 ]
+
def get_repository_owner_from_clone_url( repository_clone_url ):
"""Given a repository clone URL, return the owner of the repository."""
tmp_url = common_util.remove_protocol_and_user_from_clone_url( repository_clone_url )
- tool_shed = tmp_url.split( '/repos/' )[ 0 ].rstrip( '/' )
return get_repository_owner( tmp_url )
+
def get_repository_query( app ):
if is_tool_shed_client( app ):
query = app.install_model.context.query( app.install_model.ToolShedRepository )
@@ -673,6 +706,7 @@
query = app.model.context.query( app.model.Repository )
return query
+
def get_tool_panel_config_tool_path_install_dir( app, repository ):
"""
Return shed-related tool panel config, the tool_path configured in it, and the relative path to
@@ -690,12 +724,13 @@
# Just pick a semi-random shed config.
for shed_config_dict in app.toolbox.shed_tool_confs:
if ( repository.dist_to_shed and shed_config_dict[ 'config_filename' ] == app.config.migrated_tools_config ) \
- or ( not repository.dist_to_shed and shed_config_dict[ 'config_filename' ] != app.config.migrated_tools_config ):
+ or ( not repository.dist_to_shed and shed_config_dict[ 'config_filename' ] != app.config.migrated_tools_config ):
break
shed_tool_conf = shed_config_dict[ 'config_filename' ]
tool_path = shed_config_dict[ 'tool_path' ]
return shed_tool_conf, tool_path, relative_install_dir
+
def get_tool_path_by_shed_tool_conf_filename( app, shed_tool_conf ):
"""
Return the tool_path config setting for the received shed_tool_conf file by searching the tool box's in-memory list of shed_tool_confs for the
@@ -711,10 +746,12 @@
return shed_tool_conf_dict[ 'tool_path' ]
return None
+
def get_tool_shed_from_clone_url( repository_clone_url ):
tmp_url = common_util.remove_protocol_and_user_from_clone_url( repository_clone_url )
return tmp_url.split( '/repos/' )[ 0 ].rstrip( '/' )
+
def get_tool_shed_repository_by_id( app, repository_id ):
"""Return a tool shed repository database record defined by the id."""
# This method is used only in Galaxy, not the tool shed.
@@ -722,6 +759,7 @@
.filter( app.install_model.ToolShedRepository.table.c.id == app.security.decode_id( repository_id ) ) \
.first()
+
def get_tool_shed_repository_by_shed_name_owner_changeset_revision( app, tool_shed, name, owner, changeset_revision ):
"""
Return a tool shed repository database record defined by the combination of a tool_shed, repository name,
@@ -733,11 +771,12 @@
tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed )
return repository_query \
.filter( and_( app.install_model.ToolShedRepository.table.c.tool_shed == tool_shed,
- app.install_model.ToolShedRepository.table.c.name == name,
- app.install_model.ToolShedRepository.table.c.owner == owner,
- app.install_model.ToolShedRepository.table.c.changeset_revision == changeset_revision ) ) \
+ app.install_model.ToolShedRepository.table.c.name == name,
+ app.install_model.ToolShedRepository.table.c.owner == owner,
+ app.install_model.ToolShedRepository.table.c.changeset_revision == changeset_revision ) ) \
.first()
+
def get_tool_shed_repository_by_shed_name_owner_installed_changeset_revision( app, tool_shed, name, owner,
installed_changeset_revision ):
"""
@@ -750,11 +789,12 @@
tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed )
return repository_query \
.filter( and_( app.install_model.ToolShedRepository.table.c.tool_shed == tool_shed,
- app.install_model.ToolShedRepository.table.c.name == name,
- app.install_model.ToolShedRepository.table.c.owner == owner,
- app.install_model.ToolShedRepository.table.c.installed_changeset_revision == installed_changeset_revision ) ) \
+ app.install_model.ToolShedRepository.table.c.name == name,
+ app.install_model.ToolShedRepository.table.c.owner == owner,
+ app.install_model.ToolShedRepository.table.c.installed_changeset_revision == installed_changeset_revision ) ) \
.first()
+
def get_tool_shed_status_for_installed_repository( app, repository ):
"""
Send a request to the tool shed to retrieve information about newer installable repository revisions,
@@ -775,8 +815,8 @@
except HTTPError, e:
# This should handle backward compatility to the Galaxy 12/20/12 release. We used to only handle updates for an installed revision
# using a boolean value.
- log.debug( "Error attempting to get tool shed status for installed repository %s: %s\nAttempting older 'check_for_updates' method.\n" % \
- ( str( repository.name ), str( e ) ) )
+ log.debug( "Error attempting to get tool shed status for installed repository %s: %s\nAttempting older 'check_for_updates' method.\n" %
+ ( str( repository.name ), str( e ) ) )
params = '?name=%s&owner=%s&changeset_revision=%s&from_update_manager=True' % ( str( repository.name ),
str( repository.owner ),
str( repository.changeset_revision ) )
@@ -793,6 +833,7 @@
log.exception( "Error attempting to get tool shed status for installed repository %s: %s" % ( str( repository.name ), str( e ) ) )
return {}
+
def get_tool_shed_repository_status_label( app, tool_shed_repository=None, name=None, owner=None, changeset_revision=None, repository_clone_url=None ):
"""Return a color-coded label for the status of the received tool-shed_repository installed into Galaxy."""
if tool_shed_repository is None:
@@ -842,6 +883,7 @@
status_label = 'unknown status'
return '<div class="count-box state-color-%s">%s</div>' % ( bgcolor, status_label )
+
def get_updated_changeset_revisions( app, name, owner, changeset_revision ):
"""
Return a string of comma-separated changeset revision hashes for all available updates to the received changeset
@@ -863,6 +905,7 @@
return changeset_hashes_str
return ''
+
def get_updated_changeset_revisions_from_tool_shed( app, tool_shed_url, name, owner, changeset_revision ):
"""
Get all appropriate newer changeset revisions for the repository defined by
@@ -880,11 +923,13 @@
text = common_util.tool_shed_get( app, tool_shed_url, url )
return text
+
def get_user( app, id ):
"""Get a user from the database by id."""
sa_session = app.model.context.current
return sa_session.query( app.model.User ).get( app.security.decode_id( id ) )
+
def get_user_by_username( app, username ):
"""Get a user from the database by username."""
sa_session = app.model.context.current
@@ -893,9 +938,10 @@
.filter( app.model.User.table.c.username == username ) \
.one()
return user
- except Exception, e:
+ except Exception:
return None
+
def handle_email_alerts( app, host, repository, content_alert_str='', new_repo_alert=False, admin_only=False ):
"""
There are 2 complementary features that enable a tool shed user to receive email notification:
@@ -947,7 +993,7 @@
admin_body = string.Template( template ).safe_substitute( host=host,
sharable_link=sharable_link,
repository_name=repository.name,
- revision='%s:%s' %( str( ctx.rev() ), ctx ),
+ revision='%s:%s' % ( str( ctx.rev() ), ctx ),
display_date=display_date,
description=ctx.description(),
username=username,
@@ -955,7 +1001,7 @@
body = string.Template( template ).safe_substitute( host=host,
sharable_link=sharable_link,
repository_name=repository.name,
- revision='%s:%s' %( str( ctx.rev() ), ctx ),
+ revision='%s:%s' % ( str( ctx.rev() ), ctx ),
display_date=display_date,
description=ctx.description(),
username=username,
@@ -985,9 +1031,10 @@
util.send_mail( frm, to, subject, admin_body, app.config )
else:
util.send_mail( frm, to, subject, body, app.config )
- except Exception, e:
+ except Exception:
log.exception( "An error occurred sending a tool shed repository update alert by email." )
+
def have_shed_tool_conf_for_install( app ):
if not app.toolbox.shed_tool_confs:
return False
@@ -999,6 +1046,7 @@
return True
return False
+
def is_tool_shed_client( app ):
"""
The tool shed and clients to the tool (i.e. Galaxy) require a lot
@@ -1008,6 +1056,7 @@
"""
return hasattr( app, "install_model" )
+
def open_repository_files_folder( folder_path ):
"""
Return a list of dictionaries, each of which contains information for a file or directory contained
@@ -1026,14 +1075,15 @@
is_folder = True
if filename:
full_path = os.path.join( folder_path, filename )
- node = { "title" : filename,
- "isFolder" : is_folder,
- "isLazy" : is_folder,
- "tooltip" : full_path,
- "key" : full_path }
+ node = { "title": filename,
+ "isFolder": is_folder,
+ "isLazy": is_folder,
+ "tooltip": full_path,
+ "key": full_path }
folder_contents.append( node )
return folder_contents
+
def repository_was_previously_installed( app, tool_shed_url, repository_name, repo_info_tuple, from_tip=False ):
"""
Find out if a repository is already installed into Galaxy - there are several scenarios where this
@@ -1077,6 +1127,7 @@
return tool_shed_repository, previous_changeset_revision
return None, None
+
def set_image_paths( app, encoded_repository_id, text ):
"""
Handle tool help image display for tools that are contained in repositories in
@@ -1106,6 +1157,7 @@
text = re.sub( r'\.\. image:: (?!https?://)/?(.+)', r'.. image:: %s/\1' % route_to_images, text )
return text
+
def set_repository_attributes( app, repository, status, error_message, deleted, uninstalled, remove_from_disk=False ):
if remove_from_disk:
relative_install_dir = repository.repo_path( app )
@@ -1123,6 +1175,7 @@
app.install_model.context.add( repository )
app.install_model.context.flush()
+
def tool_shed_is_this_tool_shed( toolshed_base_url ):
"""Determine if a tool shed is the current tool shed."""
cleaned_toolshed_base_url = common_util.remove_protocol_from_tool_shed_url( toolshed_base_url )
diff -r 000cd07f16f991cb78025e23f0872bafd58b9daf -r 739ca42b855530e8293cbb25298e1d4f6ef03d15 lib/tool_shed/util/tool_util.py
--- a/lib/tool_shed/util/tool_util.py
+++ b/lib/tool_shed/util/tool_util.py
@@ -5,15 +5,14 @@
import galaxy.tools
from galaxy import util
from galaxy.datatypes import checkers
-from galaxy.tools import parameters
from galaxy.util.expressions import ExpressionContext
from galaxy.web.form_builder import SelectField
-from galaxy.tools.actions.upload import UploadToolAction
from tool_shed.util import basic_util
log = logging.getLogger( __name__ )
+
def build_shed_tool_conf_select_field( app ):
"""Build a SelectField whose options are the keys in app.toolbox.shed_tool_confs."""
options = []
@@ -30,6 +29,7 @@
select_field.add_option( option_tup[ 0 ], option_tup[ 1 ] )
return select_field
+
def build_tool_panel_section_select_field( app ):
"""Build a SelectField whose options are the sections of the current in-memory toolbox."""
options = []
@@ -41,6 +41,7 @@
select_field.add_option( option_tup[ 0 ], option_tup[ 1 ] )
return select_field
+
def copy_sample_file( app, filename, dest_path=None ):
"""
Copy xxx.sample to dest_path/xxx.sample and dest_path/xxx. The default value for dest_path
@@ -61,6 +62,7 @@
if not os.path.exists( os.path.join( dest_path, copied_file ) ):
shutil.copy( full_source_path, os.path.join( dest_path, copied_file ) )
+
def copy_sample_files( app, sample_files, tool_path=None, sample_files_copied=None, dest_path=None ):
"""
Copy all appropriate files to dest_path in the local Galaxy environment that have not
@@ -75,11 +77,12 @@
filename_sans_path = os.path.split( filename )[ 1 ]
if filename_sans_path not in filenames_not_to_copy and filename not in sample_files_copied:
if tool_path:
- filename=os.path.join( tool_path, filename )
+ filename = os.path.join( tool_path, filename )
# Attempt to ensure we're copying an appropriate file.
if is_data_index_sample_file( filename ):
copy_sample_file( app, filename, dest_path=dest_path )
+
def generate_message_for_invalid_tools( app, invalid_file_tups, repository, metadata_dict, as_html=True,
displaying_invalid_tool=False ):
if as_html:
@@ -124,6 +127,7 @@
message += "%s%s%s - %s%s" % ( bold_start, tool_file, bold_end, correction_msg, new_line )
return message
+
def get_headers( fname, sep, count=60, is_multi_byte=False ):
"""Returns a list with the first 'count' lines split by 'sep'."""
headers = []
@@ -137,6 +141,7 @@
break
return headers
+
def get_tool_path_install_dir( partial_install_dir, shed_tool_conf_dict, tool_dict, config_elems ):
for elem in config_elems:
if elem.tag == 'tool':
@@ -153,6 +158,7 @@
return tool_path, relative_install_dir
return None, None
+
def handle_missing_index_file( app, tool_path, sample_files, repository_tools_tups, sample_files_copied ):
"""
Inspect each tool to see if it has any input parameters that are dynamically
@@ -180,6 +186,7 @@
repository_tools_tups[ index ] = ( tup_path, guid, repository_tool )
return repository_tools_tups, sample_files_copied
+
def is_column_based( fname, sep='\t', skip=0, is_multi_byte=False ):
"""See if the file is column based with respect to a separator."""
headers = get_headers( fname, sep, is_multi_byte=is_multi_byte )
@@ -199,6 +206,7 @@
return False
return True
+
def is_data_index_sample_file( file_path ):
"""
Attempt to determine if a .sample file is appropriate for copying to ~/tool-data when
@@ -224,6 +232,7 @@
# Default to copying the file if none of the above are true.
return True
+
def new_state( trans, tool, invalid=False ):
"""Create a new `DefaultToolState` for the received tool. Only inputs on the first page will be initialized."""
state = galaxy.tools.DefaultToolState()
@@ -240,9 +249,10 @@
state.inputs[ input.name ] = []
return state
+
def panel_entry_per_tool( tool_section_dict ):
# Return True if tool_section_dict looks like this.
- # {<Tool guid> :
+ # {<Tool guid> :
# [{ tool_config : <tool_config_file>,
# id: <ToolSection id>,
# version : <ToolSection version>,
@@ -258,6 +268,7 @@
return True
return False
+
def reload_upload_tools( app ):
if hasattr( app, 'toolbox' ):
app.toolbox.handle_datatypes_changed()
https://bitbucket.org/galaxy/galaxy-central/commits/35d456f7edff/
Changeset: 35d456f7edff
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Method to abstract away ToolBox.shed_tool_confs from tool_util.py.
Start a gradual process of referring to these as dynamic tool confs instead of shed tool confs. I would like like to make them more generally Galaxy-managed tool configurations and distinguish them from deployer-managed configurations - rather then having overtly ToolShed-only logic in ToolBox.
Affected #: 2 files
diff -r 739ca42b855530e8293cbb25298e1d4f6ef03d15 -r 35d456f7edffef9a8e4cd825503c3782f2be3617 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -632,6 +632,16 @@
break
return tool_version_select_field, tools, tool
+ def dynamic_conf_filenames( self, include_migrated_tool_conf=False ):
+ """ Return list of dynamic tool configuration filenames (shed_tools).
+ These must be used with various dynamic tool configuration update
+ operations (e.g. with update_shed_config).
+ """
+ for dynamic_tool_conf_dict in self.shed_tool_confs:
+ dynamic_tool_conf_filename = dynamic_tool_conf_dict[ 'config_filename' ]
+ if include_migrated_tool_conf or (dynamic_tool_conf_filename != self.app.config.migrated_tools_config):
+ yield dynamic_tool_conf_filename
+
def build_tool_version_select_field( self, tools, tool_id, set_selected ):
"""Build a SelectField whose options are the ids for the received list of tools."""
options = []
diff -r 739ca42b855530e8293cbb25298e1d4f6ef03d15 -r 35d456f7edffef9a8e4cd825503c3782f2be3617 lib/tool_shed/util/tool_util.py
--- a/lib/tool_shed/util/tool_util.py
+++ b/lib/tool_shed/util/tool_util.py
@@ -16,14 +16,12 @@
def build_shed_tool_conf_select_field( app ):
"""Build a SelectField whose options are the keys in app.toolbox.shed_tool_confs."""
options = []
- for shed_tool_conf_dict in app.toolbox.shed_tool_confs:
- shed_tool_conf_filename = shed_tool_conf_dict[ 'config_filename' ]
- if shed_tool_conf_filename != app.config.migrated_tools_config:
- if shed_tool_conf_filename.startswith( './' ):
- option_label = shed_tool_conf_filename.replace( './', '', 1 )
- else:
- option_label = shed_tool_conf_filename
- options.append( ( option_label, shed_tool_conf_filename ) )
+ for dynamic_tool_conf_filename in app.toolbox.dynamic_conf_filenames():
+ if dynamic_tool_conf_filename.startswith( './' ):
+ option_label = dynamic_tool_conf_filename.replace( './', '', 1 )
+ else:
+ option_label = dynamic_tool_conf_filename
+ options.append( ( option_label, dynamic_tool_conf_filename ) )
select_field = SelectField( name='shed_tool_conf' )
for option_tup in options:
select_field.add_option( option_tup[ 0 ], option_tup[ 1 ] )
https://bitbucket.org/galaxy/galaxy-central/commits/83dd43611918/
Changeset: 83dd43611918
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Method to abstract away ToolBox.tool_panel from tool_util.py.
Now only thing accessing ToolBox.tool_panel outside ToolBox itself is ToolPanelManager.
Affected #: 2 files
diff -r 35d456f7edffef9a8e4cd825503c3782f2be3617 -r 83dd436119182a688824218b0efda74e55e045c9 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -1059,6 +1059,11 @@
status = 'done'
return message, status
+ def get_sections( self ):
+ for k, v in self.tool_panel.items():
+ if isinstance( v, ToolSection ):
+ yield (v.id, v.name)
+
def find_section_id( self, tool_panel_section_id ):
"""
Find the section ID referenced by the key or return '' indicating
diff -r 35d456f7edffef9a8e4cd825503c3782f2be3617 -r 83dd436119182a688824218b0efda74e55e045c9 lib/tool_shed/util/tool_util.py
--- a/lib/tool_shed/util/tool_util.py
+++ b/lib/tool_shed/util/tool_util.py
@@ -31,9 +31,8 @@
def build_tool_panel_section_select_field( app ):
"""Build a SelectField whose options are the sections of the current in-memory toolbox."""
options = []
- for k, v in app.toolbox.tool_panel.items():
- if isinstance( v, galaxy.tools.ToolSection ):
- options.append( ( v.name, v.id ) )
+ for section_id, section_name in app.toolbox.get_sections():
+ options.append( ( section_name, section_id ) )
select_field = SelectField( name='tool_panel_section_id', display='radio' )
for option_tup in options:
select_field.add_option( option_tup[ 0 ], option_tup[ 1 ] )
https://bitbucket.org/galaxy/galaxy-central/commits/6021c963ec92/
Changeset: 6021c963ec92
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Reuse new ToolBox.get_section method in ToolPanelManager.
This is a higher-level method and eliminates a couple more places where Tool Shed code is directly acceessing ToolBox.tool_panel.
Affected #: 1 file
diff -r 83dd436119182a688824218b0efda74e55e045c9 -r 6021c963ec925698353b134d070b403d2309609f 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
@@ -325,8 +325,7 @@
tool_panel_section_id=section_id,
new_tool_panel_section_label=new_tool_panel_section_label )
elif tool_panel_section_id:
- tool_panel_section_key = str( tool_panel_section_id )
- tool_section = toolbox.tool_panel[ tool_panel_section_key ]
+ tool_panel_section_key, tool_section = toolbox.get_section( tool_panel_section_id)
else:
return None, None
return tool_panel_section_key, tool_section
@@ -495,8 +494,8 @@
# Remove the tool sub-element from the section element.
config_elem.remove( tool_elem )
# Remove the tool from the section in the in-memory tool panel.
- if section_key in toolbox.tool_panel:
- tool_section = toolbox.tool_panel[ section_key ]
+ _, tool_section = toolbox.get_section( section_key )
+ if tool_section:
remove_from_panel( tool_elem, tool_section.elems, toolbox.integrated_tool_panel.get( section_key, {} ), section_key=section_key )
if len( config_elem ) < 1:
# Keep a list of all empty section elements so they can be removed.
https://bitbucket.org/galaxy/galaxy-central/commits/482b027099f5/
Changeset: 482b027099f5
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Refactor logic for removing tools from panels into ToolBox.
May seem sort of like Tool Shed specific stuff - but I think it can be reused elsewhere down the road. Regardless of this however as of this commit no external components directly access ToolBox.tool_panel or ToolBox.integrated_tool_panel - which I think is important - these should be internal details of the ToolBox (or newer modules it leverages).
Affected #: 2 files
diff -r 6021c963ec925698353b134d070b403d2309609f -r 482b027099f5aa0e15de928d093c6347a5297e18 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -658,6 +658,55 @@
select_field.add_option( 'version %s' % option_tup[ 0 ], option_tup[ 1 ] )
return select_field
+ def remove_from_panel( self, tool_id, section_key='', remove_from_config=True ):
+
+ def remove_from_dict( has_elems, integrated_has_elems ):
+ tool_key = 'tool_%s' % str( tool_id )
+ available_tool_versions = self.get_loaded_tools_by_lineage( tool_id )
+ if tool_key in has_elems:
+ if available_tool_versions:
+ available_tool_versions.reverse()
+ replacement_tool_key = None
+ replacement_tool_version = None
+ # Since we are going to remove the tool from the section, replace it with
+ # the newest loaded version of the tool.
+ for available_tool_version in available_tool_versions:
+ available_tool_section_id, available_tool_section_name = available_tool_version.get_panel_section()
+ # I suspect "available_tool_version.id in has_elems.keys()" doesn't
+ # belong in the following line or at least I don't understand what
+ # purpose it might serve. -John
+ if available_tool_version.id in has_elems.keys() or (available_tool_section_id == section_key):
+ replacement_tool_key = 'tool_%s' % str( available_tool_version.id )
+ replacement_tool_version = available_tool_version
+ break
+ if replacement_tool_key and replacement_tool_version:
+ # Get the index of the tool_key in the tool_section.
+ for tool_panel_index, key in enumerate( has_elems.keys() ):
+ if key == tool_key:
+ break
+ # Remove the tool from the tool panel.
+ del has_elems[ tool_key ]
+ # Add the replacement tool at the same location in the tool panel.
+ has_elems.insert( tool_panel_index,
+ replacement_tool_key,
+ replacement_tool_version )
+ else:
+ del has_elems[ tool_key ]
+ else:
+ del has_elems[ tool_key ]
+ if remove_from_config:
+ if hasattr( integrated_has_elems, "elems" ):
+ integrated_has_elems = integrated_has_elems.elems
+ if tool_key in integrated_has_elems:
+ del integrated_has_elems[ tool_key ]
+
+ if section_key:
+ _, tool_section = self.get_section( section_key )
+ if tool_section:
+ remove_from_dict( tool_section.elems, self.integrated_tool_panel.get( section_key, {} ) )
+ else:
+ remove_from_dict( self.tool_panel, self.integrated_tool_panel )
+
def load_tool_tag_set( self, elem, panel_dict, integrated_panel_dict, tool_path, load_panel_dict, guid=None, index=None ):
try:
path = elem.get( "file" )
diff -r 6021c963ec925698353b134d070b403d2309609f -r 482b027099f5aa0e15de928d093c6347a5297e18 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
@@ -426,50 +426,6 @@
def remove_guids( self, guids_to_remove, shed_tool_conf, uninstall ):
toolbox = self.app.toolbox
-
- def remove_from_panel( tool_elem, has_elems, integrated_has_elems, section_key='' ):
- # Hide tool from panel and promote next oldest version if
- # available.
- guid = tool_elem.get( 'guid' )
- tool_key = 'tool_%s' % str( guid )
- available_tool_versions = toolbox.get_loaded_tools_by_lineage( guid )
- if tool_key in has_elems:
- if available_tool_versions:
- available_tool_versions.reverse()
- replacement_tool_key = None
- replacement_tool_version = None
- # Since we are going to remove the tool from the section, replace it with
- # the newest loaded version of the tool.
- for available_tool_version in available_tool_versions:
- available_tool_section_id, available_tool_section_name = available_tool_version.get_panel_section()
- # I suspect "available_tool_version.id in has_elems.keys()" doesn't
- # belong in the following line or at least I don't understand what
- # purpose it might serve. -John
- if available_tool_version.id in has_elems.keys() or (available_tool_section_id == section_key):
- replacement_tool_key = 'tool_%s' % str( available_tool_version.id )
- replacement_tool_version = available_tool_version
- break
- if replacement_tool_key and replacement_tool_version:
- # Get the index of the tool_key in the tool_section.
- for tool_panel_index, key in enumerate( has_elems.keys() ):
- if key == tool_key:
- break
- # Remove the tool from the tool panel.
- del has_elems[ tool_key ]
- # Add the replacement tool at the same location in the tool panel.
- has_elems.insert( tool_panel_index,
- replacement_tool_key,
- replacement_tool_version )
- else:
- del has_elems[ tool_key ]
- else:
- del has_elems[ tool_key ]
- if uninstall:
- if hasattr( integrated_has_elems, "elems" ):
- integrated_has_elems = integrated_has_elems.elems
- if tool_key in integrated_has_elems:
- del integrated_has_elems[ tool_key ]
-
# Remove the tools from the toolbox's tools_by_id dictionary.
for guid_to_remove in guids_to_remove:
# remove_from_tool_panel to false, will handling that logic below.
@@ -494,17 +450,14 @@
# Remove the tool sub-element from the section element.
config_elem.remove( tool_elem )
# Remove the tool from the section in the in-memory tool panel.
- _, tool_section = toolbox.get_section( section_key )
- if tool_section:
- remove_from_panel( tool_elem, tool_section.elems, toolbox.integrated_tool_panel.get( section_key, {} ), section_key=section_key )
+ toolbox.remove_from_panel( tool_elem.get( "guid" ), section_key=section_key, remove_from_config=uninstall )
if len( config_elem ) < 1:
# Keep a list of all empty section elements so they can be removed.
config_elems_to_remove.append( config_elem )
elif config_elem.tag == 'tool':
guid = config_elem.get( 'guid' )
if guid in guids_to_remove:
- # get_panel_section return '' for un-sectioned tools.
- remove_from_panel( config_elem, toolbox.tool_panel, toolbox.integrated_tool_panel, section_key='' )
+ toolbox.remove_from_panel( guid, section_key='', remove_from_config=uninstall )
config_elems_to_remove.append( config_elem )
for config_elem in config_elems_to_remove:
# Remove the element from the in-memory list of elements.
https://bitbucket.org/galaxy/galaxy-central/commits/600d39d9bbac/
Changeset: 600d39d9bbac
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Update calls to ToolPanelManager.get_shed_tool_conf_dict for clarity...
... in other words to note where index in the resulting tuple is not actually used. Doing this to enable hiding this implementation detail (index) from components in subsequent commits.
Affected #: 3 files
diff -r 482b027099f5aa0e15de928d093c6347a5297e18 -r 600d39d9bbac52eb4321e65d16d1740a3f7c0871 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
@@ -730,7 +730,7 @@
shed_tool_conf = install_options.get( 'shed_tool_conf', None )
if shed_tool_conf:
# Get the tool_path setting.
- index, shed_conf_dict = self.tpm.get_shed_tool_conf_dict( shed_tool_conf )
+ _, shed_conf_dict = self.tpm.get_shed_tool_conf_dict( shed_tool_conf )
tool_path = shed_conf_dict[ 'tool_path' ]
else:
# Pick a semi-random shed-related tool panel configuration file and get the tool_path setting.
diff -r 482b027099f5aa0e15de928d093c6347a5297e18 -r 600d39d9bbac52eb4321e65d16d1740a3f7c0871 lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py
--- a/lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py
+++ b/lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py
@@ -66,7 +66,7 @@
in the received tool shed repository metadata.
"""
repository_tools_tups = []
- index, shed_conf_dict = self.tpm.get_shed_tool_conf_dict( self.metadata_dict.get( 'shed_config_filename' ) )
+ _, shed_conf_dict = self.tpm.get_shed_tool_conf_dict( self.metadata_dict.get( 'shed_config_filename' ) )
if 'tools' in self.metadata_dict:
for tool_dict in self.metadata_dict[ 'tools' ]:
load_relative_path = relative_path = tool_dict.get( 'tool_config', None )
diff -r 482b027099f5aa0e15de928d093c6347a5297e18 -r 600d39d9bbac52eb4321e65d16d1740a3f7c0871 lib/tool_shed/galaxy_install/tool_migration_manager.py
--- a/lib/tool_shed/galaxy_install/tool_migration_manager.py
+++ b/lib/tool_shed/galaxy_install/tool_migration_manager.py
@@ -78,7 +78,7 @@
self.tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( self.app, defined_tool_shed_url )
self.tool_shed = common_util.remove_protocol_and_port_from_tool_shed_url( self.tool_shed_url )
self.repository_owner = common_util.REPOSITORY_OWNER
- index, self.shed_config_dict = self.tpm.get_shed_tool_conf_dict( self.migrated_tools_config )
+ _, self.shed_config_dict = self.tpm.get_shed_tool_conf_dict( self.migrated_tools_config )
# Since tool migration scripts can be executed any number of times, we need to
# make sure the appropriate tools are defined in tool_conf.xml. If no tools
# associated with the migration stage are defined, no repositories will be installed
https://bitbucket.org/galaxy/galaxy-central/commits/7cee92f360c0/
Changeset: 7cee92f360c0
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Update ToolBox.update_shed_config to use config_filename instead of index.
Seems a more robust index, simplifies ToolPanelManager, etc....
Affected #: 2 files
diff -r 600d39d9bbac52eb4321e65d16d1740a3f7c0871 -r 7cee92f360c0ca15d0f3f443c2e80a629d5eab1b lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -265,13 +265,15 @@
return shed_config_dict
return default
- def update_shed_config( self, shed_conf_index, shed_conf, integrated_panel_changes=True ):
+ def update_shed_config( self, 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
+ for index, my_shed_tool_conf in enumerate( self.shed_tool_confs ):
+ if shed_conf['config_filename'] == my_shed_tool_conf['config_filename']:
+ self.shed_tool_confs[ 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()
diff -r 600d39d9bbac52eb4321e65d16d1740a3f7c0871 -r 7cee92f360c0ca15d0f3f443c2e80a629d5eab1b 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
@@ -40,7 +40,7 @@
shed_tool_conf, tool_panel_dict, new_install=True ):
"""A tool shed repository is being installed or updated so handle tool panel alterations accordingly."""
# We need to change the in-memory version and the file system version of the shed_tool_conf file.
- index, shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
+ _, shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
tool_path = shed_tool_conf_dict[ 'tool_path' ]
# Generate the list of ElementTree Element objects for each section or tool.
elem_list = self.generate_tool_panel_elem_list( repository_name,
@@ -66,7 +66,7 @@
)
# 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.update_shed_config( index, shed_tool_conf_dict )
+ self.app.toolbox.update_shed_config( shed_tool_conf_dict )
def config_elems_to_xml_file( self, config_elems, config_filename, tool_path ):
"""
@@ -430,7 +430,7 @@
for guid_to_remove in guids_to_remove:
# remove_from_tool_panel to false, will handling that logic below.
toolbox.remove_tool_by_id( guid_to_remove, remove_from_panel=False )
- index, shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
+ _, shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
if uninstall:
# Remove from the shed_tool_conf file on disk.
self.remove_from_shed_tool_config( shed_tool_conf_dict, guids_to_remove )
@@ -464,4 +464,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
- toolbox.update_shed_config( index, shed_tool_conf_dict, integrated_panel_changes=uninstall )
+ toolbox.update_shed_config( shed_tool_conf_dict, integrated_panel_changes=uninstall )
https://bitbucket.org/galaxy/galaxy-central/commits/22db1ba32b58/
Changeset: 22db1ba32b58
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Simplifications for ToolPanelManager.get_shed_tool_conf_dict.
None of the components using this method are using the index any more - so eliminate it. Also introduce a new ToolBox method to hide the details of ToolBox.shed_tool_confs from this method.
Affected #: 6 files
diff -r 7cee92f360c0ca15d0f3f443c2e80a629d5eab1b -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -634,15 +634,21 @@
break
return tool_version_select_field, tools, tool
+ def dynamic_confs( self, include_migrated_tool_conf=False ):
+ confs = []
+ for dynamic_tool_conf_dict in self.shed_tool_confs:
+ dynamic_tool_conf_filename = dynamic_tool_conf_dict[ 'config_filename' ]
+ if include_migrated_tool_conf or (dynamic_tool_conf_filename != self.app.config.migrated_tools_config):
+ confs.append( dynamic_tool_conf_dict )
+ return confs
+
def dynamic_conf_filenames( self, include_migrated_tool_conf=False ):
""" Return list of dynamic tool configuration filenames (shed_tools).
These must be used with various dynamic tool configuration update
operations (e.g. with update_shed_config).
"""
- for dynamic_tool_conf_dict in self.shed_tool_confs:
- dynamic_tool_conf_filename = dynamic_tool_conf_dict[ 'config_filename' ]
- if include_migrated_tool_conf or (dynamic_tool_conf_filename != self.app.config.migrated_tools_config):
- yield dynamic_tool_conf_filename
+ for dynamic_tool_conf_dict in self.dynamic_confs( include_migrated_tool_conf=include_migrated_tool_conf ):
+ yield dynamic_tool_conf_dict[ 'config_filename' ]
def build_tool_version_select_field( self, tools, tool_id, set_selected ):
"""Build a SelectField whose options are the ids for the received list of tools."""
diff -r 7cee92f360c0ca15d0f3f443c2e80a629d5eab1b -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf 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
@@ -730,7 +730,7 @@
shed_tool_conf = install_options.get( 'shed_tool_conf', None )
if shed_tool_conf:
# Get the tool_path setting.
- _, shed_conf_dict = self.tpm.get_shed_tool_conf_dict( shed_tool_conf )
+ shed_conf_dict = self.tpm.get_shed_tool_conf_dict( shed_tool_conf )
tool_path = shed_conf_dict[ 'tool_path' ]
else:
# Pick a semi-random shed-related tool panel configuration file and get the tool_path setting.
diff -r 7cee92f360c0ca15d0f3f443c2e80a629d5eab1b -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py
--- a/lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py
+++ b/lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py
@@ -66,7 +66,7 @@
in the received tool shed repository metadata.
"""
repository_tools_tups = []
- _, shed_conf_dict = self.tpm.get_shed_tool_conf_dict( self.metadata_dict.get( 'shed_config_filename' ) )
+ shed_conf_dict = self.tpm.get_shed_tool_conf_dict( self.metadata_dict.get( 'shed_config_filename' ) )
if 'tools' in self.metadata_dict:
for tool_dict in self.metadata_dict[ 'tools' ]:
load_relative_path = relative_path = tool_dict.get( 'tool_config', None )
diff -r 7cee92f360c0ca15d0f3f443c2e80a629d5eab1b -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf lib/tool_shed/galaxy_install/tool_migration_manager.py
--- a/lib/tool_shed/galaxy_install/tool_migration_manager.py
+++ b/lib/tool_shed/galaxy_install/tool_migration_manager.py
@@ -78,7 +78,7 @@
self.tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( self.app, defined_tool_shed_url )
self.tool_shed = common_util.remove_protocol_and_port_from_tool_shed_url( self.tool_shed_url )
self.repository_owner = common_util.REPOSITORY_OWNER
- _, self.shed_config_dict = self.tpm.get_shed_tool_conf_dict( self.migrated_tools_config )
+ self.shed_config_dict = self.tpm.get_shed_tool_conf_dict( self.migrated_tools_config )
# Since tool migration scripts can be executed any number of times, we need to
# make sure the appropriate tools are defined in tool_conf.xml. If no tools
# associated with the migration stage are defined, no repositories will be installed
diff -r 7cee92f360c0ca15d0f3f443c2e80a629d5eab1b -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf 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
@@ -40,7 +40,7 @@
shed_tool_conf, tool_panel_dict, new_install=True ):
"""A tool shed repository is being installed or updated so handle tool panel alterations accordingly."""
# We need to change the in-memory version and the file system version of the shed_tool_conf file.
- _, shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
+ shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
tool_path = shed_tool_conf_dict[ 'tool_path' ]
# Generate the list of ElementTree Element objects for each section or tool.
elem_list = self.generate_tool_panel_elem_list( repository_name,
@@ -304,13 +304,13 @@
Return the in-memory version of the shed_tool_conf file, which is stored in
the config_elems entry in the shed_tool_conf_dict associated with the file.
"""
- for index, shed_tool_conf_dict in enumerate( self.app.toolbox.shed_tool_confs ):
+ for shed_tool_conf_dict in self.app.toolbox.dynamic_confs( include_migrated_tool_conf=True ):
if shed_tool_conf == shed_tool_conf_dict[ 'config_filename' ]:
- return index, shed_tool_conf_dict
+ return shed_tool_conf_dict
else:
file_name = basic_util.strip_path( shed_tool_conf_dict[ 'config_filename' ] )
if shed_tool_conf == file_name:
- return index, shed_tool_conf_dict
+ return shed_tool_conf_dict
def handle_tool_panel_section( self, toolbox, tool_panel_section_id=None, new_tool_panel_section_label=None ):
"""Return a ToolSection object retrieved from the current in-memory tool_panel."""
@@ -430,7 +430,7 @@
for guid_to_remove in guids_to_remove:
# remove_from_tool_panel to false, will handling that logic below.
toolbox.remove_tool_by_id( guid_to_remove, remove_from_panel=False )
- _, shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
+ shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
if uninstall:
# Remove from the shed_tool_conf file on disk.
self.remove_from_shed_tool_config( shed_tool_conf_dict, guids_to_remove )
diff -r 7cee92f360c0ca15d0f3f443c2e80a629d5eab1b -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf test/unit/tools_support.py
--- a/test/unit/tools_support.py
+++ b/test/unit/tools_support.py
@@ -100,6 +100,7 @@
admin_users="mary(a)example.com",
len_file_path=os.path.join( 'tool-data', 'shared', 'ucsc', 'chrom' ),
builds_file_path=os.path.join( 'tool-data', 'shared', 'ucsc', 'builds.txt.sample' ),
+ migrated_tools_config=os.path.join(test_directory, "migrated_tools_conf.xml"),
)
# Setup some attributes for downstream extension by specific tests.
https://bitbucket.org/galaxy/galaxy-central/commits/68255ebe3f54/
Changeset: 68255ebe3f54
User: jmchilton
Date: 2014-12-29 14:11:54+00:00
Summary: Reuse new ToolBox.dynamic_confs method other places...
... to shield ToolBox.shed_tool_confs from other components including Tool Shed install models, shed_util_common.py, and install_manager.py.
After this commit - shed_tool_confs is only accessed directly by the ToolBox itself.
Affected #: 3 files
diff -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf -r 68255ebe3f54500aa26db814c41f67f382731462 lib/galaxy/model/tool_shed_install/__init__.py
--- a/lib/galaxy/model/tool_shed_install/__init__.py
+++ b/lib/galaxy/model/tool_shed_install/__init__.py
@@ -99,7 +99,7 @@
if not self.shed_config_filename:
self.guess_shed_config( app, default=default )
if self.shed_config_filename:
- for shed_tool_conf_dict in app.toolbox.shed_tool_confs:
+ for shed_tool_conf_dict in app.toolbox.dynamic_confs( include_migrated_tool_conf=True ):
if self.shed_config_filename == shed_tool_conf_dict[ 'config_filename' ]:
return shed_tool_conf_dict
return default
@@ -118,7 +118,7 @@
metadata = self.metadata or {}
for tool in metadata.get( 'tools', [] ):
tool_ids.append( tool.get( 'guid' ) )
- for shed_tool_conf_dict in app.toolbox.shed_tool_confs:
+ for shed_tool_conf_dict in app.toolbox.dynamic_confs( include_migrated_tool_conf=True ):
name = shed_tool_conf_dict[ 'config_filename' ]
for elem in shed_tool_conf_dict[ 'config_elems' ]:
if elem.tag == 'tool':
@@ -137,7 +137,7 @@
if self.includes_datatypes:
# We need to search by file paths here, which is less desirable.
tool_shed = common_util.remove_protocol_and_port_from_tool_shed_url( self.tool_shed )
- for shed_tool_conf_dict in app.toolbox.shed_tool_confs:
+ for shed_tool_conf_dict in app.toolbox.dynamic_confs( include_migrated_tool_conf=True ):
tool_path = shed_tool_conf_dict[ 'tool_path' ]
relative_path = os.path.join( tool_path, tool_shed, 'repos', self.owner, self.name, self.installed_changeset_revision )
if os.path.exists( relative_path ):
@@ -284,7 +284,7 @@
def repo_path( self, app ):
tool_shed = common_util.remove_protocol_and_port_from_tool_shed_url( self.tool_shed )
- for index, shed_tool_conf_dict in enumerate( app.toolbox.shed_tool_confs ):
+ for shed_tool_conf_dict in app.toolbox.dynamic_confs( include_migrated_tool_conf=True ):
tool_path = shed_tool_conf_dict[ 'tool_path' ]
relative_path = os.path.join( tool_path, tool_shed, 'repos', self.owner, self.name, self.installed_changeset_revision )
if os.path.exists( relative_path ):
diff -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf -r 68255ebe3f54500aa26db814c41f67f382731462 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
@@ -733,15 +733,13 @@
shed_conf_dict = self.tpm.get_shed_tool_conf_dict( shed_tool_conf )
tool_path = shed_conf_dict[ 'tool_path' ]
else:
- # Pick a semi-random shed-related tool panel configuration file and get the tool_path setting.
- for shed_config_dict in self.app.toolbox.shed_tool_confs:
- # Don't use migrated_tools_conf.xml.
- if shed_config_dict[ 'config_filename' ] != self.app.config.migrated_tools_config:
- break
+ # Don't use migrated_tools_conf.xml.
+ try:
+ shed_config_dict = self.app.toolbox.dynamic_confs( include_migrated_tool_conf=False )[ 0 ]
+ except IndexError:
+ raise exceptions.RequestParameterMissingException( "Missing required parameter 'shed_tool_conf'." )
shed_tool_conf = shed_config_dict[ 'config_filename' ]
tool_path = shed_config_dict[ 'tool_path' ]
- if not shed_tool_conf:
- raise exceptions.RequestParameterMissingException( "Missing required parameter 'shed_tool_conf'." )
tool_panel_section_id = self.app.toolbox.find_section_id( install_options.get( 'tool_panel_section_id', '' ) )
# Build the dictionary of information necessary for creating tool_shed_repository database records
# for each repository being installed.
diff -r 22db1ba32b58093b68662db3f9f7f513e20c2bdf -r 68255ebe3f54500aa26db814c41f67f382731462 lib/tool_shed/util/shed_util_common.py
--- a/lib/tool_shed/util/shed_util_common.py
+++ b/lib/tool_shed/util/shed_util_common.py
@@ -722,7 +722,7 @@
shed_config_dict = repository.get_shed_config_dict( app )
if not shed_config_dict:
# Just pick a semi-random shed config.
- for shed_config_dict in app.toolbox.shed_tool_confs:
+ for shed_config_dict in app.toolbox.dynamic_confs( include_migrated_tool_conf=True ):
if ( repository.dist_to_shed and shed_config_dict[ 'config_filename' ] == app.config.migrated_tools_config ) \
or ( not repository.dist_to_shed and shed_config_dict[ 'config_filename' ] != app.config.migrated_tools_config ):
break
@@ -736,7 +736,7 @@
Return the tool_path config setting for the received shed_tool_conf file by searching the tool box's in-memory list of shed_tool_confs for the
dictionary whose config_filename key has a value matching the received shed_tool_conf.
"""
- for shed_tool_conf_dict in app.toolbox.shed_tool_confs:
+ for shed_tool_conf_dict in app.toolbox.dynamic_confs( include_migrated_tool_conf=True ):
config_filename = shed_tool_conf_dict[ 'config_filename' ]
if config_filename == shed_tool_conf:
return shed_tool_conf_dict[ 'tool_path' ]
@@ -1036,15 +1036,7 @@
def have_shed_tool_conf_for_install( app ):
- if not app.toolbox.shed_tool_confs:
- return False
- migrated_tools_conf_path, migrated_tools_conf_name = os.path.split( app.config.migrated_tools_config )
- for shed_tool_conf_dict in app.toolbox.shed_tool_confs:
- shed_tool_conf = shed_tool_conf_dict[ 'config_filename' ]
- shed_tool_conf_path, shed_tool_conf_name = os.path.split( shed_tool_conf )
- if shed_tool_conf_name != migrated_tools_conf_name:
- return True
- return False
+ return bool( app.toolbox.dynamic_confs( include_migrated_tool_conf=False ) )
def is_tool_shed_client( app ):
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.
1
0
commit/galaxy-central: jmchilton: Bugfix for 44dfa6f and typos in unit tests that caused it to go undetected.
by commits-noreply@bitbucket.org 29 Dec '14
by commits-noreply@bitbucket.org 29 Dec '14
29 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/bfd679408c84/
Changeset: bfd679408c84
User: jmchilton
Date: 2014-12-29 04:25:56+00:00
Summary: Bugfix for 44dfa6f and typos in unit tests that caused it to go undetected.
Affected #: 3 files
diff -r 1912dec92b728b974094456be8eb6d84d34a7ca6 -r bfd679408c84a4c6f1d2b1a09eec1dab9c2d212b 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
@@ -475,8 +475,10 @@
else:
del has_elems[ tool_key ]
if uninstall:
- if tool_key in toolbox.integrated_tool_panel:
- del toolbox.integrated_tool_panel[ tool_key ]
+ if hasattr( integrated_has_elems, "elems" ):
+ integrated_has_elems = integrated_has_elems.elems
+ if tool_key in integrated_has_elems:
+ del integrated_has_elems[ tool_key ]
# Remove the tools from the toolbox's tools_by_id dictionary.
for guid_to_remove in guids_to_remove:
diff -r 1912dec92b728b974094456be8eb6d84d34a7ca6 -r bfd679408c84a4c6f1d2b1a09eec1dab9c2d212b 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
@@ -67,10 +67,10 @@
self._setup_two_versions_remove_one( section=True, uninstall=False )
self._verify_version_2_removed_from_panel( )
# Still in tool conf since not uninstalled only deactivated...
- assert "github.com/galaxyproect/example/test_tool/0.2" in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
+ assert "github.com/galaxyproject/example/test_tool/0.2" in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
self._verify_tool_confs()
- self._remove_guids( ["github.com/galaxyproect/example/test_tool/0.1"], uninstall=False )
+ self._remove_guids( ["github.com/galaxyproject/example/test_tool/0.1"], uninstall=False )
# Now no versions of this tool are returned by toolbox.
all_versions = self.toolbox.get_tool( "test_tool", get_all_versions=True )
@@ -84,24 +84,25 @@
self._setup_two_versions_remove_one( section=True, uninstall=True )
self._verify_version_2_removed_from_panel( )
# Not in tool conf because it was uninstalled.
- assert "github.com/galaxyproect/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
+ assert "github.com/galaxyproject/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
+ assert "tool_github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel["tid"].elems
self._verify_tool_confs()
def test_deactivate_outside_section( self ):
self._setup_two_versions_remove_one( section=False, uninstall=False )
self._verify_version_2_removed_from_panel( section=False )
# Still in tool conf since not uninstalled only deactivated...
- assert "github.com/galaxyproect/example/test_tool/0.2" in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
+ assert "github.com/galaxyproject/example/test_tool/0.2" in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
self._verify_tool_confs()
def test_uninstall_outside_section( self ):
self._setup_two_versions_remove_one( section=False, uninstall=True )
self._verify_version_2_removed_from_panel( section=False )
# Still in tool conf since not uninstalled only deactivated...
- assert "github.com/galaxyproect/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
+ assert "github.com/galaxyproject/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
self._verify_tool_confs()
- self._remove_guids( ["github.com/galaxyproect/example/test_tool/0.1"], uninstall=True )
+ self._remove_guids( ["github.com/galaxyproject/example/test_tool/0.1"], uninstall=True )
# Now no versions of this tool are returned by toolbox.
all_versions = self.toolbox.get_tool( "test_tool", get_all_versions=True )
@@ -116,7 +117,7 @@
self._setup_two_versions_in_config( section=True )
self._setup_two_versions()
self.toolbox
- self._remove_guids( ["github.com/galaxyproect/example/test_tool/0.2"], uninstall=uninstall )
+ self._remove_guids( ["github.com/galaxyproject/example/test_tool/0.2"], uninstall=uninstall )
def _verify_version_2_removed_from_panel( self, section=True ):
# Check that test_tool now only has one version...
@@ -127,12 +128,12 @@
if section:
section = self.toolbox.tool_panel["tid"]
assert len(section.elems) == 1
- assert section.elems.values()[0].id == "github.com/galaxyproect/example/test_tool/0.1"
+ assert section.elems.values()[0].id == "github.com/galaxyproject/example/test_tool/0.1"
- assert "github.com/galaxyproect/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel["tid"].elems
+ assert "github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel["tid"].elems
else:
- self.toolbox.tool_panel.values()[0].id == "github.com/galaxyproect/example/test_tool/0.1"
- assert "github.com/galaxyproect/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel
+ self.toolbox.tool_panel.values()[0].id == "github.com/galaxyproject/example/test_tool/0.1"
+ assert "github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel
def _remove_guids( self, guids, uninstall, shed_tool_conf="tool_conf.xml" ):
self.tpm.remove_guids(
diff -r 1912dec92b728b974094456be8eb6d84d34a7ca6 -r bfd679408c84a4c6f1d2b1a09eec1dab9c2d212b test/unit/tools/test_toolbox.py
--- a/test/unit/tools/test_toolbox.py
+++ b/test/unit/tools/test_toolbox.py
@@ -10,12 +10,12 @@
CONFIG_TEST_TOOL_VERSION_TEMPLATE = string.Template(
- """ <tool file="tool.xml" guid="github.com/galaxyproect/example/test_tool/0.${version}">
+ """ <tool file="tool.xml" guid="github.com/galaxyproject/example/test_tool/0.${version}"><tool_shed>github.com</tool_shed><repository_name>example</repository_name><repository_owner>galaxyproject</repository_owner><installed_changeset_revision>${version}</installed_changeset_revision>
- <id>github.com/galaxyproect/example/test_tool/0.${version}</id>
+ <id>github.com/galaxyproject/example/test_tool/0.${version}</id><version>0.${version}</version></tool>
"""
@@ -72,14 +72,14 @@
def _setup_two_versions( self ):
repository1 = self._repo_install( changeset="1" )
version1 = tool_shed_install.ToolVersion()
- version1.tool_id = "github.com/galaxyproect/example/test_tool/0.1"
+ version1.tool_id = "github.com/galaxyproject/example/test_tool/0.1"
version1.repository = repository1
self.app.install_model.context.add( version1 )
self.app.install_model.context.flush( )
repository2 = self._repo_install( changeset="2" )
version2 = tool_shed_install.ToolVersion()
- version2.tool_id = "github.com/galaxyproect/example/test_tool/0.2"
+ version2.tool_id = "github.com/galaxyproject/example/test_tool/0.2"
version2.repository = repository2
self.app.install_model.context.add( version2 )
@@ -184,7 +184,7 @@
# Assert only newer version of the tool loaded into the panel.
section = self.toolbox.tool_panel["tid"]
assert len(section.elems) == 1
- assert section.elems.values()[0].id == "github.com/galaxyproect/example/test_tool/0.2"
+ assert section.elems.values()[0].id == "github.com/galaxyproject/example/test_tool/0.2"
def test_group_tools_out_of_section( self ):
self._init_tool()
@@ -212,10 +212,10 @@
self._init_tool()
self._setup_two_versions_in_config( )
self._setup_two_versions()
- assert self.toolbox.get_tool_id( "test_tool" ) == "github.com/galaxyproect/example/test_tool/0.1"
- assert self.toolbox.get_tool_id( "github.com/galaxyproect/example/test_tool/0.1" ) == "github.com/galaxyproect/example/test_tool/0.1"
- assert self.toolbox.get_tool_id( "github.com/galaxyproect/example/test_tool/0.2" ) == "github.com/galaxyproect/example/test_tool/0.2"
- assert self.toolbox.get_tool_id( "github.com/galaxyproect/example/test_tool/0.3" ) is None
+ assert self.toolbox.get_tool_id( "test_tool" ) == "github.com/galaxyproject/example/test_tool/0.1"
+ assert self.toolbox.get_tool_id( "github.com/galaxyproject/example/test_tool/0.1" ) == "github.com/galaxyproject/example/test_tool/0.1"
+ assert self.toolbox.get_tool_id( "github.com/galaxyproject/example/test_tool/0.2" ) == "github.com/galaxyproject/example/test_tool/0.2"
+ assert self.toolbox.get_tool_id( "github.com/galaxyproject/example/test_tool/0.3" ) is None
def test_tool_dir( self ):
self._init_tool()
@@ -285,14 +285,14 @@
# Verify lineage_ids on both tools is correctly ordered.
for version in ["0.1", "0.2"]:
- guid = "github.com/galaxyproect/example/test_tool/" + version
+ guid = "github.com/galaxyproject/example/test_tool/" + version
lineage_ids = self.toolbox.get_tool( guid ).lineage_ids
- assert lineage_ids[ 0 ] == "github.com/galaxyproect/example/test_tool/0.1"
- assert lineage_ids[ 1 ] == "github.com/galaxyproect/example/test_tool/0.2"
+ assert lineage_ids[ 0 ] == "github.com/galaxyproject/example/test_tool/0.1"
+ assert lineage_ids[ 1 ] == "github.com/galaxyproject/example/test_tool/0.2"
# Test tool_version attribute.
- assert self.toolbox.get_tool( "test_tool", tool_version="0.1" ).guid == "github.com/galaxyproect/example/test_tool/0.1"
- assert self.toolbox.get_tool( "test_tool", tool_version="0.2" ).guid == "github.com/galaxyproect/example/test_tool/0.2"
+ assert self.toolbox.get_tool( "test_tool", tool_version="0.1" ).guid == "github.com/galaxyproject/example/test_tool/0.1"
+ assert self.toolbox.get_tool( "test_tool", tool_version="0.2" ).guid == "github.com/galaxyproject/example/test_tool/0.2"
def __remove_itp( self ):
os.remove( os.path)
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.
1
0