Skip to content

Commit

Permalink
fix(backend): Resolve Pydantic warning about missing secrets_dir (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Pwuts authored Nov 18, 2024
1 parent 6c109ad commit e840106
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
8 changes: 0 additions & 8 deletions autogpt_platform/backend/backend/util/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions autogpt_platform/backend/backend/util/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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",
Expand All @@ -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()

0 comments on commit e840106

Please sign in to comment.