airbyte-cdk 6.6.8.dev0__py3-none-any.whl → 6.6.8rc12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
1
  #
2
2
  # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
3
  #
4
-
5
4
  import logging
6
5
  import os
7
6
  import urllib
@@ -43,6 +42,7 @@ from airbyte_cdk.sources.streams.http.rate_limiting import (
43
42
  rate_limit_default_backoff_handler,
44
43
  user_defined_backoff_handler,
45
44
  )
45
+ from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets
46
46
  from airbyte_cdk.utils.constants import ENV_REQUEST_CACHE_PATH
47
47
  from airbyte_cdk.utils.stream_status_utils import (
48
48
  as_airbyte_message as stream_status_as_airbyte_message,
@@ -73,6 +73,7 @@ class MessageRepresentationAirbyteTracedErrors(AirbyteTracedException):
73
73
  class HttpClient:
74
74
  _DEFAULT_MAX_RETRY: int = 5
75
75
  _DEFAULT_MAX_TIME: int = 60 * 10
76
+ _ACTIONS_TO_RETRY_ON = {ResponseAction.RETRY, ResponseAction.RATE_LIMITED}
76
77
 
77
78
  def __init__(
78
79
  self,
@@ -333,6 +334,17 @@ class HttpClient:
333
334
 
334
335
  return response # type: ignore # will either return a valid response of type requests.Response or raise an exception
335
336
 
337
+ def _evict_key(self, prepared_request: requests.PreparedRequest) -> None:
338
+ """
339
+ Addresses high memory consumption when enabling concurrency in https://github.com/airbytehq/oncall/issues/6821.
340
+
341
+ The `_request_attempt_count` attribute keeps growing as multiple requests are made using the same `http_client`.
342
+ To mitigate this issue, we evict keys for completed requests once we confirm that no further retries are needed.
343
+ This helps manage memory usage more efficiently while maintaining the necessary logic for retry attempts.
344
+ """
345
+ if prepared_request in self._request_attempt_count:
346
+ del self._request_attempt_count[prepared_request]
347
+
336
348
  def _handle_error_resolution(
337
349
  self,
338
350
  response: Optional[requests.Response],
@@ -341,6 +353,9 @@ class HttpClient:
341
353
  error_resolution: ErrorResolution,
342
354
  exit_on_rate_limit: Optional[bool] = False,
343
355
  ) -> None:
356
+ if error_resolution.response_action not in self._ACTIONS_TO_RETRY_ON:
357
+ self._evict_key(request)
358
+
344
359
  # Emit stream status RUNNING with the reason RATE_LIMITED to log that the rate limit has been reached
345
360
  if error_resolution.response_action == ResponseAction.RATE_LIMITED:
346
361
  # TODO: Update to handle with message repository when concurrent message repository is ready
@@ -361,12 +376,13 @@ class HttpClient:
361
376
 
362
377
  if error_resolution.response_action == ResponseAction.FAIL:
363
378
  if response is not None:
364
- error_message = f"'{request.method}' request to '{request.url}' failed with status code '{response.status_code}' and error message '{self._error_message_parser.parse_response_error_message(response)}'"
379
+ error_message = f"'{request.method}' request to '{request.url}' failed with status code '{response.status_code}' and error message '{response.content}'"
365
380
  else:
366
381
  error_message = (
367
382
  f"'{request.method}' request to '{request.url}' failed with exception: '{exc}'"
368
383
  )
369
384
 
385
+ self._logger.warning(filter_secrets(error_message))
370
386
  raise MessageRepresentationAirbyteTracedErrors(
371
387
  internal_message=error_message,
372
388
  message=error_resolution.error_message or error_message,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: airbyte-cdk
3
- Version: 6.6.8.dev0
3
+ Version: 6.6.8rc12
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  Home-page: https://airbyte.com
6
6
  License: MIT
@@ -274,7 +274,7 @@ airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py,sha
274
274
  airbyte_cdk/sources/streams/http/error_handlers/response_models.py,sha256=7AX6sm8hMfVtcZuUrCmGmNFsO5rDK9Ecg2Kzl6rQwrk,2235
275
275
  airbyte_cdk/sources/streams/http/exceptions.py,sha256=njC7MlMJoFYcSGz4mIp6-bqLFTr6vC8ej25X0oSeyjE,1824
276
276
  airbyte_cdk/sources/streams/http/http.py,sha256=XoUvIClYO96datz_lBPBBY6uWmCja2mUk_yERdjskQo,28466
277
- airbyte_cdk/sources/streams/http/http_client.py,sha256=EhB9An8wA9wkoNBxTPfHGwmL_-jJVLUl6uFgkY6Fcho,19125
277
+ airbyte_cdk/sources/streams/http/http_client.py,sha256=vFSoGF6_6Xz210P3PASBs2ggNVgThdLsSAclE1LzP_k,20103
278
278
  airbyte_cdk/sources/streams/http/rate_limiting.py,sha256=IwdjrHKUnU97XO4qONgYRv4YYW51xQ8SJm4WLafXDB8,6351
279
279
  airbyte_cdk/sources/streams/http/requests_native_auth/__init__.py,sha256=RN0D3nOX1xLgwEwKWu6pkGy3XqBFzKSNZ8Lf6umU2eY,413
280
280
  airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py,sha256=r6KvG6V-bzhnCGwLqnxngrjGM0UrvD1dRo8knatuAH0,10320
@@ -331,8 +331,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EemcgcQlI8-LPYOPlYv4Qkdjyho79XVLWaUHF5X
331
331
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=LVc9KbtMeV_z99jWo0Ou8u4l6eBJ0BWNhxj4zrrGKRs,763
332
332
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
333
333
  airbyte_cdk/utils/traced_exception.py,sha256=89TQdFuYZ1NJgmFpqLzY_T_T_64TpJYmVqs119Bp43g,6164
334
- airbyte_cdk-6.6.8.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
335
- airbyte_cdk-6.6.8.dev0.dist-info/METADATA,sha256=oeA2-t-KedsEuBmQUsMmkIYa0lHZuO9L8nAJwmlly-w,13347
336
- airbyte_cdk-6.6.8.dev0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
337
- airbyte_cdk-6.6.8.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
338
- airbyte_cdk-6.6.8.dev0.dist-info/RECORD,,
334
+ airbyte_cdk-6.6.8rc12.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
335
+ airbyte_cdk-6.6.8rc12.dist-info/METADATA,sha256=zii2yqop4Sen_rkbdozR-ppoaIS4SyKjOsU9ucRiyEA,13346
336
+ airbyte_cdk-6.6.8rc12.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
337
+ airbyte_cdk-6.6.8rc12.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
338
+ airbyte_cdk-6.6.8rc12.dist-info/RECORD,,