Skip to content

Remove deprecated tool document cache #20510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24359,7 +24359,9 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": unknown;
"application/json": {
[key: string]: unknown;
};
};
};
/** @description Request Error */
Expand Down
16 changes: 0 additions & 16 deletions doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1217,22 +1217,6 @@
:Type: str


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``enable_tool_document_cache``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Description:
This option is deprecated, and the tool document cache will be
removed in the next release. Whether to enable the tool document
cache. This cache stores expanded XML strings. Enabling the tool
cache results in slightly faster startup times. The tool cache is
backed by a SQLite database, which cannot be stored on certain
network disks. The cache location is configurable with the
``tool_cache_data_dir`` tag in tool config files.
:Default: ``false``
:Type: bool


~~~~~~~~~~~~~~~~~~~~~~~~~
``tool_search_index_dir``
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 0 additions & 1 deletion lib/galaxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ def __init__(self, **kwargs) -> None:
self.datatypes_registry.load_external_metadata_tool(self.toolbox)
# Load history import/export tools.
load_lib_tools(self.toolbox)
self.toolbox.persist_cache(register_postfork=True)
# visualizations registry: associates resources with visualizations, controls how to render
self.visualizations_registry = self._register_singleton(
VisualizationsRegistry,
Expand Down
2 changes: 0 additions & 2 deletions lib/galaxy/app_unittest_utils/galaxy_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ def __init__(self, **kwargs):
self.version_major = "19.09"

# set by MockDir
self.enable_tool_document_cache = False
self.tool_cache_data_dir = os.path.join(self.root, "tool_cache")
self.external_chown_script = None
self.check_job_script_integrity = False
self.check_job_script_integrity_count = 0
Expand Down
9 changes: 0 additions & 9 deletions lib/galaxy/config/sample/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -935,15 +935,6 @@ galaxy:
# generated commands run in sh.
#default_job_shell: /bin/bash

# This option is deprecated, and the tool document cache will be
# removed in the next release. Whether to enable the tool document
# cache. This cache stores expanded XML strings. Enabling the tool
# cache results in slightly faster startup times. The tool cache is
# backed by a SQLite database, which cannot be stored on certain
# network disks. The cache location is configurable with the
# ``tool_cache_data_dir`` tag in tool config files.
#enable_tool_document_cache: false

# Directory in which the toolbox search index is stored. The value of
# this option will be resolved with respect to <data_dir>.
#tool_search_index_dir: tool_search_index
Expand Down
13 changes: 0 additions & 13 deletions lib/galaxy/config/schemas/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -882,19 +882,6 @@ 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: false
required: false
desc: |
This option is deprecated, and the tool document cache will be removed
in the next release.
Whether to enable the tool document cache. This cache stores
expanded XML strings. Enabling the tool cache results in slightly faster startup
times. The tool cache is backed by a SQLite database, which cannot
be stored on certain network disks. The cache location is configurable
with the ``tool_cache_data_dir`` tag in tool config files.

tool_search_index_dir:
type: str
default: tool_search_index
Expand Down
1 change: 0 additions & 1 deletion lib/galaxy/dependencies/pinned-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ social-auth-core==4.6.1
sortedcontainers==2.4.0
spython==0.3.14
sqlalchemy==2.0.40
sqlitedict==2.1.0
sqlparse==0.5.3
starlette==0.46.2
starlette-context==0.4.0
Expand Down
13 changes: 7 additions & 6 deletions lib/galaxy/managers/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def tool_payload_to_tool(app, tool_dict: Dict[str, Any]) -> Optional[Tool]:
return tool


class DynamicToolManager(ModelManager[model.DynamicTool]):
class DynamicToolManager(ModelManager[DynamicTool]):
"""Manages dynamic tools stored in Galaxy's database."""

model_class = model.DynamicTool
model_class = DynamicTool

def ensure_can_use_unprivileged_tool(self, user: model.User):
stmt = select(
Expand All @@ -70,7 +70,7 @@ def ensure_can_use_unprivileged_tool(self, user: model.User):
if not self.session().execute(stmt).scalar():
raise exceptions.InsufficientPermissionsException("User is not allowed to run unprivileged tools")

def get_tool_by_id_or_uuid(self, id_or_uuid: Union[int, str]):
def get_tool_by_id_or_uuid(self, id_or_uuid: Union[int, str]) -> Union[DynamicTool, None]:
if isinstance(id_or_uuid, int):
return self.get_tool_by_id(id_or_uuid)
else:
Expand Down Expand Up @@ -213,9 +213,10 @@ def deactivate_unprivileged_tool(self, user: model.User, dynamic_tool: DynamicTo
session.execute(update_stmt)
session.commit()

def deactivate(self, dynamic_tool):
self.update(dynamic_tool, {"active": False})
return dynamic_tool
def deactivate(self, dynamic_tool: DynamicTool) -> DynamicTool:
assert isinstance(dynamic_tool.uuid, UUID)
del self.app.toolbox._tools_by_uuid[dynamic_tool.uuid]
return self.update(dynamic_tool, {"active": False})


class ToolFilterMixin:
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def get_uuid(uuid: Optional[Union[UUID, str]] = None) -> UUID:
return uuid
if not uuid:
return uuid4()
return UUID(str(uuid))
return UUID(uuid)


def to_json(sa_session, column, keys: List[str]):
Expand Down
18 changes: 12 additions & 6 deletions lib/galaxy/queue_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import threading
import time
from inspect import ismodule
from typing import TYPE_CHECKING
from typing import (
Optional,
TYPE_CHECKING,
)

from kombu import (
Consumer,
Expand All @@ -33,10 +36,14 @@
log = logging.getLogger(__name__)

if TYPE_CHECKING:
from galaxy.structured_app import MinimalManagerApp
from galaxy.app import UniverseApplication
from galaxy.structured_app import (
MinimalManagerApp,
StructuredApp,
)


def send_local_control_task(app, task, get_response=False, kwargs=None):
def send_local_control_task(app: "StructuredApp", task: str, get_response: bool = False, kwargs: Optional[dict] = None):
"""
This sends a message to the process-local control worker, which is useful
for one-time asynchronous tasks like recalculating user disk usage.
Expand Down Expand Up @@ -162,7 +169,7 @@ def reload_tool(app, **kwargs):
log.error("Reload tool invoked without tool id.")


def reload_toolbox(app, save_integrated_tool_panel=True, **kwargs):
def reload_toolbox(app: "UniverseApplication", save_integrated_tool_panel: bool = True, **kwargs) -> None:
reload_timer = util.ExecutionTimer()
log.debug("Executing toolbox reload on '%s'", app.config.server_name)
reload_count = app.toolbox._reload_count
Expand All @@ -174,7 +181,7 @@ def reload_toolbox(app, save_integrated_tool_panel=True, **kwargs):
log.debug("Toolbox reload %s", reload_timer)


def _get_new_toolbox(app, save_integrated_tool_panel=True):
def _get_new_toolbox(app: "UniverseApplication", save_integrated_tool_panel: bool = True) -> None:
"""
Generate a new toolbox, by constructing a toolbox from the config files,
and then adding pre-existing data managers from the old toolbox to the new toolbox.
Expand All @@ -190,7 +197,6 @@ def _get_new_toolbox(app, save_integrated_tool_panel=True):
load_lib_tools(new_toolbox)
[new_toolbox.register_tool(tool) for tool in new_toolbox.data_manager_tools.values()]
app._toolbox = new_toolbox
app.toolbox.persist_cache()


def reload_data_managers(app, **kwargs):
Expand Down
10 changes: 3 additions & 7 deletions lib/galaxy/tool_shed/galaxy_install/tools/tool_panel_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def add_to_shed_tool_config(self, shed_tool_conf_dict: Dict[str, Any], elem_list
return
old_toolbox = self.app.toolbox
shed_tool_conf = shed_tool_conf_dict["config_filename"]
tool_cache_data_dir = shed_tool_conf_dict.get("tool_cache_data_dir")
tool_path = shed_tool_conf_dict["tool_path"]
config_elems = []
# Ideally shed_tool_conf.xml would be created before the repo is cloned and added to the DB, but this is called
Expand Down Expand Up @@ -83,7 +82,7 @@ def add_to_shed_tool_config(self, shed_tool_conf_dict: Dict[str, Any], elem_list
else:
config_elems.append(elem_entry)
# Persist the altered shed_tool_config file.
self.config_elems_to_xml_file(config_elems, shed_tool_conf, tool_path, tool_cache_data_dir)
self.config_elems_to_xml_file(config_elems, shed_tool_conf, tool_path)
self.app.wait_for_toolbox_reload(old_toolbox)
else:
log.error(error_message)
Expand Down Expand Up @@ -135,16 +134,13 @@ def add_to_tool_panel(
self.app.toolbox.update_shed_config(shed_tool_conf_dict)
self.add_to_shed_tool_config(shed_tool_conf_dict, elem_list)

def config_elems_to_xml_file(self, config_elems, config_filename, tool_path, tool_cache_data_dir=None) -> None:
def config_elems_to_xml_file(self, config_elems, config_filename, tool_path) -> None:
"""
Persist the current in-memory list of config_elems to a file named by the
value of config_filename.
"""
try:
tool_cache_data_dir = f' tool_cache_data_dir="{tool_cache_data_dir}"' if tool_cache_data_dir else ""
root = parse_xml_string(
f'<?xml version="1.0"?>\n<toolbox tool_path="{tool_path}"{tool_cache_data_dir}></toolbox>'
)
root = parse_xml_string(f'<?xml version="1.0"?>\n<toolbox tool_path="{tool_path}"></toolbox>')
for elem in config_elems:
root.append(elem)
with RenamedTemporaryFile(config_filename, mode="w") as fh:
Expand Down
16 changes: 12 additions & 4 deletions lib/galaxy/tool_shed/unittest_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from pathlib import Path
from typing import (
Any,
cast,
Dict,
List,
NamedTuple,
Optional,
TYPE_CHECKING,
Union,
)

Expand Down Expand Up @@ -39,6 +41,10 @@
)
from galaxy.util.tool_shed.tool_shed_registry import Registry

if TYPE_CHECKING:
from galaxy.tools import Tool
from galaxy.util.path import StrPath


class ToolShedTarget(NamedTuple):
url: str
Expand Down Expand Up @@ -83,7 +89,7 @@ class TestTool:
params_with_missing_data_table_entry: list = []
params_with_missing_index_file: list = []

def __init__(self, config_file, tool_shed_repository, guid):
def __init__(self, config_file: "StrPath", tool_shed_repository, guid: str) -> None:
self.config_file = config_file
self.tool_shed_repository = tool_shed_repository
self.guid = guid
Expand All @@ -100,12 +106,14 @@ def lineage(self):


class TestToolBox(AbstractToolBox):
def create_tool(self, config_file, tool_cache_data_dir=None, **kwds):
tool = TestTool(config_file, kwds["tool_shed_repository"], kwds["guid"])
def create_tool(self, config_file: "StrPath", **kwds) -> "Tool":
tool = cast("Tool", TestTool(config_file, kwds["tool_shed_repository"], kwds["guid"]))
tool._lineage = self._lineage_map.register(tool) # cleanup?
return tool

def _get_tool_shed_repository(self, tool_shed, name, owner, installed_changeset_revision):
def _get_tool_shed_repository(
self, tool_shed: str, name: str, owner: str, installed_changeset_revision: Optional[str]
):
return get_installed_repository(
self.app,
tool_shed=tool_shed,
Expand Down
16 changes: 8 additions & 8 deletions lib/galaxy/tool_shed/util/repository_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ def get_absolute_path_to_file_in_repository(repo_files_dir, file_name):

def get_installed_repository(
app: "InstallationTarget",
tool_shed=None,
name=None,
owner=None,
changeset_revision=None,
installed_changeset_revision=None,
repository_id=None,
from_cache=False,
):
tool_shed: Optional[str] = None,
name: Optional[str] = None,
owner: Optional[str] = None,
changeset_revision: Optional[str] = None,
installed_changeset_revision: Optional[str] = None,
repository_id: Optional[int] = None,
from_cache: bool = False,
) -> ToolShedRepository:
"""
Return a tool shed repository database record defined by the combination of a toolshed, repository name,
repository owner and either current or originally installed changeset_revision.
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/parser/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def parse_creator(self):
return []

@property
def macro_paths(self):
def macro_paths(self) -> List[str]:
return []

@property
Expand Down
7 changes: 5 additions & 2 deletions lib/galaxy/tool_util/parser/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
)

if TYPE_CHECKING:
from galaxy.util.path import StrPath
from .output_objects import ToolOutputBase

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -158,7 +159,9 @@ class XmlToolSource(ToolSource):

language = "xml"

def __init__(self, xml_tree: ElementTree, source_path=None, macro_paths=None):
def __init__(
self, xml_tree: ElementTree, source_path: Optional["StrPath"] = None, macro_paths: Optional[List[str]] = None
) -> None:
self.xml_tree = xml_tree
self.root = self.xml_tree.getroot()
self._source_path = source_path
Expand Down Expand Up @@ -683,7 +686,7 @@ def parse_help(self) -> Optional[HelpContent]:
return HelpContent(format=help_format, content=content)

@property
def macro_paths(self):
def macro_paths(self) -> List[str]:
return self._macro_paths

@property
Expand Down
Loading
Loading