refactor: Update loading.py to ignore Pydantic deprecation warnings
The code changes in loading.py add a filter to ignore Pydantic deprecation warnings when building custom components or components. This refactor improves the code's maintainability and ensures compatibility with the latest Pydantic version.
This commit is contained in:
parent
ddd4ebf4fa
commit
4a546dbab7
1 changed files with 10 additions and 6 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import warnings
|
||||||
from typing import TYPE_CHECKING, Any, Type
|
from typing import TYPE_CHECKING, Any, Type
|
||||||
|
|
||||||
import orjson
|
import orjson
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
from pydantic import PydanticDeprecatedSince20
|
||||||
|
|
||||||
from langflow.custom.eval import eval_custom_component_code
|
from langflow.custom.eval import eval_custom_component_code
|
||||||
from langflow.schema import Data
|
from langflow.schema import Data
|
||||||
|
|
@ -43,6 +45,8 @@ async def instantiate_class(
|
||||||
params_copy = update_params_with_load_from_db_fields(
|
params_copy = update_params_with_load_from_db_fields(
|
||||||
custom_component, params_copy, vertex.load_from_db_fields, fallback_to_env_vars
|
custom_component, params_copy, vertex.load_from_db_fields, fallback_to_env_vars
|
||||||
)
|
)
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20)
|
||||||
if base_type == "custom_components":
|
if base_type == "custom_components":
|
||||||
return await build_custom_component(params=params_copy, custom_component=custom_component)
|
return await build_custom_component(params=params_copy, custom_component=custom_component)
|
||||||
elif base_type == "component":
|
elif base_type == "component":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue