debugging improvements

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-02 16:11:51 -03:00
commit 9f2b6443cf
3 changed files with 15 additions and 14 deletions

View file

@ -6,6 +6,7 @@ if settings.database_url.startswith("sqlite"):
connect_args = {"check_same_thread": False}
else:
connect_args = {}
engine = create_engine(settings.database_url, connect_args=connect_args)
@ -13,6 +14,15 @@ def create_db_and_tables():
logger.debug("Creating database and tables")
SQLModel.metadata.create_all(engine)
logger.debug("Database and tables created")
# Now check if the table Flow exists, if not, something went wrong
# and we need to create the tables again.
from sqlalchemy import inspect
inspector = inspect(engine)
if "flow" not in inspector.get_table_names():
logger.error("Something went wrong creating the database and tables.")
logger.error("Please check your database settings.")
raise RuntimeError("Something went wrong creating the database and tables.")
def get_session():

View file

@ -1,16 +1,7 @@
# This file is used by lc-serve to load the mounted app and serve it.
from pathlib import Path
from langflow.main import setup_app
from langflow.utils.logger import configure
from fastapi.staticfiles import StaticFiles
from langflow.main import create_app
app = create_app()
path = Path(__file__).parent
static_files_dir = path / "frontend"
app.mount(
"/",
StaticFiles(directory=static_files_dir, html=True),
name="static",
)
configure(log_level="DEBUG")
app = setup_app()

View file

@ -61,7 +61,7 @@ def setup_static_files(app: FastAPI, static_files_dir: Path):
# app = create_app()
# setup_static_files(app, static_files_dir)
def setup_app(static_files_dir: Optional[Path]) -> FastAPI:
def setup_app(static_files_dir: Optional[Path] = None) -> FastAPI:
"""Setup the FastAPI app."""
# get the directory of the current file
if not static_files_dir: