Release 0.5.0a5 (#1000)
This commit is contained in:
commit
a8f444656b
6 changed files with 41 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "langflow"
|
||||
version = "0.5.0a4"
|
||||
version = "0.5.0a5"
|
||||
description = "A Python package with a built-in web application"
|
||||
authors = ["Logspace <contact@logspace.ai>"]
|
||||
maintainers = [
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from langchain import PromptTemplate
|
||||
from langchain.prompts import PromptTemplate
|
||||
from langchain.chains.base import Chain
|
||||
from langchain.document_loaders.base import BaseLoader
|
||||
from langchain.schema.embeddings import Embeddings
|
||||
|
|
@ -45,7 +45,7 @@ DEFAULT_CUSTOM_COMPONENT_CODE = """from langflow import CustomComponent
|
|||
|
||||
from langchain.llms.base import BaseLLM
|
||||
from langchain.chains import LLMChain
|
||||
from langchain import PromptTemplate
|
||||
from langchain.prompts import PromptTemplate
|
||||
from langchain.schema import Document
|
||||
|
||||
import requests
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import importlib
|
||||
from typing import Any, Type
|
||||
|
||||
from langchain import PromptTemplate
|
||||
from langchain.prompts import PromptTemplate
|
||||
from langchain.agents import Agent
|
||||
from langchain.base_language import BaseLanguageModel
|
||||
from langchain.chains.base import Chain
|
||||
|
|
|
|||
|
|
@ -58,6 +58,27 @@ class DatabaseService(Service):
|
|||
with Session(self.engine) as session:
|
||||
yield session
|
||||
|
||||
def migrate_flows_if_auto_login(self):
|
||||
# if auto_login is enabled, we need to migrate the flows
|
||||
# to the default superuser if they don't have a user id
|
||||
# associated with them
|
||||
settings_service = get_settings_service()
|
||||
if settings_service.auth_settings.AUTO_LOGIN:
|
||||
with Session(self.engine) as session:
|
||||
flows = (
|
||||
session.query(models.Flow)
|
||||
.filter(models.Flow.user_id == None) # noqa
|
||||
.all()
|
||||
)
|
||||
if flows:
|
||||
logger.debug("Migrating flows to default superuser")
|
||||
username = settings_service.auth_settings.SUPERUSER
|
||||
user = get_user_by_username(session, username)
|
||||
for flow in flows:
|
||||
flow.user_id = user.id
|
||||
session.commit()
|
||||
logger.debug("Flows migrated successfully")
|
||||
|
||||
def check_schema_health(self) -> bool:
|
||||
inspector = inspect(self.engine)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from langflow.services.settings.constants import (
|
|||
DEFAULT_SUPERUSER_PASSWORD,
|
||||
)
|
||||
from sqlmodel import Session
|
||||
from .getters import get_session, get_settings_service
|
||||
from .getters import get_db_service, get_session, get_settings_service
|
||||
from loguru import logger
|
||||
|
||||
|
||||
|
|
@ -54,8 +54,15 @@ def get_or_create_super_user(session: Session, username, password, is_default):
|
|||
logger.debug("Creating default superuser.")
|
||||
else:
|
||||
logger.debug("Creating superuser.")
|
||||
|
||||
return create_super_user(username, password, db=session)
|
||||
try:
|
||||
return create_super_user(username, password, db=session)
|
||||
except Exception as exc:
|
||||
if "UNIQUE constraint failed: user.username" in str(exc):
|
||||
# This is to deal with workers running this
|
||||
# at startup and trying to create the superuser
|
||||
# at the same time.
|
||||
logger.debug("Superuser already exists.")
|
||||
return None
|
||||
|
||||
|
||||
def setup_superuser(settings_service, session: Session):
|
||||
|
|
@ -193,3 +200,8 @@ def initialize_services():
|
|||
setup_superuser(
|
||||
service_manager.get(ServiceType.SETTINGS_SERVICE), next(get_session())
|
||||
)
|
||||
try:
|
||||
get_db_service().migrate_flows_if_auto_login()
|
||||
except Exception as exc:
|
||||
logger.error(f"Error migrating flows: {exc}")
|
||||
raise RuntimeError("Error migrating flows") from exc
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ from langflow.interface.custom.custom_component import CustomComponent
|
|||
|
||||
from langchain.llms.base import BaseLLM
|
||||
from langchain.chains import LLMChain
|
||||
from langchain import PromptTemplate
|
||||
from langchain.prompts import PromptTemplate
|
||||
from langchain.schema import Document
|
||||
|
||||
import requests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue