airbyte-cdk 6.26.0__py3-none-any.whl → 6.26.0.dev0__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.
@@ -222,8 +222,6 @@ class PerPartitionCursor(DeclarativeCursor):
222
222
  next_page_token: Optional[Mapping[str, Any]] = None,
223
223
  ) -> Mapping[str, Any]:
224
224
  if stream_slice:
225
- if self._to_partition_key(stream_slice.partition) not in self._cursor_per_partition:
226
- self._create_cursor_for_partition(self._to_partition_key(stream_slice.partition))
227
225
  return self._partition_router.get_request_params( # type: ignore # this always returns a mapping
228
226
  stream_state=stream_state,
229
227
  stream_slice=StreamSlice(partition=stream_slice.partition, cursor_slice={}),
@@ -246,8 +244,6 @@ class PerPartitionCursor(DeclarativeCursor):
246
244
  next_page_token: Optional[Mapping[str, Any]] = None,
247
245
  ) -> Mapping[str, Any]:
248
246
  if stream_slice:
249
- if self._to_partition_key(stream_slice.partition) not in self._cursor_per_partition:
250
- self._create_cursor_for_partition(self._to_partition_key(stream_slice.partition))
251
247
  return self._partition_router.get_request_headers( # type: ignore # this always returns a mapping
252
248
  stream_state=stream_state,
253
249
  stream_slice=StreamSlice(partition=stream_slice.partition, cursor_slice={}),
@@ -270,8 +266,6 @@ class PerPartitionCursor(DeclarativeCursor):
270
266
  next_page_token: Optional[Mapping[str, Any]] = None,
271
267
  ) -> Union[Mapping[str, Any], str]:
272
268
  if stream_slice:
273
- if self._to_partition_key(stream_slice.partition) not in self._cursor_per_partition:
274
- self._create_cursor_for_partition(self._to_partition_key(stream_slice.partition))
275
269
  return self._partition_router.get_request_body_data( # type: ignore # this always returns a mapping
276
270
  stream_state=stream_state,
277
271
  stream_slice=StreamSlice(partition=stream_slice.partition, cursor_slice={}),
@@ -294,8 +288,6 @@ class PerPartitionCursor(DeclarativeCursor):
294
288
  next_page_token: Optional[Mapping[str, Any]] = None,
295
289
  ) -> Mapping[str, Any]:
296
290
  if stream_slice:
297
- if self._to_partition_key(stream_slice.partition) not in self._cursor_per_partition:
298
- self._create_cursor_for_partition(self._to_partition_key(stream_slice.partition))
299
291
  return self._partition_router.get_request_body_json( # type: ignore # this always returns a mapping
300
292
  stream_state=stream_state,
301
293
  stream_slice=StreamSlice(partition=stream_slice.partition, cursor_slice={}),
@@ -311,6 +303,21 @@ class PerPartitionCursor(DeclarativeCursor):
311
303
  raise ValueError("A partition needs to be provided in order to get request body json")
312
304
 
313
305
  def should_be_synced(self, record: Record) -> bool:
306
+ if (
307
+ record.associated_slice
308
+ and self._to_partition_key(record.associated_slice.partition)
309
+ not in self._cursor_per_partition
310
+ ):
311
+ partition_state = (
312
+ self._state_to_migrate_from
313
+ if self._state_to_migrate_from
314
+ else self._NO_CURSOR_STATE
315
+ )
316
+ cursor = self._create_cursor(partition_state)
317
+
318
+ self._cursor_per_partition[
319
+ self._to_partition_key(record.associated_slice.partition)
320
+ ] = cursor
314
321
  return self._get_cursor(record).should_be_synced(
315
322
  self._convert_record_to_cursor_record(record)
316
323
  )
@@ -349,32 +356,8 @@ class PerPartitionCursor(DeclarativeCursor):
349
356
  )
350
357
  partition_key = self._to_partition_key(record.associated_slice.partition)
351
358
  if partition_key not in self._cursor_per_partition:
352
- self._create_cursor_for_partition(partition_key)
359
+ raise ValueError(
360
+ "Invalid state as stream slices that are emitted should refer to an existing cursor"
361
+ )
353
362
  cursor = self._cursor_per_partition[partition_key]
354
363
  return cursor
355
-
356
- def _create_cursor_for_partition(self, partition_key: str) -> None:
357
- """
358
- Dynamically creates and initializes a cursor for the specified partition.
359
-
360
- This method is required for `ConcurrentPerPartitionCursor`. For concurrent cursors,
361
- stream_slices is executed only for the concurrent cursor, so cursors per partition
362
- are not created for the declarative cursor. This method ensures that a cursor is available
363
- to create requests for the specified partition. The cursor is initialized
364
- with the per-partition state if present in the initial state, or with the global state
365
- adjusted by the lookback window, or with the state to migrate from.
366
-
367
- Note:
368
- This is a temporary workaround and should be removed once the declarative cursor
369
- is decoupled from the concurrent cursor implementation.
370
-
371
- Args:
372
- partition_key (str): The unique identifier for the partition for which the cursor
373
- needs to be created.
374
- """
375
- partition_state = (
376
- self._state_to_migrate_from if self._state_to_migrate_from else self._NO_CURSOR_STATE
377
- )
378
- cursor = self._create_cursor(partition_state)
379
-
380
- self._cursor_per_partition[partition_key] = cursor
@@ -2407,7 +2407,7 @@ class ModelToComponentFactory:
2407
2407
  if (
2408
2408
  not isinstance(stream_slicer, DatetimeBasedCursor)
2409
2409
  or type(stream_slicer) is not DatetimeBasedCursor
2410
- ):
2410
+ ) and not isinstance(stream_slicer, PerPartitionWithGlobalCursor):
2411
2411
  # Many of the custom component implementations of DatetimeBasedCursor override get_request_params() (or other methods).
2412
2412
  # Because we're decoupling RequestOptionsProvider from the Cursor, custom components will eventually need to reimplement
2413
2413
  # their own RequestOptionsProvider. However, right now the existing StreamSlicer/Cursor still can act as the SimpleRetriever's
@@ -296,12 +296,8 @@ class SubstreamPartitionRouter(PartitionRouter):
296
296
 
297
297
  if not parent_state and incremental_dependency:
298
298
  # Attempt to retrieve child state
299
- substream_state_values = list(stream_state.values())
300
- substream_state = substream_state_values[0] if substream_state_values else {}
301
- # Filter out per partition state. Because we pass the state to the parent stream in the format {cursor_field: substream_state}
302
- if isinstance(substream_state, (list, dict)):
303
- substream_state = {}
304
-
299
+ substream_state = list(stream_state.values())
300
+ substream_state = substream_state[0] if substream_state else {} # type: ignore [assignment] # Incorrect type for assignment
305
301
  parent_state = {}
306
302
 
307
303
  # Copy child state to parent streams with incremental dependencies
@@ -154,9 +154,8 @@ class DynamicSchemaLoader(SchemaLoader):
154
154
  transformed_properties = self._transform(properties, {})
155
155
 
156
156
  return {
157
- "$schema": "https://json-schema.org/draft-07/schema#",
157
+ "$schema": "http://json-schema.org/draft-07/schema#",
158
158
  "type": "object",
159
- "additionalProperties": True,
160
159
  "properties": transformed_properties,
161
160
  }
162
161
 
@@ -221,17 +220,25 @@ class DynamicSchemaLoader(SchemaLoader):
221
220
  )
222
221
 
223
222
  def _resolve_complex_type(self, complex_type: ComplexFieldType) -> Mapping[str, Any]:
