debugging improvements
This commit is contained in:
parent
6255932c8c
commit
9f2b6443cf
3 changed files with 15 additions and 14 deletions
|
|
@ -6,6 +6,7 @@ if settings.database_url.startswith("sqlite"):
|
||||||
connect_args = {"check_same_thread": False}
|
connect_args = {"check_same_thread": False}
|
||||||
else:
|
else:
|
||||||
connect_args = {}
|
connect_args = {}
|
||||||
|
|
||||||
engine = create_engine(settings.database_url, connect_args=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")
|
logger.debug("Creating database and tables")
|
||||||
SQLModel.metadata.create_all(engine)
|
SQLModel.metadata.create_all(engine)
|
||||||
logger.debug("Database and tables created")
|
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():
|
def get_session():
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,7 @@
|
||||||
# This file is used by lc-serve to load the mounted app and serve it.
|
# 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
|
configure(log_level="DEBUG")
|
||||||
|
app = setup_app()
|
||||||
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",
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ def setup_static_files(app: FastAPI, static_files_dir: Path):
|
||||||
|
|
||||||
# app = create_app()
|
# app = create_app()
|
||||||
# setup_static_files(app, static_files_dir)
|
# 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."""
|
"""Setup the FastAPI app."""
|
||||||
# get the directory of the current file
|
# get the directory of the current file
|
||||||
if not static_files_dir:
|
if not static_files_dir:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue