feat: Add support for Python 3.13 (#6685)
This commit is contained in:
parent
60b2e76283
commit
41edba73c9
18 changed files with 910 additions and 400 deletions
|
|
@ -597,8 +597,8 @@ async def load_flows_from_directory() -> None:
|
|||
# Ensure that the default folder exists for this user
|
||||
_ = await get_or_create_default_folder(session, user.id)
|
||||
|
||||
async for file_path in anyio.Path(flows_path).iterdir():
|
||||
if not await file_path.is_file() or file_path.suffix != ".json":
|
||||
for file_path in await asyncio.to_thread(Path(flows_path).iterdir):
|
||||
if not await anyio.Path(file_path).is_file() or file_path.suffix != ".json":
|
||||
continue
|
||||
logger.info(f"Loading flow from file: {file_path.name}")
|
||||
async with async_open(str(file_path), "r", encoding="utf-8") as f:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
import anyio
|
||||
from aiofile import async_open
|
||||
from loguru import logger
|
||||
|
|
@ -88,7 +91,9 @@ class LocalStorageService(StorageService):
|
|||
msg = f"Flow {flow_id} directory does not exist."
|
||||
raise FileNotFoundError(msg)
|
||||
|
||||
files = [file.name async for file in folder_path.iterdir() if await file.is_file()]
|
||||
files = [
|
||||
file.name for file in await asyncio.to_thread(Path(folder_path).iterdir) if await anyio.Path(file).is_file()
|
||||
]
|
||||
logger.info(f"Listed {len(files)} files in flow {flow_id}.")
|
||||
return files
|
||||
|
||||
|
|
|
|||
|
|
@ -108,14 +108,15 @@ def execute_function(code, function_name, *args, **kwargs):
|
|||
)
|
||||
function_code.parent = None
|
||||
code_obj = compile(ast.Module(body=[function_code], type_ignores=[]), "<string>", "exec")
|
||||
exec_locals = dict(locals())
|
||||
try:
|
||||
exec(code_obj, exec_globals, locals())
|
||||
exec(code_obj, exec_globals, exec_locals)
|
||||
except Exception as exc:
|
||||
msg = "Function string does not contain a function"
|
||||
raise ValueError(msg) from exc
|
||||
|
||||
# Add the function to the exec_globals dictionary
|
||||
exec_globals[function_name] = locals()[function_name]
|
||||
exec_globals[function_name] = exec_locals[function_name]
|
||||
|
||||
return exec_globals[function_name](*args, **kwargs)
|
||||
|
||||
|
|
@ -152,9 +153,10 @@ def create_function(code, function_name):
|
|||
)
|
||||
function_code.parent = None
|
||||
code_obj = compile(ast.Module(body=[function_code], type_ignores=[]), "<string>", "exec")
|
||||
exec_locals = dict(locals())
|
||||
with contextlib.suppress(Exception):
|
||||
exec(code_obj, exec_globals, locals())
|
||||
exec_globals[function_name] = locals()[function_name]
|
||||
exec(code_obj, exec_globals, exec_locals)
|
||||
exec_globals[function_name] = exec_locals[function_name]
|
||||
|
||||
# Return a function that imports necessary modules and calls the target function
|
||||
def wrapped_function(*args, **kwargs):
|
||||
|
|
@ -306,8 +308,9 @@ def build_class_constructor(compiled_class, exec_globals, class_name):
|
|||
Returns:
|
||||
Constructor function for the class
|
||||
"""
|
||||
exec(compiled_class, exec_globals, locals())
|
||||
exec_globals[class_name] = locals()[class_name]
|
||||
exec_locals = dict(locals())
|
||||
exec(compiled_class, exec_globals, exec_locals)
|
||||
exec_globals[class_name] = exec_locals[class_name]
|
||||
|
||||
# Return a function that imports necessary modules and creates an instance of the target class
|
||||
def build_custom_class():
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
name = "langflow-base"
|
||||
version = "0.1.5"
|
||||
description = "A Python package with a built-in web application"
|
||||
requires-python = ">=3.10,<3.13"
|
||||
requires-python = ">=3.10,<3.14"
|
||||
license = "MIT"
|
||||
keywords = ["nlp", "langchain", "openai", "gpt", "gui"]
|
||||
readme = "README.md"
|
||||
|
|
@ -37,7 +37,7 @@ dependencies = [
|
|||
"cachetools>=5.5.0,<6.0.0",
|
||||
"platformdirs>=4.2.0,<5.0.0",
|
||||
"python-multipart>=0.0.12,<1.0.0",
|
||||
"orjson==3.10.0",
|
||||
"orjson==3.10.15",
|
||||
"alembic>=1.13.0,<2.0.0",
|
||||
"passlib>=1.7.4,<2.0.0",
|
||||
"bcrypt==4.0.1",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue