airbyte-cdk 6.7.1rc3__py3-none-any.whl → 6.7.1rc4__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.
@@ -360,6 +360,9 @@ class SimpleRetriever(Retriever):
360
360
  next_page_token = self._next_page_token(response)
361
361
  if not next_page_token:
362
362
  pagination_complete = True
363
+ # Closing the response to avoid memory issues. Note that this assumes the caller as completely consumed the response before
364
+ # iterating on another one
365
+ response.close()
363
366
 
364
367
  # Always return an empty generator just in case no records were ever yielded
365
368
  yield from []
@@ -6,7 +6,7 @@ import logging
6
6
  import os
7
7
  import urllib
8
8
  from pathlib import Path
9
- from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Union
9
+ from typing import Any, Callable, List, Mapping, Optional, Tuple, Union
10
10
 
11
11
  import orjson
12
12
  import requests
@@ -43,6 +43,7 @@ from airbyte_cdk.sources.streams.http.rate_limiting import (
43
43
  rate_limit_default_backoff_handler,
44
44
  user_defined_backoff_handler,
45
45
  )
46
+ from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets
46
47
  from airbyte_cdk.utils.constants import ENV_REQUEST_CACHE_PATH
47
48
  from airbyte_cdk.utils.stream_status_utils import (
48
49
  as_airbyte_message as stream_status_as_airbyte_message,
@@ -90,9 +91,11 @@ class HttpClient:
90
91
  ):
91
92
  self._name = name
92
93
  self._api_budget: APIBudget = api_budget or APIBudget(policies=[])
94
+ self._is_session_owner = False
93
95
  if session:
94
96
  self._session = session
95
97
  else:
98
+ self._is_session_owner = True
96
99
  self._use_cache = use_cache
97
100
  self._session = self._request_session()
98
101
  self._session.mount(
@@ -113,10 +116,13 @@ class HttpClient:
113
116
  else:
114
117
  self._backoff_strategies = [DefaultBackoffStrategy()]
115
118
  self._error_message_parser = error_message_parser or JsonErrorMessageParser()
116
- self._request_attempt_count: Dict[requests.PreparedRequest, int] = {}
117
119
  self._disable_retries = disable_retries
118
120
  self._message_repository = message_repository
119
121
 
122
+ def __del__(self):
123
+ if self._is_session_owner:
124
+ self._session.close()
125
+
120
126
  @property
121
127
  def cache_filename(self) -> str:
122
128
  """
@@ -269,13 +275,6 @@ class HttpClient:
269
275
  log_formatter: Optional[Callable[[requests.Response], Any]] = None,
270
276
  exit_on_rate_limit: Optional[bool] = False,
271
277
  ) -> requests.Response:
272
- if request not in self._request_attempt_count:
273
- self._request_attempt_count[request] = 1
274
- else:
275
- self._request_attempt_count[request] += 1
276
- if hasattr(self._session, "auth") and isinstance(self._session.auth, AuthBase):
277
- self._session.auth(request)
278
-
279
278
  self._logger.debug(
280
279
  "Making outbound API request",
281
280
  extra={"headers": request.headers, "url": request.url, "request_body": request.body},
@@ -361,12 +360,13 @@ class HttpClient:
361
360
 
362
361
  if error_resolution.response_action == ResponseAction.FAIL:
363
362
  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)}'"
363
+ error_message = f"'{request.method}' request to '{request.url}' failed with status code '{response.status_code}' and error message '{response.content}'"
365
364
  else:
366
365
  error_message = (
367
366
  f"'{request.method}' request to '{request.url}' failed with exception: '{exc}'"
368
367
  )
369
368
 
369
+ self._logger.warning(filter_secrets(error_message))
370
370
  raise MessageRepresentationAirbyteTracedErrors(
371
371
  internal_message=error_message,
372
372
  message=error_resolution.error_message or error_message,
@@ -390,7 +390,7 @@ class HttpClient:
390
390
  for backoff_strategy in self._backoff_strategies:
391
391
  backoff_time = backoff_strategy.backoff_time(
392
392
  response_or_exception=response if response is not None else exc,
393
- attempt_count=self._request_attempt_count[request],
393
+ attempt_count=0,
394
394
  )
395
395
  if backoff_time:
396
396
  user_defined_backoff_time = backoff_time
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: airbyte-cdk
3
- Version: 6.7.1rc3
3
+ Version: 6.7.1rc4
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  Home-page: https://airbyte.com
6
6
  License: MIT
@@ -155,7 +155,7 @@ airbyte_cdk/sources/declarative/requesters/requester.py,sha256=9LWbCkHpr7GWTkPvY
155
155
  airbyte_cdk/sources/declarative/retrievers/__init__.py,sha256=FVQpUGVwp2Gibk4gp07VmLKX5AafUlsZWFSrDpUDuJM,443
156
156
  airbyte_cdk/sources/declarative/retrievers/async_retriever.py,sha256=iNe8Ihrk4vClCNtnEjtMUjjUoNo0UceYUFV7yAcXCU0,4965
157
157
  airbyte_cdk/sources/declarative/retrievers/retriever.py,sha256=XPLs593Xv8c5cKMc37XzUAYmzlXd1a7eSsspM-CMuWA,1696
158
- airbyte_cdk/sources/declarative/retrievers/simple_retriever.py,sha256=j09j4ngVDGosEVVEQk_joejAXm6dBfr45ulElhz2ZoA,23931
158
+ airbyte_cdk/sources/declarative/retrievers/simple_retriever.py,sha256=koRm-fZbogmUAw71hxQC6VDzk5i8ku8juQaiu-VeAUo,24147
159
159
  airbyte_cdk/sources/declarative/schema/__init__.py,sha256=ul8L9S0-__AMEdbCLHBq-PMEeA928NVp8BB83BMotfU,517
160
160
  airbyte_cdk/sources/declarative/schema/default_schema_loader.py,sha256=KTACrIE23a83wsm3Rd9Eb4K6-20lrGqYxTHNp9yxsso,1820
161
161
  airbyte_cdk/sources/declarative/schema/inline_schema_loader.py,sha256=bVETE10hRsatRJq3R3BeyRR0wIoK3gcP1gcpVRQ_P5U,464
@@ -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=Yi5uAhi8u4EXDk4QaiXGF__OF3M45cQ6UvouHHzEq_4,18949
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.7.1rc3.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
335
- airbyte_cdk-6.7.1rc3.dist-info/METADATA,sha256=30Cxq3db7GZ-C8f9O_upnnu24ohOqsW5epbzvlvsJw0,13345
336
- airbyte_cdk-6.7.1rc3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
337
- airbyte_cdk-6.7.1rc3.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
338
- airbyte_cdk-6.7.1rc3.dist-info/RECORD,,
334
+ airbyte_cdk-6.7.1rc4.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
335
+ airbyte_cdk-6.7.1rc4.dist-info/METADATA,sha256=iS1Wng9dw5V52JIfeTLoumDUhZpZDXffvvM1CJSvCxw,13345
336
+ airbyte_cdk-6.7.1rc4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
337
+ airbyte_cdk-6.7.1rc4.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
338
+ airbyte_cdk-6.7.1rc4.dist-info/RECORD,,