|
37 | 37 | PaginatedImageQueryList, |
38 | 38 | ) |
39 | 39 | from urllib3.exceptions import InsecureRequestWarning |
| 40 | +from urllib3.util.retry import Retry |
40 | 41 |
|
41 | 42 | from groundlight.binary_labels import Label, convert_internal_label_to_display |
42 | 43 | from groundlight.config import API_TOKEN_MISSING_HELP_MESSAGE, API_TOKEN_VARIABLE_NAME, DISABLE_TLS_VARIABLE_NAME |
@@ -133,26 +134,31 @@ def __init__( |
133 | 134 | endpoint: Optional[str] = None, |
134 | 135 | api_token: Optional[str] = None, |
135 | 136 | disable_tls_verification: Optional[bool] = None, |
| 137 | + http_transport_retries: Optional[Union[int, Retry]] = None, |
136 | 138 | ): |
137 | 139 | """ |
138 | 140 | Initialize a new Groundlight client instance. |
139 | 141 |
|
140 | 142 | :param endpoint: Optional custom API endpoint URL. If not specified, uses the default Groundlight endpoint. |
141 | 143 | :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. |
143 | 145 | :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. |
146 | 148 |
|
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`. |
150 | 153 |
|
151 | 154 | :return: Groundlight client |
152 | 155 | """ |
153 | 156 | # Specify the endpoint |
154 | 157 | self.endpoint = sanitize_endpoint_url(endpoint) |
155 | 158 | 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 |
156 | 162 |
|
157 | 163 | if not api_token: |
158 | 164 | try: |
|
0 commit comments