From d078e7b1f6082801d3334bd2f032de5d616ce558 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 18 Jul 2023 19:34:09 -0700 Subject: [PATCH] Clean up search type usage in khoj server, tests and Readme --- README.md | 2 +- src/khoj/configure.py | 6 ++---- tests/test_client.py | 12 ++++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index fd8fbc88..99e21677 100644 --- a/README.md +++ b/README.md @@ -311,7 +311,7 @@ pip install --upgrade --pre khoj-assistant model_directory: "~/.khoj/search/asymmetric/" ``` - 2. Regenerate your content index. For example, by opening [\/api/update?t=force](http://localhost:42110/api/update?t=force) + 2. Regenerate your content index. For example, by opening [\/api/update?force=true](http://localhost:42110/api/update?force=true) ### Bootstrap Khoj Search for Offline Usage later diff --git a/src/khoj/configure.py b/src/khoj/configure.py index bba03dc2..469f33ff 100644 --- a/src/khoj/configure.py +++ b/src/khoj/configure.py @@ -37,9 +37,7 @@ from khoj.search_filter.file_filter import FileFilter logger = logging.getLogger(__name__) -def initialize_server( - config: Optional[FullConfig], regenerate: bool, type: Optional[SearchType] = None, required=False -): +def initialize_server(config: Optional[FullConfig], regenerate: bool, required=False): if config is None and required: logger.error( f"🚨 Exiting as Khoj is not configured.\nConfigure it via http://localhost:42110/config or by editing {state.config_file}." @@ -52,7 +50,7 @@ def initialize_server( return None try: - configure_server(config, regenerate, type) + configure_server(config, regenerate) except Exception as e: logger.error(f"🚨 Failed to configure server on app load: {e}", exc_info=True) diff --git a/tests/test_client.py b/tests/test_client.py index d86bdd90..f1f4951b 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -35,11 +35,11 @@ def test_search_with_invalid_content_type(client): # ---------------------------------------------------------------------------------------------------- def test_search_with_valid_content_type(client): - for content_type in ["all", "org", "markdown", "image", "pdf", "plugin1"]: + for content_type in ["all", "org", "markdown", "image", "pdf", "github", "notion", "plugin1"]: # Act response = client.get(f"/api/search?q=random&t={content_type}") # Assert - assert response.status_code == 200 + assert response.status_code == 200, f"Returned status: {response.status_code} for content type: {content_type}" # ---------------------------------------------------------------------------------------------------- @@ -53,11 +53,11 @@ def test_update_with_invalid_content_type(client): # ---------------------------------------------------------------------------------------------------- def test_update_with_valid_content_type(client): - for content_type in ["org", "markdown", "image", "pdf", "plugin1"]: + for content_type in ["all", "org", "markdown", "image", "pdf", "github", "notion", "plugin1"]: # Act response = client.get(f"/api/update?t={content_type}") # Assert - assert response.status_code == 200 + assert response.status_code == 200, f"Returned status: {response.status_code} for content type: {content_type}" # ---------------------------------------------------------------------------------------------------- @@ -71,11 +71,11 @@ def test_regenerate_with_invalid_content_type(client): # ---------------------------------------------------------------------------------------------------- def test_regenerate_with_valid_content_type(client): - for content_type in ["org", "markdown", "image", "pdf", "plugin1"]: + for content_type in ["all", "org", "markdown", "image", "pdf", "github", "notion", "plugin1"]: # Act response = client.get(f"/api/update?force=true&t={content_type}") # Assert - assert response.status_code == 200 + assert response.status_code == 200, f"Returned status: {response.status_code} for content type: {content_type}" # ----------------------------------------------------------------------------------------------------