224
- if not complex_type.items:
225
- return self._get_airbyte_type(complex_type.field_type)
226
-
227
- field_type = self._get_airbyte_type(complex_type.field_type)
228
- field_type["items"] = (
229
- self._get_airbyte_type(complex_type.items)
230
- if isinstance(complex_type.items, str)
231
- else self._resolve_complex_type(complex_type.items)
232
- )
233
-
234
- return field_type
223
+ types = [complex_type]
224
+ resolved_type: MutableMapping[str, Any] = {}
225
+
226
+ while types:
227
+ current_type = types.pop()
228
+ if not current_type.items:
229
+ resolved_type = self._get_airbyte_type(current_type.field_type)
230
+ else:
231
+ field_type = self._get_airbyte_type(current_type.field_type)
232
+
233
+ if isinstance(current_type.items, str):
234
+ items_type = current_type.items
235
+ else:
236
+ types.append(current_type.items)
237
+ continue # Skip the following lines until the stack is resolved
238
+ field_type["items"] = self._get_airbyte_type(items_type)
239
+ resolved_type = field_type
240
+
241
+ return resolved_type
235
242
 
236
243
  def _replace_type_if_not_valid(
237
244
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.26.0
3
+ Version: 6.26.0.dev0
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  License: MIT
6
6
  Keywords: airbyte,connector-development-kit,cdk
@@ -92,7 +92,7 @@ airbyte_cdk/sources/declarative/incremental/concurrent_partition_cursor.py,sha25
92
92
  airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py,sha256=_UzUnSIUsDbRgbFTXgSyZEFb4ws-KdhdQPWO8mFbV7U,22028
93
93
  airbyte_cdk/sources/declarative/incremental/declarative_cursor.py,sha256=5Bhw9VRPyIuCaD0wmmq_L3DZsa-rJgtKSEUzSd8YYD0,536
94
94
  airbyte_cdk/sources/declarative/incremental/global_substream_cursor.py,sha256=9HO-QbL9akvjq2NP7l498RwLA4iQZlBMQW1tZbt34I8,15943
95
- airbyte_cdk/sources/declarative/incremental/per_partition_cursor.py,sha256=9IAJTCiRUXvhFFz-IhZtYh_KfAjLHqthsYf2jErQRls,17728
95
+ airbyte_cdk/sources/declarative/incremental/per_partition_cursor.py,sha256=_FSJjAwL4Zu-i2CngnhTtx8j-NPVSBKj5LwDSPta3Cg,16305
96
96
  airbyte_cdk/sources/declarative/incremental/per_partition_with_global.py,sha256=2YBOA2NnwAeIKlIhSwUB_W-FaGnPcmrG_liY7b4mV2Y,8365
97
97
  airbyte_cdk/sources/declarative/incremental/resumable_full_refresh_cursor.py,sha256=10LFv1QPM-agVKl6eaANmEBOfd7gZgBrkoTcMggsieQ,4809
98
98
  airbyte_cdk/sources/declarative/interpolation/__init__.py,sha256=tjUJkn3B-iZ-p7RP2c3dVZejrGiQeooGmS5ibWTuUL4,437
@@ -115,14 +115,14 @@ airbyte_cdk/sources/declarative/parsers/custom_code_compiler.py,sha256=958MMX6_Z
115
115
  airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
116
116
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
117
117
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
118
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=zfWJLlopJklDK1xvoUy2qMFcnSklmQ7wwEbdWVxYlw0,122917
118
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=mf0Iwq0VtetpC2HYq93_hZUOuFhWUB7aPjacC6RarYk,122981
119
119
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=HJ-Syp3p7RpyR_OK0X_a2kSyISfu3W-PKrRI16iY0a8,957
120
120
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=n82J15S8bjeMZ5uROu--P3hnbQoxkY5v7RPHYx7g7ro,2929
121
121
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
122
122
  airbyte_cdk/sources/declarative/partition_routers/list_partition_router.py,sha256=t7pRdFWfFWJtQQG19c9PVeMODyO2BknRTakpM5U9N-8,4844
123
123
  airbyte_cdk/sources/declarative/partition_routers/partition_router.py,sha256=YyEIzdmLd1FjbVP3QbQ2VFCLW_P-OGbVh6VpZShp54k,2218
124
124
  airbyte_cdk/sources/declarative/partition_routers/single_partition_router.py,sha256=SKzKjSyfccq4dxGIh-J6ejrgkCHzaiTIazmbmeQiRD4,1942
125
- airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py,sha256=pPb0blnNx598bk47Khgs0cvwhN02SWSmg7lnJKb9K6Q,15577
125
+ airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py,sha256=5bgXoJfBg_6i53krQMptAGb50XB5XoVfqQxKQhlLtBA,15383
126
126
  airbyte_cdk/sources/declarative/requesters/README.md,sha256=eL1I4iLkxaw7hJi9S9d18_XcRl-R8lUSjqBVJJzvXmg,2656
127
127
  airbyte_cdk/sources/declarative/requesters/__init__.py,sha256=d7a3OoHbqaJDyyPli3nqqJ2yAW_SLX6XDaBAKOwvpxw,364
128
128
  airbyte_cdk/sources/declarative/requesters/error_handlers/__init__.py,sha256=SkEDcJxlT1683rNx93K9whoS0OyUukkuOfToGtgpF58,776
@@ -170,7 +170,7 @@ airbyte_cdk/sources/declarative/retrievers/retriever.py,sha256=XPLs593Xv8c5cKMc3
170
170
  airbyte_cdk/sources/declarative/retrievers/simple_retriever.py,sha256=kgnhVQxRlFqJs2-rDu2-QH-p-GzQU3nKmSp6_aq8u0s,24550
171
171
  airbyte_cdk/sources/declarative/schema/__init__.py,sha256=xU45UvM5O4c1PSM13UHpCdh5hpW3HXy9vRRGEiAC1rg,795
172
172
  airbyte_cdk/sources/declarative/schema/default_schema_loader.py,sha256=KTACrIE23a83wsm3Rd9Eb4K6-20lrGqYxTHNp9yxsso,1820
173
- airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py,sha256=d8tfDiDcJiunvN_Yalyfx5ISY5A-iIW3HbPwX2Hagh4,10702
173
+ airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py,sha256=QG0ApZFFPVZyG8ZsdVJ5vx1vrPb7QTUdBJY8VJIaPlQ,11022
174
174
  airbyte_cdk/sources/declarative/schema/inline_schema_loader.py,sha256=bVETE10hRsatRJq3R3BeyRR0wIoK3gcP1gcpVRQ_P5U,464
175
175
  airbyte_cdk/sources/declarative/schema/json_file_schema_loader.py,sha256=5Wl-fqW-pVf_dxJ4yGHMAFfC4JjKHYJhqFJT1xA57F4,4177
176
176
  airbyte_cdk/sources/declarative/schema/schema_loader.py,sha256=kjt8v0N5wWKA5zyLnrDLxf1PJKdUqvQq2RVnAOAzNSY,379
@@ -350,8 +350,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
350
350
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
351
351
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
352
352
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
353
- airbyte_cdk-6.26.0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
354
- airbyte_cdk-6.26.0.dist-info/METADATA,sha256=tzGmGFZqFNZ_5jEwuijPrrzH5z1d5ITGm2VdZV9TzTk,5996
355
- airbyte_cdk-6.26.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
356
- airbyte_cdk-6.26.0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
357
- airbyte_cdk-6.26.0.dist-info/RECORD,,
353
+ airbyte_cdk-6.26.0.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
354
+ airbyte_cdk-6.26.0.dev0.dist-info/METADATA,sha256=g4Da91E4C4Ye-yiU-Rmg7E52t4O0pHx_w4KVJ2meuBc,6001
355
+ airbyte_cdk-6.26.0.dev0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
356
+ airbyte_cdk-6.26.0.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
357
+ airbyte_cdk-6.26.0.dev0.dist-info/RECORD,,