feat: add auto_save option to Settings and CLI (#3386)
* feat: Add auto save feature in Langflow run function. * feat: Add auto_save field to ConfigResponse model. * refactor: Move logger import to the top in __main__.py and update auto save option help message. * refactor: Update variable names for auto save to auto saving.
This commit is contained in:
parent
93e0ffb05e
commit
c00e687ec1
4 changed files with 17 additions and 2 deletions
|
|
@ -20,13 +20,13 @@ from rich.panel import Panel
|
||||||
from rich.table import Table
|
from rich.table import Table
|
||||||
from sqlmodel import select
|
from sqlmodel import select
|
||||||
|
|
||||||
|
from langflow.logging.logger import configure, logger
|
||||||
from langflow.main import setup_app
|
from langflow.main import setup_app
|
||||||
from langflow.services.database.models.folder.utils import create_default_folder_if_it_doesnt_exist
|
from langflow.services.database.models.folder.utils import create_default_folder_if_it_doesnt_exist
|
||||||
from langflow.services.database.utils import session_getter
|
from langflow.services.database.utils import session_getter
|
||||||
from langflow.services.deps import get_db_service, get_settings_service, session_scope
|
from langflow.services.deps import get_db_service, get_settings_service, session_scope
|
||||||
from langflow.services.settings.constants import DEFAULT_SUPERUSER
|
from langflow.services.settings.constants import DEFAULT_SUPERUSER
|
||||||
from langflow.services.utils import initialize_services
|
from langflow.services.utils import initialize_services
|
||||||
from langflow.logging.logger import configure, logger
|
|
||||||
from langflow.utils.util import update_settings
|
from langflow.utils.util import update_settings
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
|
|
@ -120,6 +120,11 @@ def run(
|
||||||
help="Enables the store features.",
|
help="Enables the store features.",
|
||||||
envvar="LANGFLOW_STORE",
|
envvar="LANGFLOW_STORE",
|
||||||
),
|
),
|
||||||
|
auto_saving: bool = typer.Option(
|
||||||
|
True,
|
||||||
|
help="Defines if the auto save is enabled.",
|
||||||
|
envvar="LANGFLOW_AUTO_SAVING",
|
||||||
|
),
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Run Langflow.
|
Run Langflow.
|
||||||
|
|
@ -137,6 +142,7 @@ def run(
|
||||||
cache=cache,
|
cache=cache,
|
||||||
components_path=components_path,
|
components_path=components_path,
|
||||||
store=store,
|
store=store,
|
||||||
|
auto_saving=auto_saving,
|
||||||
)
|
)
|
||||||
# create path object if path is provided
|
# create path object if path is provided
|
||||||
static_files_dir: Optional[Path] = Path(path) if path else None
|
static_files_dir: Optional[Path] = Path(path) if path else None
|
||||||
|
|
|
||||||
|
|
@ -330,3 +330,4 @@ class FlowDataRequest(BaseModel):
|
||||||
|
|
||||||
class ConfigResponse(BaseModel):
|
class ConfigResponse(BaseModel):
|
||||||
frontend_timeout: int
|
frontend_timeout: int
|
||||||
|
auto_saving: bool
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,10 @@ class Settings(BaseSettings):
|
||||||
vertex_builds_storage_enabled: bool = True
|
vertex_builds_storage_enabled: bool = True
|
||||||
"""If set to True, Langflow will keep track of each vertex builds (outputs) in the UI for any flow."""
|
"""If set to True, Langflow will keep track of each vertex builds (outputs) in the UI for any flow."""
|
||||||
|
|
||||||
|
# Config
|
||||||
|
auto_saving: bool = True
|
||||||
|
"""If set to True, Langflow will auto save flows."""
|
||||||
|
|
||||||
@field_validator("dev")
|
@field_validator("dev")
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_dev(cls, value):
|
def set_dev(cls, value):
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
from docstring_parser import parse
|
from docstring_parser import parse
|
||||||
|
|
||||||
|
from langflow.logging.logger import logger
|
||||||
from langflow.schema import Data
|
from langflow.schema import Data
|
||||||
from langflow.services.deps import get_settings_service
|
from langflow.services.deps import get_settings_service
|
||||||
from langflow.template.frontend_node.constants import FORCE_SHOW_FIELDS
|
from langflow.template.frontend_node.constants import FORCE_SHOW_FIELDS
|
||||||
from langflow.utils import constants
|
from langflow.utils import constants
|
||||||
from langflow.logging.logger import logger
|
|
||||||
|
|
||||||
|
|
||||||
def unescape_string(s: str):
|
def unescape_string(s: str):
|
||||||
|
|
@ -427,6 +427,7 @@ def update_settings(
|
||||||
remove_api_keys: bool = False,
|
remove_api_keys: bool = False,
|
||||||
components_path: Optional[Path] = None,
|
components_path: Optional[Path] = None,
|
||||||
store: bool = True,
|
store: bool = True,
|
||||||
|
auto_saving: bool = True,
|
||||||
):
|
):
|
||||||
"""Update the settings from a config file."""
|
"""Update the settings from a config file."""
|
||||||
from langflow.services.utils import initialize_settings_service
|
from langflow.services.utils import initialize_settings_service
|
||||||
|
|
@ -450,6 +451,9 @@ def update_settings(
|
||||||
if not store:
|
if not store:
|
||||||
logger.debug("Setting store to False")
|
logger.debug("Setting store to False")
|
||||||
settings_service.settings.update_settings(store=False)
|
settings_service.settings.update_settings(store=False)
|
||||||
|
if not auto_saving:
|
||||||
|
logger.debug("Setting auto_saving to False")
|
||||||
|
settings_service.settings.update_settings(auto_saving=False)
|
||||||
|
|
||||||
|
|
||||||
def is_class_method(func, cls):
|
def is_class_method(func, cls):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue