Skip to content

Commit

Permalink
Merge pull request #3125 from mvdbeek/fix_invalid_section_key
Browse files Browse the repository at this point in the history
Fix tools placed outside of panel section
  • Loading branch information
bgruening committed Nov 6, 2016
2 parents 58b7b6c + 4365b90 commit 202f96c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
12 changes: 11 additions & 1 deletion lib/galaxy/queue_worker.py
Expand Up @@ -40,6 +40,15 @@ def send_control_task(app, task, noop_self=False, kwargs={}):
# just an example method. Ideally this gets pushed into atomic tasks, whether
# where they're currently invoked, or elsewhere. (potentially using a dispatch
# decorator).

def create_panel_section(app, **kwargs):
"""
Updates in memory toolbox dictionary.
"""
log.debug("Updating in-memory tool panel")
app.toolbox.create_section(kwargs)


def reload_tool(app, **kwargs):
params = util.Params(kwargs)
tool_id = params.get('tool_id', None)
Expand Down Expand Up @@ -117,7 +126,8 @@ def admin_job_lock(app, **kwargs):
log.info("Administrative Job Lock is now set to %s. Jobs will %s dispatch."
% (job_lock, "not" if job_lock else "now"))

control_message_to_task = { 'reload_tool': reload_tool,
control_message_to_task = { 'create_panel_section': create_panel_section,
'reload_tool': reload_tool,
'reload_toolbox': reload_toolbox,
'reload_data_managers': reload_data_managers,
'reload_display_application': reload_display_application,
Expand Down
14 changes: 13 additions & 1 deletion lib/galaxy/tools/__init__.py
Expand Up @@ -9,6 +9,7 @@
import re
import tarfile
import tempfile
import time
import threading
import urllib
from datetime import datetime
Expand All @@ -24,7 +25,10 @@
from galaxy.managers import histories
from galaxy.datatypes.metadata import JobExternalOutputMetadataWrapper
from galaxy import exceptions
from galaxy.queue_worker import reload_toolbox
from galaxy.queue_worker import (
reload_toolbox,
send_control_task
)
from galaxy.tools.actions import DefaultToolAction
from galaxy.tools.actions.upload import UploadToolAction
from galaxy.tools.actions.data_source import DataSourceToolAction
Expand Down Expand Up @@ -115,6 +119,14 @@ def __init__( self, config_filenames, tool_root_dir, app, tool_conf_watcher=None
def handle_reload_toolbox(self):
reload_toolbox(self.app)

def handle_panel_update(self, section_dict):
send_control_task(self.app, 'create_panel_section', noop_self=False, kwargs=section_dict)
max_wait = 10
i = 0
while not section_dict['id'] in self._tool_panel and i < max_wait:
i += 1
time.sleep(1)

def has_reloaded(self, other_toolbox):
return self._reload_count != other_toolbox._reload_count

Expand Down
18 changes: 15 additions & 3 deletions lib/galaxy/tools/toolbox/base.py
Expand Up @@ -95,6 +95,13 @@ def handle_reload_toolbox(self):
interacting with the rest of the Galaxy app or message queues, etc....
"""

def handle_panel_update(self, section_dict):
"""Extension-point for Galaxy-app specific reload logic.
This abstract representation of the toolbox shouldn't have details about
interacting with the rest of the Galaxy app or message queues, etc....
"""

def create_tool( self, config_file, repository_id=None, guid=None, **kwds ):
raise NotImplementedError()

Expand Down Expand Up @@ -236,14 +243,19 @@ def get_section( self, section_id, new_label=None, create_if_needed=False ):
'id': section_id,
'version': '',
}
tool_section = ToolSection( section_dict )
self._tool_panel.append_section( tool_panel_section_key, tool_section )
log.debug( "Loading new tool panel section: %s" % str( tool_section.name ) )
self.handle_panel_update(section_dict)
tool_section = self._tool_panel[ tool_panel_section_key ]
self._save_integrated_tool_panel()
else:
tool_section = None
return tool_panel_section_key, tool_section

def create_section(self, section_dict):
tool_section = ToolSection(section_dict)
self._tool_panel.append_section(tool_section.id, tool_section)
log.debug("Loading new tool panel section: %s" % str(tool_section.name))
return tool_section

def get_integrated_section_for_tool( self, tool ):
tool_id = tool.id

Expand Down
3 changes: 3 additions & 0 deletions test/unit/tools/test_toolbox.py
Expand Up @@ -443,6 +443,9 @@ def __init__( self, test_case ):
)
self._tool_conf_watcher = get_tool_conf_watcher(dummy_callback)

def handle_panel_update(self, section_dict):
self.create_section(section_dict)


def dummy_callback():
pass

0 comments on commit 202f96c

Please sign in to comment.