Skip to content

Commit ea19514

Browse files
committed
Add http_transport_retries parameter to Groundlight class
1 parent 6a16f78 commit ea19514

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/groundlight/client.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
PaginatedImageQueryList,
3838
)
3939
from urllib3.exceptions import InsecureRequestWarning
40+
from urllib3.util.retry import Retry
4041

4142
from groundlight.binary_labels import Label, convert_internal_label_to_display
4243
from groundlight.config import API_TOKEN_MISSING_HELP_MESSAGE, API_TOKEN_VARIABLE_NAME, DISABLE_TLS_VARIABLE_NAME
@@ -133,26 +134,31 @@ def __init__(
133134
endpoint: Optional[str] = None,
134135
api_token: Optional[str] = None,
135136
disable_tls_verification: Optional[bool] = None,
137+
http_transport_retries: Optional[Union[int, Retry]] = None,
136138
):
137139
"""
138140
Initialize a new Groundlight client instance.
139141
140142
:param endpoint: Optional custom API endpoint URL. If not specified, uses the default Groundlight endpoint.
141143
:param api_token: Authentication token for API access.
142-
If not provided, will attempt to read from the "GROUNDLIGHT_API_TOKEN" environment variable.
144+
If not provided, will attempt to read from the "GROUNDLIGHT_API_TOKEN" environment variable.
143145
:param disable_tls_verification: If True, disables SSL/TLS certificate verification for API calls.
144-
When not specified, checks the "DISABLE_TLS_VERIFY" environment variable
145-
(1=disable, 0=enable). Certificate verification is enabled by default.
146+
When not specified, checks the "DISABLE_TLS_VERIFY" environment variable (1=disable, 0=enable).
147+
Certificate verification is enabled by default.
146148
147-
Warning: Only disable verification when connecting to a Groundlight Edge
148-
Endpoint using self-signed certificates. For security, always keep
149-
verification enabled when using the Groundlight cloud service.
149+
Warning: Only disable verification when connecting to a Groundlight Edge Endpoint using self-signed
150+
certificates. For security, always keep verification enabled when using the Groundlight cloud service.
151+
:param http_transport_retries: Overrides urllib3 `PoolManager` retry policy for HTTP/HTTPS (forwarded to
152+
`Configuration.retries`). Not the same as SDK 5xx retries handled by `RequestsRetryDecorator`.
150153
151154
:return: Groundlight client
152155
"""
153156
# Specify the endpoint
154157
self.endpoint = sanitize_endpoint_url(endpoint)
155158
self.configuration = Configuration(host=self.endpoint)
159+
if http_transport_retries is not None:
160+
# Once we upgrade openapitools to ^7.7.0, retries can be passed into the constructor of Configuration above.
161+
self.configuration.retries = http_transport_retries
156162

157163
if not api_token:
158164
try:

0 commit comments

Comments
 (0)