From d612abd80a4d6d0c2373a584a56ef9816babb51e Mon Sep 17 00:00:00 2001 From: Mark Kurtz Date: Wed, 17 Jul 2024 20:40:53 -0400 Subject: [PATCH] Add config overrides for protected namespaces to remove warnings for pydantic classes that have model_* params (#1657) * Add config overrides for protected namespaces to remove warnings for pydantic classes that have model_* params * make quality --- src/deepsparse/pipeline_config.py | 5 ++++- src/deepsparse/server/server.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/deepsparse/pipeline_config.py b/src/deepsparse/pipeline_config.py index 3af9a82dd8..f76ba071d4 100644 --- a/src/deepsparse/pipeline_config.py +++ b/src/deepsparse/pipeline_config.py @@ -14,7 +14,7 @@ from typing import Any, Dict, List, Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field from deepsparse.operators.engine_operator import DEEPSPARSE_ENGINE @@ -84,3 +84,6 @@ class PipelineConfig(BaseModel): "into the pipeline as kwargs" ), ) + + # override name spaces due to model_ warnings in pydantic 2.X + model_config = ConfigDict(protected_namespaces=()) diff --git a/src/deepsparse/server/server.py b/src/deepsparse/server/server.py index 0c52efc508..ca9b17caed 100644 --- a/src/deepsparse/server/server.py +++ b/src/deepsparse/server/server.py @@ -20,7 +20,7 @@ from typing import AsyncGenerator, List, Optional, Union import yaml -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict import uvicorn from deepsparse.benchmark.benchmark_pipeline import benchmark_from_pipeline @@ -52,6 +52,9 @@ class CheckReady(BaseModel): class ModelMetaData(BaseModel): model_path: str + # override name spaces due to model_ warnings in pydantic 2.X + model_config = ConfigDict(protected_namespaces=()) + # For deepsparse endpoints, we bind the `predict`` and `predict_from_files` functions to # each of the added routes. As we require access to the pipeline to run inference on