airbyte-cdk 6.37.0.dev0__py3-none-any.whl → 6.37.2.dev1__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.
airbyte_cdk/entrypoint.py CHANGED
@@ -37,8 +37,8 @@ from airbyte_cdk.sources import Source
37
37
  from airbyte_cdk.sources.connector_state_manager import HashableStreamDescriptor
38
38
  from airbyte_cdk.sources.utils.schema_helpers import check_config_against_spec_or_exit, split_config
39
39
 
40
- from airbyte_cdk.utils import PrintBuffer, is_cloud_environment, message_utils # add PrintBuffer back once fixed
41
- # from airbyte_cdk.utils import is_cloud_environment, message_utils
40
+ # from airbyte_cdk.utils import PrintBuffer, is_cloud_environment, message_utils # add PrintBuffer back once fixed
41
+ from airbyte_cdk.utils import is_cloud_environment, message_utils
42
42
  from airbyte_cdk.utils.airbyte_secrets_utils import get_secrets, update_secrets
43
43
  from airbyte_cdk.utils.constants import ENV_REQUEST_CACHE_PATH
44
44
  from airbyte_cdk.utils.traced_exception import AirbyteTracedException
@@ -337,11 +337,11 @@ def launch(source: Source, args: List[str]) -> None:
337
337
  parsed_args = source_entrypoint.parse_args(args)
338
338
  # temporarily removes the PrintBuffer because we're seeing weird print behavior for concurrent syncs
339
339
  # Refer to: https://github.com/airbytehq/oncall/issues/6235
340
- with PrintBuffer():
341
- for message in source_entrypoint.run(parsed_args):
342
- # simply printing is creating issues for concurrent CDK as Python uses different two instructions to print: one for the message and
343
- # the other for the break line. Adding `\n` to the message ensure that both are printed at the same time
344
- print(f"{message}\n", end="", flush=True)
340
+ # with PrintBuffer():
341
+ for message in source_entrypoint.run(parsed_args):
342
+ # simply printing is creating issues for concurrent CDK as Python uses different two instructions to print: one for the message and
343
+ # the other for the break line. Adding `\n` to the message ensure that both are printed at the same time
344
+ print(f"{message}\n", end="", flush=True)
345
345
 
346
346
 
347
347
  def _init_internal_request_filter() -> None:
@@ -5,7 +5,7 @@ import json
5
5
  import logging
6
6
  from abc import ABC, abstractmethod
7
7
  from dataclasses import dataclass
8
- from io import BufferedIOBase, TextIOWrapper
8
+ from io import BufferedIOBase, BytesIO, TextIOWrapper
9
9
  from typing import Any, Generator, MutableMapping, Optional
10
10
 
11
11
  import orjson
@@ -124,7 +124,8 @@ class CsvParser(Parser):
124
124
  """
125
125
  Parse CSV data from decompressed bytes.
126
126
  """
127
- text_data = TextIOWrapper(data, encoding=self.encoding) # type: ignore
127
+ bytes_data = BytesIO(data.read())
128
+ text_data = TextIOWrapper(bytes_data, encoding=self.encoding) # type: ignore
128
129
  reader = csv.DictReader(text_data, delimiter=self._get_delimiter() or ",")
129
130
  for row in reader:
130
131
  yield row
@@ -136,6 +136,7 @@ class ResponseToFileExtractor(RecordExtractor):
136
136
  """
137
137
 
138
138
  try:
139
+ # TODO: Add support for other file types, like `json`, with `pd.read_json()`
139
140
  with open(path, "r", encoding=file_encoding) as data:
140
141
  chunks = pd.read_csv(
141
142
  data, chunksize=chunk_size, iterator=True, dialect="unix", dtype=object
@@ -23,6 +23,7 @@ from airbyte_cdk.sources.declarative.extractors.response_to_file_extractor impor
23
23
  )
24
24
  from airbyte_cdk.sources.declarative.requesters.requester import Requester
25
25
  from airbyte_cdk.sources.declarative.retrievers.simple_retriever import SimpleRetriever
26
+ from airbyte_cdk.sources.http_logger import format_http_message
26
27
  from airbyte_cdk.sources.types import Record, StreamSlice
27
28
  from airbyte_cdk.utils import AirbyteTracedException
28
29
 
@@ -71,7 +72,15 @@ class AsyncHttpJobRepository(AsyncJobRepository):
71
72
  """
72
73
 
73
74
  polling_response: Optional[requests.Response] = self.polling_requester.send_request(
74
- stream_slice=stream_slice
75
+ stream_slice=stream_slice,
76
+ log_formatter=lambda polling_response: format_http_message(
77
+ response=polling_response,
78
+ title="Async Job -- Polling",
79
+ description="Poll the status of the server-side async job.",
80
+ stream_name=None,
81
+ is_auxiliary=True,
82
+ type="ASYNC_POLL",
83
+ ),
75
84
  )
76
85
  if polling_response is None:
77
86
  raise AirbyteTracedException(
@@ -118,8 +127,17 @@ class AsyncHttpJobRepository(AsyncJobRepository):
118
127
  """
119
128
 
120
129
  response: Optional[requests.Response] = self.creation_requester.send_request(
121
- stream_slice=stream_slice
130
+ stream_slice=stream_slice,
131
+ log_formatter=lambda response: format_http_message(
132
+ response=response,
133
+ title="Async Job -- Create",
134
+ description="Create the server-side async job.",
135
+ stream_name=None,
136
+ is_auxiliary=True,
137
+ type="ASYNC_CREATE",
138
+ ),
122
139
  )
140
+
123
141
  if not response:
124
142
  raise AirbyteTracedException(
125
143
  internal_message="Always expect a response or an exception from creation_requester",
@@ -217,13 +235,33 @@ class AsyncHttpJobRepository(AsyncJobRepository):
217
235
  if not self.abort_requester:
218
236
  return
219
237
 
220
- self.abort_requester.send_request(stream_slice=self._get_create_job_stream_slice(job))
238
+ abort_response = self.abort_requester.send_request(
239
+ stream_slice=self._get_create_job_stream_slice(job),
240
+ log_formatter=lambda abort_response: format_http_message(
241
+ response=abort_response,
242
+ title="Async Job -- Abort",
243
+ description="Abort the running server-side async job.",
244
+ stream_name=None,
245
+ is_auxiliary=True,
246
+ type="ASYNC_ABORT",
247
+ ),
248
+ )
221
249
 
222
250
  def delete(self, job: AsyncJob) -> None:
223
251
  if not self.delete_requester:
224
252
  return
225
253
 
226
- self.delete_requester.send_request(stream_slice=self._get_create_job_stream_slice(job))
254
+ delete_job_reponse = self.delete_requester.send_request(
255
+ stream_slice=self._get_create_job_stream_slice(job),
256
+ log_formatter=lambda delete_job_reponse: format_http_message(
257
+ response=delete_job_reponse,
258
+ title="Async Job -- Delete",
259
+ description="Delete the specified job from the list of Jobs.",
260
+ stream_name=None,
261
+ is_auxiliary=True,
262
+ type="ASYNC_DELETE",
263
+ ),
264
+ )
227
265
  self._clean_up_job(job.api_job_id())
228
266
 
229
267
  def _clean_up_job(self, job_id: str) -> None:
@@ -1,13 +1,12 @@
1
1
  # Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2
2
 
3
3
 
4
- from dataclasses import InitVar, dataclass
4
+ from dataclasses import InitVar, dataclass, field
5
5
  from typing import Any, Iterable, Mapping, Optional
6
6
 
7
7
  from typing_extensions import deprecated
8
8
 
9
9
  from airbyte_cdk.sources.declarative.async_job.job import AsyncJob
10
- from airbyte_cdk.sources.declarative.async_job.job_orchestrator import AsyncPartition
11
10
  from airbyte_cdk.sources.declarative.extractors.record_selector import RecordSelector
12
11
  from airbyte_cdk.sources.declarative.partition_routers.async_job_partition_router import (
13
12
  AsyncJobPartitionRouter,
@@ -16,6 +15,7 @@ from airbyte_cdk.sources.declarative.retrievers.retriever import Retriever
16
15
  from airbyte_cdk.sources.source import ExperimentalClassWarning
17
16
  from airbyte_cdk.sources.streams.core import StreamData
18
17
  from airbyte_cdk.sources.types import Config, StreamSlice, StreamState
18
+ from airbyte_cdk.sources.utils.slice_logger import AlwaysLogSliceLogger
19
19
 
20
20
 
21
21
  @deprecated(
@@ -28,6 +28,10 @@ class AsyncRetriever(Retriever):
28
28
  parameters: InitVar[Mapping[str, Any]]
29
29
  record_selector: RecordSelector
30
30
  stream_slicer: AsyncJobPartitionRouter
31
+ slice_logger: AlwaysLogSliceLogger = field(
32
+ init=False,
33
+ default_factory=lambda: AlwaysLogSliceLogger(),
34
+ )
31
35
 
32
36
  def __post_init__(self, parameters: Mapping[str, Any]) -> None:
33
37
  self._parameters = parameters
@@ -75,13 +79,16 @@ class AsyncRetriever(Retriever):
75
79
  return stream_slice.extra_fields.get("jobs", []) if stream_slice else []
76
80
 
77
81
  def stream_slices(self) -> Iterable[Optional[StreamSlice]]:
78
- return self.stream_slicer.stream_slices()
82
+ yield from self.stream_slicer.stream_slices()
79
83
 
80
84
  def read_records(
81
85
  self,
82
86
  records_schema: Mapping[str, Any],
83
87
  stream_slice: Optional[StreamSlice] = None,
84
88
  ) -> Iterable[StreamData]:
89
+ # emit the slice_descriptor log message, for connector builder TestRead
90
+ yield self.slice_logger.create_slice_log_message(stream_slice.cursor_slice) # type: ignore
91
+
85
92
  stream_state: StreamState = self._get_stream_state()
86
93
  jobs: Iterable[AsyncJob] = self._validate_and_get_stream_slice_jobs(stream_slice)
87
94
  records: Iterable[Mapping[str, Any]] = self.stream_slicer.fetch_records(jobs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: airbyte-cdk
3
- Version: 6.37.0.dev0
3
+ Version: 6.37.2.dev1
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  Home-page: https://airbyte.com
6
6
  License: MIT
@@ -26,7 +26,7 @@ airbyte_cdk/destinations/vector_db_based/indexer.py,sha256=beiSi2Uu67EoTr7yQSaCJ
26
26
  airbyte_cdk/destinations/vector_db_based/test_utils.py,sha256=MkqLiOJ5QyKbV4rNiJhe-BHM7FD-ADHQ4bQGf4c5lRY,1932
27
27
  airbyte_cdk/destinations/vector_db_based/utils.py,sha256=FOyEo8Lc-fY8UyhpCivhZtIqBRyxf3cUt6anmK03fUY,1127
28
28
  airbyte_cdk/destinations/vector_db_based/writer.py,sha256=nZ00xPiohElJmYktEZZIhr0m5EDETCHGhg0Lb2S7A20,5095
29
- airbyte_cdk/entrypoint.py,sha256=2b8lsoJkMIVtQE0vKkpsjHYnIUJm9G6HDuEN_lc4SP0,18569
29
+ airbyte_cdk/entrypoint.py,sha256=xFLY2PV8mKXUaeBAknczbK6plrs4_B1WdWA6K3iaRJI,18555
30
30
  airbyte_cdk/exception_handler.py,sha256=D_doVl3Dt60ASXlJsfviOCswxGyKF2q0RL6rif3fNks,2013
31
31
  airbyte_cdk/logger.py,sha256=qi4UGuSYQQGaFaTVJlMD9lLppwqLXt1XBhwSXo-Q5IA,3660
32
32
  airbyte_cdk/models/__init__.py,sha256=MOTiuML2wShBaMSIwikdjyye2uUWBjo4J1QFSbnoiM4,2075
@@ -75,7 +75,7 @@ airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=5o5Gslt
75
75
  airbyte_cdk/sources/declarative/declarative_source.py,sha256=nF7wBqFd3AQmEKAm4CnIo29CJoQL562cJGSCeL8U8bA,1531
76
76
  airbyte_cdk/sources/declarative/declarative_stream.py,sha256=venZjfpvtqr3oFSuvMBWtn4h9ayLhD4L65ACuXCDZ64,10445
77
77
  airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=JHb_0d3SE6kNY10mxA5YBEKPeSbsWYjByq1gUQxepoE,953
78
- airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py,sha256=DJbWaaJ5LHCBpyWz-4bEw8rqtJYqabEYZtxnfRtWFE0,4946
78
+ airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py,sha256=dQtXYK2ngM8JnVsQi_UXQugWYjotMrzRJfc6kNz7Sx4,5003
79
79
  airbyte_cdk/sources/declarative/decoders/decoder.py,sha256=sl-Gt8lXi7yD2Q-sD8je5QS2PbgrgsYjxRLWsay7DMc,826
80
80
  airbyte_cdk/sources/declarative/decoders/json_decoder.py,sha256=BdWpXXPhEGf_zknggJmhojLosmxuw51RBVTS0jvdCPc,2080
81
81
  airbyte_cdk/sources/declarative/decoders/noop_decoder.py,sha256=iZh0yKY_JzgBnJWiubEusf5c0o6Khd-8EWFWT-8EgFo,542
@@ -89,7 +89,7 @@ airbyte_cdk/sources/declarative/extractors/http_selector.py,sha256=2zWZ4ewTqQC8V
89
89
  airbyte_cdk/sources/declarative/extractors/record_extractor.py,sha256=XJELMjahAsaomlvQgN2zrNO0DJX0G0fr9r682gUz7Pg,691
90
90
  airbyte_cdk/sources/declarative/extractors/record_filter.py,sha256=yTdEkyDUSW2KbFkEwJJMlS963C955LgCCOVfTmmScpQ,3367
91
91
  airbyte_cdk/sources/declarative/extractors/record_selector.py,sha256=HCqx7IyENM_aRF4it2zJN26_vDu6WeP8XgCxQWHUvcY,6934
92
- airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py,sha256=LhqGDfX06_dDYLKsIVnwQ_nAWCln-v8PV7Wgt_QVeTI,6533
92
+ airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py,sha256=L6hQV7bdwEp8y-TBMeQY-xmrNyRggL14lKXdWnzYFfA,6622
93
93
  airbyte_cdk/sources/declarative/extractors/type_transformer.py,sha256=d6Y2Rfg8pMVEEnHllfVksWZdNVOU55yk34O03dP9muY,1626
94
94
  airbyte_cdk/sources/declarative/incremental/__init__.py,sha256=U1oZKtBaEC6IACmvziY9Wzg7Z8EgF4ZuR7NwvjlB_Sk,1255
95
95
  airbyte_cdk/sources/declarative/incremental/concurrent_partition_cursor.py,sha256=MT5JbdEbnPzk3VWZGGvThe4opoX5dHhSXFrnTRYC6dg,22210
@@ -142,7 +142,7 @@ airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.
142
142
  airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py,sha256=q0YkeYUUWO6iErUy0vjqiOkhg8_9d5YcCmtlpXAJJ9E,1314
143
143
  airbyte_cdk/sources/declarative/requesters/error_handlers/error_handler.py,sha256=Tan66odx8VHzfdyyXMQkXz2pJYksllGqvxmpoajgcK4,669
144
144
  airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py,sha256=E-fQbt4ShfxZVoqfnmOx69C6FUPWZz8BIqI3DN9Kcjs,7935
145
- airbyte_cdk/sources/declarative/requesters/http_job_repository.py,sha256=3GtOefPH08evlSUxaILkiKLTHbIspFY4qd5B3ZqNE60,10063
145
+ airbyte_cdk/sources/declarative/requesters/http_job_repository.py,sha256=Wjh5ARW1kcuRfihfFEloQ_l1N6yY1NN_4qFZJiqlH4o,11612
146
146
  airbyte_cdk/sources/declarative/requesters/http_requester.py,sha256=pR2uR5b9eGyvYIOYwus3mz3OaqRu1ozwja_ys1SE7hc,14952
147
147
  airbyte_cdk/sources/declarative/requesters/paginators/__init__.py,sha256=uArbKs9JKNCt7t9tZoeWwjDpyI1HoPp29FNW0JzvaEM,644
148
148
  airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py,sha256=ZW4lwWNAzb4zL0jKc-HjowP5-y0Zg9xi0YlK6tkx_XY,12057
@@ -169,7 +169,7 @@ airbyte_cdk/sources/declarative/resolvers/components_resolver.py,sha256=KPjKc0yb
169
169
  airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py,sha256=dz4iJV9liD_LzY_Mn4XmAStoUll60R3MIGWV4aN3pgg,5223
170
170
  airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py,sha256=AiojNs8wItJFrENZBFUaDvau3sgwudO6Wkra36upSPo,4639
171
171
  airbyte_cdk/sources/declarative/retrievers/__init__.py,sha256=ix9m1dkR69DcXCXUKC5RK_ZZM7ojTLBQ4IkWQTfmfCk,456
172
- airbyte_cdk/sources/declarative/retrievers/async_retriever.py,sha256=2oQn_vo7uJKp4pdMnsF5CG5Iwc9rkPeEOLoAm_9bcus,3222
172
+ airbyte_cdk/sources/declarative/retrievers/async_retriever.py,sha256=dwYZ70eg9DKHEqZydHhMFPkEILbNcXu7E-djOCikNgI,3530
173
173
  airbyte_cdk/sources/declarative/retrievers/retriever.py,sha256=XPLs593Xv8c5cKMc37XzUAYmzlXd1a7eSsspM-CMuWA,1696
174
174
  airbyte_cdk/sources/declarative/retrievers/simple_retriever.py,sha256=bOAKQLgMv1Vca-ozMPRVAg1V5nkyUoPwqC02lKpnLiM,24575
175
175
  airbyte_cdk/sources/declarative/schema/__init__.py,sha256=xU45UvM5O4c1PSM13UHpCdh5hpW3HXy9vRRGEiAC1rg,795
@@ -360,9 +360,9 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EDxgROHDbfG-QKQb59m7h_7crN1tRiawdf5uU7G
360
360
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
361
361
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
362
362
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
363
- airbyte_cdk-6.37.0.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
364
- airbyte_cdk-6.37.0.dev0.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
365
- airbyte_cdk-6.37.0.dev0.dist-info/METADATA,sha256=kcKo6BoaqSRqsOMLq2fmnSa6iVkhtMy4YMEL4Dk1WYU,6015
366
- airbyte_cdk-6.37.0.dev0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
367
- airbyte_cdk-6.37.0.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
368
- airbyte_cdk-6.37.0.dev0.dist-info/RECORD,,
363
+ airbyte_cdk-6.37.2.dev1.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
364
+ airbyte_cdk-6.37.2.dev1.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
365
+ airbyte_cdk-6.37.2.dev1.dist-info/METADATA,sha256=-nhNtzFqhzx4jLmK3XuDXywoS33ZGSuy9PM0PsRC97g,6015
366
+ airbyte_cdk-6.37.2.dev1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
367
+ airbyte_cdk-6.37.2.dev1.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
368
+ airbyte_cdk-6.37.2.dev1.dist-info/RECORD,,