Skip to content

Commit

Permalink
[FIX] Optionally allow the client to disable SSL verification for tes…
Browse files Browse the repository at this point in the history
…ting purposes

GitOrigin-RevId: 02d9665ae06ad74399ee9b07520d955049b348be
  • Loading branch information
rrx committed Sep 23, 2024
1 parent 847bd2d commit 26b3e9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/gretel_client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def _get_api_client_generic(
config_cls: Type[ConfigT],
max_retry_attempts: int = 3,
backoff_factor: float = 1,
verify_ssl: bool = True,
*,
default_headers: Optional[dict[str, str]] = None,
) -> ClientT: ...
Expand Down Expand Up @@ -491,6 +492,7 @@ def _get_api_client_generic(
config_cls: Type[ConfigT],
max_retry_attempts: int = 3,
backoff_factor: float = 1,
verify_ssl: bool = True,
*,
default_headers: Optional[dict[str, str]] = None,
) -> ClientT:
Expand Down Expand Up @@ -523,6 +525,7 @@ def _get_api_client_generic(
max_retry_attempts=max_retry_attempts,
backoff_factor=backoff_factor,
)
configuration.verify_ssl = verify_ssl
client = client_cls(configuration, **client_kwargs)
client.default_headers.update(_metrics_headers() | (default_headers or {}))
return client
Expand Down Expand Up @@ -591,6 +594,7 @@ def _get_api_client_generic(
config_cls: Type[ConfigT],
max_retry_attempts: int = 3,
backoff_factor: float = 1,
verify_ssl: bool = True,
*,
default_headers: Optional[dict[str, str]] = None,
) -> ClientT:
Expand All @@ -599,6 +603,7 @@ def _get_api_client_generic(
config_cls=config_cls,
max_retry_attempts=max_retry_attempts,
backoff_factor=backoff_factor,
verify_ssl=verify_ssl,
default_headers=default_headers,
)

Expand Down Expand Up @@ -628,6 +633,7 @@ def _get_api_client_generic(
config_cls: Type[ConfigT],
max_retry_attempts: int = 3,
backoff_factor: float = 1,
verify_ssl: bool = True,
*,
default_headers: Optional[dict[str, str]] = None,
) -> ClientT:
Expand All @@ -637,6 +643,7 @@ def _get_api_client_generic(
config_cls=config_cls,
max_retry_attempts=max_retry_attempts,
backoff_factor=backoff_factor,
verify_ssl=verify_ssl,
default_headers=all_headers,
)

Expand Down
4 changes: 3 additions & 1 deletion src/gretel_client/inference_api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from gretel_client.config import ClientConfig, configure_session, get_session_config
from gretel_client.rest.api_client import ApiClient
from gretel_client.rest.configuration import Configuration

MODELS_API_PATH = "/v1/inference/models"

Expand Down Expand Up @@ -147,6 +148,7 @@ def __init__(
self,
backend_model: Optional[str] = None,
*,
verify_ssl: bool = True,
session: Optional[ClientConfig] = None,
**session_kwargs,
):
Expand All @@ -164,7 +166,7 @@ def __init__(
f"is configured to: {session.default_runner}"
)
self.endpoint = session.endpoint
self._api_client = session._get_api_client()
self._api_client = session._get_api_client(verify_ssl=verify_ssl)
self._available_backend_models = get_full_navigator_model_list(self._api_client)
self.backend_model = backend_model

Expand Down

0 comments on commit 26b3e9e

Please sign in to comment.