From e8401069493ced5a8892a29896804eb926a512e3 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Mon, 18 Nov 2024 13:41:18 +0100 Subject: [PATCH] fix(backend): Resolve Pydantic warning about missing `secrets_dir` (#8692) - Remove `secrets_dir` and other references to `get_secrets_path()` - Remove unused `get_config_path()` Follow-up to #8521, which removed the `secrets` dir but not the references to it. --- autogpt_platform/backend/backend/util/data.py | 8 -------- autogpt_platform/backend/backend/util/settings.py | 11 +---------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/autogpt_platform/backend/backend/util/data.py b/autogpt_platform/backend/backend/util/data.py index d9659623f735..d77d4cc7899d 100644 --- a/autogpt_platform/backend/backend/util/data.py +++ b/autogpt_platform/backend/backend/util/data.py @@ -3,14 +3,6 @@ import sys -def get_secrets_path() -> pathlib.Path: - return get_data_path() / "secrets" - - -def get_config_path() -> pathlib.Path: - return get_data_path() - - def get_frontend_path() -> pathlib.Path: if getattr(sys, "frozen", False): # The application is frozen diff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.py index 6ac528fef01f..7383c3d10584 100644 --- a/autogpt_platform/backend/backend/util/settings.py +++ b/autogpt_platform/backend/backend/util/settings.py @@ -11,7 +11,7 @@ SettingsConfigDict, ) -from backend.util.data import get_data_path, get_secrets_path +from backend.util.data import get_data_path T = TypeVar("T", bound=BaseSettings) @@ -272,7 +272,6 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings): # Add more secret fields as needed model_config = SettingsConfigDict( - secrets_dir=get_secrets_path(), env_file=".env", env_file_encoding="utf-8", extra="allow", @@ -299,11 +298,3 @@ def save(self) -> None: with open(config_path, "w") as f: json.dump(config_to_save, f, indent=2) self.config.clear_updates() - - # Save updated secrets to individual files - secrets_dir = get_secrets_path() - for key in self.secrets.updated_fields: - secret_file = os.path.join(secrets_dir, key) - with open(secret_file, "w") as f: - f.write(str(getattr(self.secrets, key))) - self.secrets.clear_updates()