Skip to content

Commit

Permalink
Deprecate the REST/HTTP client (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
aksestok committed Jun 20, 2022
1 parent ff03633 commit 5c2b95d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
7 changes: 4 additions & 3 deletions exabel_data_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import sys
import warnings

from exabel_data_sdk.util.warnings import ExabelDeprecationWarning

from .client.exabel_client import ExabelClient

if sys.version_info.major == 3 and sys.version_info.minor == 6:
import warnings

warnings.warn(
"Python 3.6 is deprecated as of version 3.3.0 of the Exabel Python SDK. Support will be "
"removed in a future release. Please upgrade to Python 3.7 or a newer release of Python.",
FutureWarning,
ExabelDeprecationWarning,
)
10 changes: 10 additions & 0 deletions exabel_data_sdk/client/api/api_client/http/base_http_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import warnings
from typing import Optional, TypeVar, overload

import requests
Expand All @@ -9,6 +10,7 @@
from exabel_data_sdk.client.api.data_classes.request_error import RequestError
from exabel_data_sdk.client.api.error_handler import http_status_to_error_type
from exabel_data_sdk.client.client_config import ClientConfig
from exabel_data_sdk.util.warnings import ExabelDeprecationWarning

TMessage = TypeVar("TMessage", bound=Message)

Expand All @@ -35,6 +37,14 @@ def _request(self, method: str, url: str, response_proto: None, body: Message =
def _request(
self, method: str, url: str, response_proto: Optional[TMessage], body: Message = None
) -> Optional[TMessage]:
warnings.warn(
"The HTTP/REST client is deprecated as of version 3.7.0 of the Exabel Python SDK. "
"Support will be removed in a future release. Please run scripts without the "
'"--use-json" flag, or instantiate the ExabelClient with use_json = False.',
ExabelDeprecationWarning,
stacklevel=2,
)

response = requests.request(
method,
f"https://{self.host}/v1/{url}",
Expand Down
1 change: 1 addition & 0 deletions exabel_data_sdk/scripts/command_line_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def setup_logging(
) -> None:
"""Setup logging"""
logging.basicConfig(format=format, level=level, stream=stream)
logging.captureWarnings(True)

@abc.abstractmethod
def run(self) -> None:
Expand Down
2 changes: 2 additions & 0 deletions exabel_data_sdk/util/warnings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ExabelDeprecationWarning(FutureWarning):
"""Warning for deprecated features that will be removed or altered in the future."""

0 comments on commit 5c2b95d

Please sign in to comment.