From 12a8ae1c47f111b9f36633c96b26e8642c5ff223 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 26 Jul 2023 04:16:43 -0700 Subject: fix: :bug: more reliable setup of meilisearch --- .../continuedev/plugins/context_providers/file.py | 41 ++++++++++++---------- .../src/continuedev/server/meilisearch_server.py | 14 +++++--- 2 files changed, 33 insertions(+), 22 deletions(-) (limited to 'continuedev/src') diff --git a/continuedev/src/continuedev/plugins/context_providers/file.py b/continuedev/src/continuedev/plugins/context_providers/file.py index 6222ec6a..3e1b12c8 100644 --- a/continuedev/src/continuedev/plugins/context_providers/file.py +++ b/continuedev/src/continuedev/plugins/context_providers/file.py @@ -14,6 +14,27 @@ def get_file_contents(filepath: str) -> str: return "" +DEFAULT_IGNORE_DIRS = [ + ".git", + ".vscode", + ".idea", + ".vs", + ".venv", + "env", + ".env", + "node_modules", + "dist", + "build", + "target", + "out", + "bin", + ".pytest_cache", + ".vscode-test", + ".continue", + "__pycache__" +] + + class FileContextProvider(ContextProvider): """ The FileContextProvider is a ContextProvider that allows you to search files in the open workspace. @@ -21,24 +42,8 @@ class FileContextProvider(ContextProvider): title = "file" workspace_dir: str - ignore_patterns: List[str] = [ - ".git", - ".vscode", - ".idea", - ".vs", - ".venv", - "env", - ".env", - "node_modules", - "dist", - "build", - "target", - "out", - "bin", - ".pytest_cache", - ".vscode-test", - ".continue", - ] + ignore_patterns: List[str] = DEFAULT_IGNORE_DIRS + \ + list(filter(lambda d: f"**/{d}", DEFAULT_IGNORE_DIRS)) async def provide_context_items(self) -> List[ContextItem]: filepaths = [] diff --git a/continuedev/src/continuedev/server/meilisearch_server.py b/continuedev/src/continuedev/server/meilisearch_server.py index 286019e1..840a4b77 100644 --- a/continuedev/src/continuedev/server/meilisearch_server.py +++ b/continuedev/src/continuedev/server/meilisearch_server.py @@ -6,9 +6,11 @@ from meilisearch_python_async import Client from ..libs.util.paths import getServerFolderPath -def ensure_meilisearch_installed(): +def ensure_meilisearch_installed() -> bool: """ Checks if MeiliSearch is installed. + + Returns a bool indicating whether it was installed to begin with. """ serverPath = getServerFolderPath() meilisearchPath = os.path.join(serverPath, "meilisearch") @@ -29,7 +31,7 @@ def ensure_meilisearch_installed(): # Clear the meilisearch binary if meilisearchPath in existing_paths: os.remove(meilisearchPath) - non_existing_paths.remove(meilisearchPath) + existing_paths.remove(meilisearchPath) # Clear the existing directories for p in existing_paths: @@ -40,6 +42,10 @@ def ensure_meilisearch_installed(): subprocess.run( f"curl -L https://install.meilisearch.com | sh", shell=True, check=True, cwd=serverPath) + return False + + return True + async def check_meilisearch_running() -> bool: """ @@ -68,10 +74,10 @@ async def start_meilisearch(): serverPath = getServerFolderPath() # Check if MeiliSearch is installed, if not download - ensure_meilisearch_installed() + was_already_installed = ensure_meilisearch_installed() # Check if MeiliSearch is running - if not await check_meilisearch_running(): + if not await check_meilisearch_running() or not was_already_installed: print("Starting MeiliSearch...") subprocess.Popen(["./meilisearch"], cwd=serverPath, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT, close_fds=True, start_new_session=True) -- cgit v1.2.3-70-g09d2