feat: read flows from local directory at startup (#1989)
* feat: read flows from local directory at startup * cleanup * add check * fix * fix * fix by endpoint name --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
parent
44121515ed
commit
7abfb0b232
6 changed files with 95 additions and 4 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import json
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
# we need to import tmpdir
|
||||
import tempfile
|
||||
|
|
@ -92,6 +94,12 @@ class Config:
|
|||
result_backend = "redis://localhost:6379/0"
|
||||
|
||||
|
||||
@pytest.fixture(name="load_flows_dir")
|
||||
def load_flows_dir():
|
||||
tempdir = tempfile.TemporaryDirectory()
|
||||
yield tempdir.name
|
||||
|
||||
|
||||
@pytest.fixture(name="distributed_env")
|
||||
def setup_env(monkeypatch):
|
||||
monkeypatch.setenv("LANGFLOW_CACHE_TYPE", "redis")
|
||||
|
|
@ -209,7 +217,7 @@ def json_vector_store():
|
|||
|
||||
|
||||
@pytest.fixture(name="client", autouse=True)
|
||||
def client_fixture(session: Session, monkeypatch, request):
|
||||
def client_fixture(session: Session, monkeypatch, request, load_flows_dir):
|
||||
# Set the database url to a test database
|
||||
if "noclient" in request.keywords:
|
||||
yield
|
||||
|
|
@ -218,6 +226,11 @@ def client_fixture(session: Session, monkeypatch, request):
|
|||
db_path = Path(db_dir) / "test.db"
|
||||
monkeypatch.setenv("LANGFLOW_DATABASE_URL", f"sqlite:///{db_path}")
|
||||
monkeypatch.setenv("LANGFLOW_AUTO_LOGIN", "false")
|
||||
if "load_flows" in request.keywords:
|
||||
shutil.copyfile(pytest.BASIC_EXAMPLE_PATH,
|
||||
os.path.join(load_flows_dir, "c54f9130-f2fa-4a3e-b22a-3856d946351b.json"))
|
||||
monkeypatch.setenv("LANGFLOW_LOAD_FLOWS_PATH", load_flows_dir)
|
||||
monkeypatch.setenv("LANGFLOW_AUTO_LOGIN", "true")
|
||||
|
||||
from langflow.main import create_app
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue