Skip to content

Commit a69ef52

Browse files
authored
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
1 parent a70b087 commit a69ef52

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

clients/python/text_generation/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@
1414

1515
__version__ = "0.6.0"
1616

17+
DEPRECATION_WARNING = (
18+
"`text_generation` clients are deprecated and will be removed in the near future. "
19+
"Please use the `InferenceClient` from the `huggingface_hub` package instead."
20+
)
21+
1722
from text_generation.client import Client, AsyncClient
1823
from text_generation.inference_api import InferenceAPIClient, InferenceAPIAsyncClient

clients/python/text_generation/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import json
22
import requests
3+
import warnings
34

45
from aiohttp import ClientSession, ClientTimeout
56
from pydantic import ValidationError
67
from typing import Dict, Optional, List, AsyncIterator, Iterator, Union
78

9+
from text_generation import DEPRECATION_WARNING
810
from text_generation.types import (
911
StreamResponse,
1012
Response,
@@ -19,6 +21,9 @@
1921
)
2022
from text_generation.errors import parse_error
2123

24+
# emit deprecation warnings
25+
warnings.simplefilter("always", DeprecationWarning)
26+
2227

2328
class Client:
2429
"""Client to make calls to a text-generation-inference instance
@@ -59,6 +64,7 @@ def __init__(
5964
timeout (`int`):
6065
Timeout in seconds
6166
"""
67+
warnings.warn(DEPRECATION_WARNING, DeprecationWarning)
6268
self.base_url = base_url
6369
self.headers = headers
6470
self.cookies = cookies
@@ -449,6 +455,7 @@ def __init__(
449455
timeout (`int`):
450456
Timeout in seconds
451457
"""
458+
warnings.warn(DEPRECATION_WARNING, DeprecationWarning)
452459
self.base_url = base_url
453460
self.headers = headers
454461
self.cookies = cookies

0 commit comments

Comments
 (0)