Skip to content

Commit cfe6ce4

Browse files
committed
fix: suppress LangChainDeprecationWarning messages
1 parent d38e79b commit cfe6ce4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/backend/base/langflow/utils/validate.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import ast
22
import contextlib
33
import importlib
4+
import warnings
45
from types import FunctionType
56
from typing import Optional, Union
67

8+
from langchain_core._api.deprecation import LangChainDeprecationWarning
79
from loguru import logger
810
from pydantic import ValidationError
911

@@ -221,9 +223,11 @@ def prepare_global_scope(code, module):
221223
raise ModuleNotFoundError(msg) from e
222224
elif isinstance(node, ast.ImportFrom) and node.module is not None:
223225
try:
224-
imported_module = importlib.import_module(node.module)
225-
for alias in node.names:
226-
exec_globals[alias.name] = getattr(imported_module, alias.name)
226+
with warnings.catch_warnings():
227+
warnings.simplefilter("ignore", LangChainDeprecationWarning)
228+
imported_module = importlib.import_module(node.module)
229+
for alias in node.names:
230+
exec_globals[alias.name] = getattr(imported_module, alias.name)
227231
except ModuleNotFoundError as e:
228232
msg = f"Module {node.module} not found. Please install it and try again"
229233
raise ModuleNotFoundError(msg) from e

0 commit comments

Comments
 (0)