From 3de99087d9bfa5f5dab0f7d071345186e0890a40 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 6 Aug 2019 16:33:13 -0400 Subject: [PATCH 1/2] Don't parse HTML for tool help search index. Just use the simpler raw rST (or Markdown in the future). This should prevent all rst_to_html loading from happening at Galaxy startup - the existing caching should allow it to just be loaded and cached on first use. --- lib/galaxy/tools/__init__.py | 7 +++++++ lib/galaxy/tools/search/__init__.py | 18 +++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index e9490bb99d0..288258ba1eb 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -1246,6 +1246,13 @@ class Tool(Dictifiable): self.__ensure_help() return self.__help_by_page + @property + def raw_help(self): + # may return rst (or Markdown in the future) + tool_source = self.__help_source + help_text = tool_source.parse_help() + return help_text + def __ensure_help(self): with HELP_UNINITIALIZED: if self.__help is HELP_UNINITIALIZED: diff --git a/lib/galaxy/tools/search/__init__.py b/lib/galaxy/tools/search/__init__.py index 7f68703bc06..a7d38c3076f 100644 --- a/lib/galaxy/tools/search/__init__.py +++ b/lib/galaxy/tools/search/__init__.py @@ -104,15 +104,15 @@ class ToolBoxSearch(object): add_doc_kwds['stub'] = to_unicode(id) if tool.labels: add_doc_kwds['labels'] = to_unicode(" ".join(tool.labels)) - if index_help and tool.help: - try: - raw_html = tool.help.render(host_url="", static_path="") - cleantext = clean(raw_html, tags=[''], strip=True).replace('\n', ' ') - add_doc_kwds['help'] = to_unicode(cleantext) - except Exception: - # Don't fail to build index just because a help message - # won't render. - pass + if index_help: + raw_help = tool.raw_help + if raw_help: + try: + add_doc_kwds['help'] = to_unicode(raw_help) + except Exception: + # Don't fail to build index just because a help message + # won't render. + pass return add_doc_kwds def search(self, q, tool_name_boost, tool_section_boost, tool_description_boost, tool_label_boost, tool_stub_boost, tool_help_boost, tool_search_limit, tool_enable_ngram_search, tool_ngram_minsize, tool_ngram_maxsize): From 42d1a1fb1f28bce9ec8500d789c078f3aa111ae3 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Tue, 6 Aug 2019 16:55:17 -0400 Subject: [PATCH 2/2] drop unused import --- lib/galaxy/tools/search/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/galaxy/tools/search/__init__.py b/lib/galaxy/tools/search/__init__.py index a7d38c3076f..2c894bd56cb 100644 --- a/lib/galaxy/tools/search/__init__.py +++ b/lib/galaxy/tools/search/__init__.py @@ -6,7 +6,6 @@ import logging import re import tempfile -from bleach import clean from whoosh import analysis from whoosh.analysis import StandardAnalyzer from whoosh.fields import (