Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Speed up initialization

Daoud Clarkeacecffedf9cb
diff --git a/mwmbl/redis_url_queue.py b/mwmbl/redis_url_queue.py
index 30605fb..5cf0877 100644
--- a/mwmbl/redis_url_queue.py
+++ b/mwmbl/redis_url_queue.py
@@ -54,7 +54,7 @@ def get_domain_max_urls(domain: str, curated_domains: set[str]):
class RedisURLQueue:
def __init__(self, redis: Redis, get_curated_domains_function: Callable[[], set[str]]) -> None:
self.redis = redis
- self.black_listed_domains = get_blacklist_domains()
+ self._blacklisted_domains = None
self.get_curated_domains_function = get_curated_domains_function
def queue_urls(self, found_urls: list[FoundURL]):
@@ -160,3 +160,9 @@ class RedisURLQueue:
def get_domain_count(self, domain: str):
return self.redis.zcard(DOMAIN_URLS_KEY.format(domain=domain))
+
+ @property
+ def blacklisted_domains(self):
+ if self._black_listed_domains is None:
+ self._black_listed_domains = get_blacklist_domains()
+ return self._black_listed_domains
diff --git a/mwmbl/search_setup.py b/mwmbl/search_setup.py
index 4b749f0..11ace76 100644
--- a/mwmbl/search_setup.py
+++ b/mwmbl/search_setup.py
@@ -33,8 +33,8 @@ index_path = Path(settings.DATA_PATH) / settings.INDEX_NAME
tiny_index = TinyIndex(item_factory=Document, index_path=index_path)
tiny_index.__enter__()
-model_path = Path(__file__).parent / "resources" / "model.pickle"
-model = pickle.load(open(model_path, 'rb'))
+# model_path = Path(__file__).parent / "resources" / "model.pickle"
+# model = pickle.load(open(model_path, 'rb'))
# ranker = LTRRanker(tiny_index, completer, model, 1000, True, 5)
ranker = HeuristicAndWikiRanker(tiny_index, completer)