From 4d984c51328007f53a2d2e1f95513199f002b558 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 20 Jan 2021 10:08:54 +0100 Subject: [PATCH 1/2] Add setting that lets admins enable/disable the tool document cache Closes https://github.com/galaxyproject/galaxy/issues/11082 --- doc/source/admin/galaxy_options.rst | 15 +++++++++++++++ lib/galaxy/config/sample/galaxy.yml.sample | 8 ++++++++ lib/galaxy/tools/__init__.py | 9 +++++---- lib/galaxy/webapps/galaxy/config_schema.yml | 11 +++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index 336c57ec9b5..6469d27017f 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -1049,6 +1049,21 @@ :Type: str +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``enable_tool_document_cache`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Description: + Set this to false to disable the tool document cache. This cache + stores expanded xml strings. Disabling the tool cache results in + slower startup times. The tool cache is backed by sqlite database, + which cannot be stored on certain network disks. The cache + location is configurable using the ``tool_cache_data_dir`` + setting, but can be disabled completely here. +:Default: ``true`` +:Type: bool + + ~~~~~~~~~~~~~~~~~~~~~~~ ``tool_cache_data_dir`` ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index 7aa1ff8723a..7fccb510097 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -617,6 +617,14 @@ galaxy: # generated commands run in sh. #default_job_shell: /bin/bash + # Set this to false to disable the tool document cache. This cache + # stores expanded xml strings. Disabling the tool cache results in + # slower startup times. The tool cache is backed by sqlite database, + # which cannot be stored on certain network disks. The cache location + # is configurable using the ``tool_cache_data_dir`` setting, but can + # be disabled completely here. + #enable_tool_document_cache: true + # Tool related caching. Fully expanded tools and metadata will be # stored at this path. Per tool_conf cache locations can be configured # in (``shed_``)tool_conf.xml files using the tool_cache_data_dir diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index dfaefdd8f90..13c89d9b7ff 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -305,13 +305,14 @@ class ToolBox(BaseGalaxyToolBox): return self._tools_by_id def get_cache_region(self, tool_cache_data_dir): - if tool_cache_data_dir not in self.cache_regions: - self.cache_regions[tool_cache_data_dir] = ToolDocumentCache(cache_dir=tool_cache_data_dir) - return self.cache_regions[tool_cache_data_dir] + if self.app.config.enable_tool_document_cache: + if tool_cache_data_dir not in self.cache_regions: + self.cache_regions[tool_cache_data_dir] = ToolDocumentCache(cache_dir=tool_cache_data_dir) + return self.cache_regions[tool_cache_data_dir] def create_tool(self, config_file, tool_cache_data_dir=None, **kwds): cache = self.get_cache_region(tool_cache_data_dir or self.app.config.tool_cache_data_dir) - if config_file.endswith('.xml') and not cache.disabled: + if config_file.endswith('.xml') and cache and not cache.disabled: tool_document = cache.get(config_file) if tool_document: tool_source = self.get_expanded_tool_source( diff --git a/lib/galaxy/webapps/galaxy/config_schema.yml b/lib/galaxy/webapps/galaxy/config_schema.yml index 7abb5892c01..5471ac209ae 100644 --- a/lib/galaxy/webapps/galaxy/config_schema.yml +++ b/lib/galaxy/webapps/galaxy/config_schema.yml @@ -765,6 +765,17 @@ mapping: should be disabled. Containerized jobs always use /bin/sh - so more maximum portability tool authors should assume generated commands run in sh. + enable_tool_document_cache: + type: bool + default: true + required: false + desc: | + Set this to false to disable the tool document cache. This cache stores + expanded xml strings. Disabling the tool cache results in slower startup + times. The tool cache is backed by sqlite database, which cannot + be stored on certain network disks. The cache location is configurable + using the ``tool_cache_data_dir`` setting, but can be disabled completely here. + tool_cache_data_dir: type: str default: tool_cache From 9ac472ecc5d4e6567145bee0c028fe6b3869f793 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 20 Jan 2021 10:34:02 +0100 Subject: [PATCH 2/2] Disable tool document cache in unit tests --- test/unit/unittest_utils/galaxy_mock.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit/unittest_utils/galaxy_mock.py b/test/unit/unittest_utils/galaxy_mock.py index 3b258b9c60d..0bce36c22ef 100644 --- a/test/unit/unittest_utils/galaxy_mock.py +++ b/test/unit/unittest_utils/galaxy_mock.py @@ -170,6 +170,7 @@ class MockAppConfig(Bunch): # set by MockDir self.root = root + self.enable_tool_document_cache = False self.tool_cache_data_dir = os.path.join(root, 'tool_cache') self.delay_tool_initialization = True self.external_chown_script = None