feat: flag to disable transaction and vertex_builds writes (#3031)
* feat: flag to disable transaction and vertex_builds writes * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
811816c8b1
commit
56523a7f2d
2 changed files with 11 additions and 2 deletions
|
|
@ -14,7 +14,7 @@ from langflow.services.database.models.transactions.crud import log_transaction
|
|||
from langflow.services.database.models.vertex_builds.crud import log_vertex_build as crud_log_vertex_build
|
||||
from langflow.services.database.models.vertex_builds.model import VertexBuildBase
|
||||
from langflow.services.database.utils import session_getter
|
||||
from langflow.services.deps import get_db_service
|
||||
from langflow.services.deps import get_db_service, get_settings_service
|
||||
from loguru import logger
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -132,6 +132,8 @@ async def log_transaction(
|
|||
flow_id: Union[str, UUID], source: "Vertex", status, target: Optional["Vertex"] = None, error=None
|
||||
) -> None:
|
||||
try:
|
||||
if not get_settings_service().settings.transactions_storage_enabled:
|
||||
return
|
||||
inputs = _vertex_to_primitive_dict(source)
|
||||
transaction = TransactionBase(
|
||||
vertex_id=source.id,
|
||||
|
|
@ -159,6 +161,8 @@ def log_vertex_build(
|
|||
artifacts: Optional[dict] = None,
|
||||
):
|
||||
try:
|
||||
if not get_settings_service().settings.vertex_builds_storage_enabled:
|
||||
return
|
||||
vertex_build = VertexBuildBase(
|
||||
flow_id=flow_id,
|
||||
id=vertex_id,
|
||||
|
|
@ -166,7 +170,8 @@ def log_vertex_build(
|
|||
params=str(params) if params else None,
|
||||
# ugly hack to get the model dump with weird datatypes
|
||||
data=json.loads(data.model_dump_json()),
|
||||
artifacts=artifacts,
|
||||
# ugly hack to get the model dump with weird datatypes
|
||||
artifacts=json.loads(json.dumps(artifacts, default=str)),
|
||||
)
|
||||
with session_getter(get_db_service()) as session:
|
||||
inserted = crud_log_vertex_build(session, vertex_build)
|
||||
|
|
|
|||
|
|
@ -146,6 +146,10 @@ class Settings(BaseSettings):
|
|||
do_not_track: bool = False
|
||||
"""If set to True, Langflow will not track telemetry."""
|
||||
telemetry_base_url: str = "https://langflow.gateway.scarf.sh"
|
||||
transactions_storage_enabled: bool = True
|
||||
"""If set to True, Langflow will track transactions between flows."""
|
||||
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."""
|
||||
|
||||
@field_validator("user_agent", mode="after")
|
||||
@classmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue