"...git@developer.sourcefind.cn:OpenDAS/pytorch3d.git" did not exist on "9fc661f8b325142323b1925109ccf87ebb5904f2"
Unverified Commit a69ef52c authored by drbh's avatar drbh Committed by GitHub
Browse files

feat: add deprecation warning to clients (#1855)

This PR adds a deprecation warning to the clients and points users to
the https://github.com/huggingface/huggingface_hub
parent a70b087e
...@@ -14,5 +14,10 @@ ...@@ -14,5 +14,10 @@
__version__ = "0.6.0" __version__ = "0.6.0"
DEPRECATION_WARNING = (
"`text_generation` clients are deprecated and will be removed in the near future. "
"Please use the `InferenceClient` from the `huggingface_hub` package instead."
)
from text_generation.client import Client, AsyncClient from text_generation.client import Client, AsyncClient
from text_generation.inference_api import InferenceAPIClient, InferenceAPIAsyncClient from text_generation.inference_api import InferenceAPIClient, InferenceAPIAsyncClient
import json import json
import requests import requests
import warnings
from aiohttp import ClientSession, ClientTimeout from aiohttp import ClientSession, ClientTimeout
from pydantic import ValidationError from pydantic import ValidationError
from typing import Dict, Optional, List, AsyncIterator, Iterator, Union from typing import Dict, Optional, List, AsyncIterator, Iterator, Union
from text_generation import DEPRECATION_WARNING
from text_generation.types import ( from text_generation.types import (
StreamResponse, StreamResponse,
Response, Response,
...@@ -19,6 +21,9 @@ from text_generation.types import ( ...@@ -19,6 +21,9 @@ from text_generation.types import (
) )
from text_generation.errors import parse_error from text_generation.errors import parse_error
# emit deprecation warnings
warnings.simplefilter("always", DeprecationWarning)
class Client: class Client:
"""Client to make calls to a text-generation-inference instance """Client to make calls to a text-generation-inference instance
...@@ -59,6 +64,7 @@ class Client: ...@@ -59,6 +64,7 @@ class Client:
timeout (`int`): timeout (`int`):
Timeout in seconds Timeout in seconds
""" """
warnings.warn(DEPRECATION_WARNING, DeprecationWarning)
self.base_url = base_url self.base_url = base_url
self.headers = headers self.headers = headers
self.cookies = cookies self.cookies = cookies
...@@ -449,6 +455,7 @@ class AsyncClient: ...@@ -449,6 +455,7 @@ class AsyncClient:
timeout (`int`): timeout (`int`):
Timeout in seconds Timeout in seconds
""" """
warnings.warn(DEPRECATION_WARNING, DeprecationWarning)
self.base_url = base_url self.base_url = base_url
self.headers = headers self.headers = headers
self.cookies = cookies self.cookies = cookies
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment