From a21621d78e0e97fa88cfbd49ae3c2e1c85ef38cc Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 7 Jul 2026 14:02:48 +0200 Subject: [PATCH] source_store: drop benchmark-only ToolIndex.search and get_sanitize_allowlist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neither is on the production read path. Lazy search goes through the populator-built whoosh index (LazyToolboxSearch -> ToolWhooshIndex), and /api/sanitize_allow builds its response from config.sanitize_allowlist against the toolbox. The two ToolIndex methods were called only from benchmarks.py and unit tests, and ToolIndex.search's token ranking diverged from whoosh's BM25F — a correctness trap. Remove both (whoosh search stays covered by test_multi_store_search.py); keep the reusable per-entry ToolIndexEntry.to_sanitize_entry projection. Claude-Session: https://claude.ai/code/session_018L7ZmCv2ubKA3JNeSL8Pkr --- lib/galaxy/tools/source_store/benchmarks.py | 24 --------------------- 1 file changed, 24 deletions(-) diff --git a/lib/galaxy/tools/source_store/benchmarks.py b/lib/galaxy/tools/source_store/benchmarks.py index 402d47857d6..8fbac494834 100644 --- a/lib/galaxy/tools/source_store/benchmarks.py +++ b/lib/galaxy/tools/source_store/benchmarks.py @@ -222,17 +222,6 @@ class ToolSourceBenchmarks: iterations=iterations, ) - def benchmark_index_search(self, iterations: int = 100) -> BenchmarkResult: - """Benchmark searching the tool index.""" - index = self._build_sample_index(1000) - queries = ["genomics", "tool_5", "number", "does"] - - def search(): - for q in queries: - index.search(q, limit=50) - - return benchmark_function("index_search", search, iterations) - def benchmark_api_response_generation(self, iterations: int = 100) -> BenchmarkResult: """Benchmark generating /api/tools response from index.""" index = self._build_sample_index(1000) @@ -268,17 +257,6 @@ class ToolSourceBenchmarks: iterations, ) - def benchmark_sanitize_allowlist(self, iterations: int = 100) -> BenchmarkResult: - """Benchmark /api/sanitize_allow generation.""" - index = self._build_sample_index(1000) - allowed_ids = {f"tool_{i}" for i in range(0, 1000, 2)} # Half allowed - - return benchmark_function( - "sanitize_allowlist", - lambda: index.get_sanitize_allowlist(allowed_ids), - iterations, - ) - def benchmark_requirements_summary(self, iterations: int = 100) -> BenchmarkResult: """Benchmark /api/dependency_resolvers/toolbox generation.""" index = self._build_sample_index(1000) @@ -322,11 +300,9 @@ class ToolSourceBenchmarks: ("XML Parsing", lambda: self.benchmark_xml_parsing(iterations)), ("DB Deserialization", lambda: self.benchmark_deserialization_from_db_format(iterations)), ("Hash Computation", lambda: self.benchmark_hash_computation(iterations * 10)), - ("Index Search", lambda: self.benchmark_index_search(iterations)), ("API Response Generation", lambda: self.benchmark_api_response_generation(iterations)), ("Tests Summary", lambda: self.benchmark_tests_summary(iterations)), ("All Requirements", lambda: self.benchmark_all_requirements(iterations)), - ("Sanitize Allowlist", lambda: self.benchmark_sanitize_allowlist(iterations)), ("Requirements Summary", lambda: self.benchmark_requirements_summary(iterations)), ("Index Serialization", lambda: self.benchmark_index_serialization(iterations // 2)), ("Index Deserialization", lambda: self.benchmark_index_deserialization(iterations // 2)),