feat: Add alembic log path as env var change (#4272)
* Added alembic log path as env var change * [autofix.ci] apply automated fixes * Improved platform independence of path check * fix: arg-type mypy error --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Ítalo Johnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
parent
924e02f46d
commit
fb0084d478
2 changed files with 12 additions and 1 deletions
|
|
@ -44,6 +44,15 @@ class DatabaseService(Service):
|
||||||
self.script_location = langflow_dir / "alembic"
|
self.script_location = langflow_dir / "alembic"
|
||||||
self.alembic_cfg_path = langflow_dir / "alembic.ini"
|
self.alembic_cfg_path = langflow_dir / "alembic.ini"
|
||||||
self.engine = self._create_engine()
|
self.engine = self._create_engine()
|
||||||
|
alembic_log_file = self.settings_service.settings.alembic_log_file
|
||||||
|
|
||||||
|
# Check if the provided path is absolute, cross-platform.
|
||||||
|
if Path(alembic_log_file).is_absolute():
|
||||||
|
# Use the absolute path directly.
|
||||||
|
self.alembic_log_path = Path(alembic_log_file)
|
||||||
|
else:
|
||||||
|
# Construct the path using the langflow directory.
|
||||||
|
self.alembic_log_path = Path(langflow_dir) / alembic_log_file
|
||||||
|
|
||||||
def reload_engine(self) -> None:
|
def reload_engine(self) -> None:
|
||||||
self.engine = self._create_engine()
|
self.engine = self._create_engine()
|
||||||
|
|
@ -178,7 +187,7 @@ class DatabaseService(Service):
|
||||||
# which is a buffer
|
# which is a buffer
|
||||||
# I don't want to output anything
|
# I don't want to output anything
|
||||||
# subprocess.DEVNULL is an int
|
# 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 = Config(stdout=buffer)
|
||||||
# alembic_cfg.attributes["connection"] = session
|
# alembic_cfg.attributes["connection"] = session
|
||||||
alembic_cfg.set_main_option("script_location", str(self.script_location))
|
alembic_cfg.set_main_option("script_location", str(self.script_location))
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,8 @@ class Settings(BaseSettings):
|
||||||
"""The log level for Langflow."""
|
"""The log level for Langflow."""
|
||||||
log_file: str | None = "logs/langflow.log"
|
log_file: str | None = "logs/langflow.log"
|
||||||
"""The path to log file for Langflow."""
|
"""The path to log file for Langflow."""
|
||||||
|
alembic_log_file: str = "alembic/alembic.log"
|
||||||
|
"""The path to log file for Alembic for SQLAlchemy."""
|
||||||
frontend_path: str | None = None
|
frontend_path: str | None = None
|
||||||
"""The path to the frontend directory containing build files. This is for development purposes only.."""
|
"""The path to the frontend directory containing build files. This is for development purposes only.."""
|
||||||
open_browser: bool = False
|
open_browser: bool = False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue