From 6be29f5bed5627a72dbedc9a88c5c81345d0eebb Mon Sep 17 00:00:00 2001 From: Deshraj Yadav Date: Sun, 24 Dec 2023 16:33:53 +0530 Subject: [PATCH] [Bug Fix] Fix `FileExistsError` when using Embedchain in multithreading setting (#1056) --- embedchain/cli.py | 4 ++-- embedchain/client.py | 4 +--- embedchain/telemetry/posthog.py | 4 +--- pyproject.toml | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/embedchain/cli.py b/embedchain/cli.py index 7063b81e..17c3d6be 100644 --- a/embedchain/cli.py +++ b/embedchain/cli.py @@ -356,7 +356,7 @@ def deploy_render(): console.print(f"❌ [bold red]An error occurred: {e}[/bold red]") except FileNotFoundError: console.print( - "❌ [bold red]'render' command not found. Please ensure Render CLI is installed and in your PATH.[/bold red]" + "❌ [bold red]'render' command not found. Please ensure Render CLI is installed and in your PATH.[/bold red]" # noqa:E501 ) @@ -371,7 +371,7 @@ def deploy_gradio_app(): console.print(f"❌ [bold red]An error occurred: {e}[/bold red]") except FileNotFoundError: console.print( - "❌ [bold red]'gradio' command not found. Please ensure Gradio CLI is installed and in your PATH.[/bold red]" + "❌ [bold red]'gradio' command not found. Please ensure Gradio CLI is installed and in your PATH.[/bold red]" # noqa:E501 ) diff --git a/embedchain/client.py b/embedchain/client.py index 7303aafe..416e3777 100644 --- a/embedchain/client.py +++ b/embedchain/client.py @@ -39,9 +39,7 @@ class Client: :return: user id :rtype: str """ - if not os.path.exists(CONFIG_DIR): - os.makedirs(CONFIG_DIR) - + os.makedirs(CONFIG_DIR, exist_ok=True) if os.path.exists(CONFIG_FILE): with open(CONFIG_FILE, "r") as f: data = json.load(f) diff --git a/embedchain/telemetry/posthog.py b/embedchain/telemetry/posthog.py index 174c87ac..ac2c5594 100644 --- a/embedchain/telemetry/posthog.py +++ b/embedchain/telemetry/posthog.py @@ -39,9 +39,7 @@ class AnonymousTelemetry: posthog_logger.disabled = True def _get_user_id(self): - if not os.path.exists(CONFIG_DIR): - os.makedirs(CONFIG_DIR) - + os.makedirs(CONFIG_DIR, exist_ok=True) if os.path.exists(CONFIG_FILE): with open(CONFIG_FILE, "r") as f: data = json.load(f) diff --git a/pyproject.toml b/pyproject.toml index 86fc4d53..a45942b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "embedchain" -version = "0.1.42" +version = "0.1.43" description = "Data platform for LLMs - Load, index, retrieve and sync any unstructured data" authors = [ "Taranjeet Singh ",