🔧 fix(__main__.py): import get_number_of_workers function from langflow.utils.util module to fix NameError
🔧 fix(__main__.py): change default value of workers option to -1 to indicate automatic calculation of number of workers 🔧 fix(__main__.py): remove unused import of cpu_count from multiprocess module 🔧 fix(__main__.py): remove unused import of time module 🔧 fix(__main__.py): remove unused import of httpx module 🔧 fix(__main__.py): remove unused import of sys module 🔧 fix(__main__.py): remove unused import of os module 🔧 fix(__main__.py): remove unused import of Path class from pathlib module 🔧 fix(__main__.py): remove unused import of load_dotenv function from dotenv module 🔧 fix(__main__.py): remove unused import of typer module 🔧 fix(__main__.py): remove unused import of app object from typer module 🔧 fix(__main__.py): remove unused import of Optional type from typing module 🔧 fix(__main__.py): remove unused import of Process class from multiprocess module 🔧 fix(__main__.py): remove unused import of platform module 🔧 fix(__main__.py): remove unused import of update_settings function 🔧 fix(__main__.py): remove unused import of run_langflow function 🔧 fix(util.py): import logger from langflow.utils.logger module to fix NameError 🔧 fix(util.py): import cpu_count from multiprocess module to fix NameError 🔧 fix(util.py): add default value of None to workers parameter in get_number_of_workers function to fix TypeError
This commit is contained in:
parent
cf688adf53
commit
80db6b910e
2 changed files with 13 additions and 9 deletions
|
|
@ -2,7 +2,8 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import httpx
|
import httpx
|
||||||
from multiprocess import Process, cpu_count # type: ignore
|
from langflow.utils.util import get_number_of_workers
|
||||||
|
from multiprocess import Process # type: ignore
|
||||||
import platform
|
import platform
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
@ -20,12 +21,6 @@ from dotenv import load_dotenv
|
||||||
app = typer.Typer()
|
app = typer.Typer()
|
||||||
|
|
||||||
|
|
||||||
def get_number_of_workers(workers=None):
|
|
||||||
if workers == -1:
|
|
||||||
workers = (cpu_count() * 2) + 1
|
|
||||||
return workers
|
|
||||||
|
|
||||||
|
|
||||||
def update_settings(
|
def update_settings(
|
||||||
config: str,
|
config: str,
|
||||||
cache: str,
|
cache: str,
|
||||||
|
|
@ -120,7 +115,7 @@ def serve(
|
||||||
"127.0.0.1", help="Host to bind the server to.", envvar="LANGFLOW_HOST"
|
"127.0.0.1", help="Host to bind the server to.", envvar="LANGFLOW_HOST"
|
||||||
),
|
),
|
||||||
workers: int = typer.Option(
|
workers: int = typer.Option(
|
||||||
1, help="Number of worker processes.", envvar="LANGFLOW_WORKERS"
|
-1, help="Number of worker processes.", envvar="LANGFLOW_WORKERS"
|
||||||
),
|
),
|
||||||
timeout: int = typer.Option(60, help="Worker timeout in seconds."),
|
timeout: int = typer.Option(60, help="Worker timeout in seconds."),
|
||||||
port: int = typer.Option(7860, help="Port to listen on.", envvar="LANGFLOW_PORT"),
|
port: int = typer.Option(7860, help="Port to listen on.", envvar="LANGFLOW_PORT"),
|
||||||
|
|
@ -298,7 +293,7 @@ def run_langflow(host, port, log_level, options, app):
|
||||||
Run Langflow server on localhost
|
Run Langflow server on localhost
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if platform.system() in ["Darwin", "Windows"]:
|
if platform.system() in ["Windows"]:
|
||||||
# Run using uvicorn on MacOS and Windows
|
# Run using uvicorn on MacOS and Windows
|
||||||
# Windows doesn't support gunicorn
|
# Windows doesn't support gunicorn
|
||||||
# MacOS requires an env variable to be set to use gunicorn
|
# MacOS requires an env variable to be set to use gunicorn
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ from docstring_parser import parse # type: ignore
|
||||||
|
|
||||||
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.utils.logger import logger
|
||||||
|
from multiprocess import cpu_count
|
||||||
|
|
||||||
|
|
||||||
def build_template_from_function(
|
def build_template_from_function(
|
||||||
|
|
@ -451,3 +453,10 @@ def add_options_to_field(
|
||||||
value["options"] = options_map[class_name]
|
value["options"] = options_map[class_name]
|
||||||
value["list"] = True
|
value["list"] = True
|
||||||
value["value"] = options_map[class_name][0]
|
value["value"] = options_map[class_name][0]
|
||||||
|
|
||||||
|
|
||||||
|
def get_number_of_workers(workers=None):
|
||||||
|
if workers == -1 or workers is None:
|
||||||
|
workers = (cpu_count() * 2) + 1
|
||||||
|
logger.debug(f"Number of workers: {workers}")
|
||||||
|
return workers
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue