Skip to content

Commit

Permalink
Added alembic log path as env var change
Browse files Browse the repository at this point in the history
  • Loading branch information
devinbost committed Oct 24, 2024
1 parent 21bdad0 commit 09272dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/backend/base/langflow/services/database/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def __init__(self, settings_service: SettingsService):
self.script_location = langflow_dir / "alembic"
self.alembic_cfg_path = langflow_dir / "alembic.ini"
self.engine = self._create_engine()
if self.settings_service.settings.alembic_log_file.startswith('/'):

Check failure on line 47 in src/backend/base/langflow/services/database/service.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.12)

Ruff (Q000)

src/backend/base/langflow/services/database/service.py:47:71: Q000 Single quotes found but double quotes preferred
# Then, the log file path is overridden by an absolute path, and we should use it directly.
self.alembic_log_path = Path(self.settings_service.settings.alembic_log_file)
else:
self.alembic_log_path = Path(f"{langflow_dir}/{self.settings_service.settings.alembic_log_file}")

def reload_engine(self) -> None:
self.engine = self._create_engine()
Expand Down Expand Up @@ -178,7 +183,7 @@ def run_migrations(self, *, fix=False) -> None:
# which is a buffer
# I don't want to output anything
# subprocess.DEVNULL is an int
with (self.script_location / "alembic.log").open("w", encoding="utf-8") as buffer:
with self.alembic_log_path.open("w", encoding="utf-8") as buffer:
alembic_cfg = Config(stdout=buffer)
# alembic_cfg.attributes["connection"] = session
alembic_cfg.set_main_option("script_location", str(self.script_location))
Expand Down
2 changes: 2 additions & 0 deletions src/backend/base/langflow/services/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class Settings(BaseSettings):
"""The log level for Langflow."""
log_file: str | None = "logs/langflow.log"
"""The path to log file for Langflow."""
alembic_log_file: str | None = "alembic/alembic.log"
"""The path to log file for Alembic for SQLAlchemy."""
frontend_path: str | None = None
"""The path to the frontend directory containing build files. This is for development purposes only.."""
open_browser: bool = False
Expand Down

0 comments on commit 09272dc

Please sign in to comment.