airbyte-cdk 6.27.0__py3-none-any.whl → 6.27.1__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/sources/declarative/incremental/concurrent_partition_cursor.py +29 -13
- {airbyte_cdk-6.27.0.dist-info → airbyte_cdk-6.27.1.dist-info}/METADATA +1 -1
- {airbyte_cdk-6.27.0.dist-info → airbyte_cdk-6.27.1.dist-info}/RECORD +6 -6
- {airbyte_cdk-6.27.0.dist-info → airbyte_cdk-6.27.1.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.27.0.dist-info → airbyte_cdk-6.27.1.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.27.0.dist-info → airbyte_cdk-6.27.1.dist-info}/entry_points.txt +0 -0
@@ -95,6 +95,7 @@ class ConcurrentPerPartitionCursor(Cursor):
|
|
95
95
|
self._lookback_window: int = 0
|
96
96
|
self._parent_state: Optional[StreamState] = None
|
97
97
|
self._over_limit: int = 0
|
98
|
+
self._use_global_cursor: bool = False
|
98
99
|
self._partition_serializer = PerPartitionKeySerializer()
|
99
100
|
|
100
101
|
self._set_initial_state(stream_state)
|
@@ -105,16 +106,18 @@ class ConcurrentPerPartitionCursor(Cursor):
|
|
105
106
|
|
106
107
|
@property
|
107
108
|
def state(self) -> MutableMapping[str, Any]:
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
109
|
+
state: dict[str, Any] = {"use_global_cursor": self._use_global_cursor}
|
110
|
+
if not self._use_global_cursor:
|
111
|
+
states = []
|
112
|
+
for partition_tuple, cursor in self._cursor_per_partition.items():
|
113
|
+
if cursor.state:
|
114
|
+
states.append(
|
115
|
+
{
|
116
|
+
"partition": self._to_dict(partition_tuple),
|
117
|
+
"cursor": copy.deepcopy(cursor.state),
|
118
|
+
}
|
119
|
+
)
|
120
|
+
state[self._PERPARTITION_STATE_KEY] = states
|
118
121
|
|
119
122
|
if self._global_cursor:
|
120
123
|
state[self._GLOBAL_STATE_KEY] = self._global_cursor
|
@@ -147,7 +150,8 @@ class ConcurrentPerPartitionCursor(Cursor):
|
|
147
150
|
< cursor.state[self.cursor_field.cursor_field_key]
|
148
151
|
):
|
149
152
|
self._new_global_cursor = copy.deepcopy(cursor.state)
|
150
|
-
self.
|
153
|
+
if not self._use_global_cursor:
|
154
|
+
self._emit_state_message()
|
151
155
|
|
152
156
|
def ensure_at_least_one_state_emitted(self) -> None:
|
153
157
|
"""
|
@@ -225,14 +229,18 @@ class ConcurrentPerPartitionCursor(Cursor):
|
|
225
229
|
"""
|
226
230
|
with self._lock:
|
227
231
|
while len(self._cursor_per_partition) > self.DEFAULT_MAX_PARTITIONS_NUMBER - 1:
|
232
|
+
self._over_limit += 1
|
228
233
|
# Try removing finished partitions first
|
229
234
|
for partition_key in list(self._cursor_per_partition.keys()):
|
230
|
-
if
|
235
|
+
if (
|
236
|
+
partition_key in self._finished_partitions
|
237
|
+
and self._semaphore_per_partition[partition_key]._value == 0
|
238
|
+
):
|
231
239
|
oldest_partition = self._cursor_per_partition.pop(
|
232
240
|
partition_key
|
233
241
|
) # Remove the oldest partition
|
234
242
|
logger.warning(
|
235
|
-
f"The maximum number of partitions has been reached. Dropping the oldest partition: {oldest_partition}. Over limit: {self._over_limit}."
|
243
|
+
f"The maximum number of partitions has been reached. Dropping the oldest finished partition: {oldest_partition}. Over limit: {self._over_limit}."
|
236
244
|
)
|
237
245
|
break
|
238
246
|
else:
|
@@ -297,6 +305,8 @@ class ConcurrentPerPartitionCursor(Cursor):
|
|
297
305
|
self._new_global_cursor = deepcopy(stream_state)
|
298
306
|
|
299
307
|
else:
|
308
|
+
self._use_global_cursor = stream_state.get("use_global_cursor", False)
|
309
|
+
|
300
310
|
self._lookback_window = int(stream_state.get("lookback_window", 0))
|
301
311
|
|
302
312
|
for state in stream_state.get(self._PERPARTITION_STATE_KEY, []):
|
@@ -320,6 +330,9 @@ class ConcurrentPerPartitionCursor(Cursor):
|
|
320
330
|
self._partition_router.set_initial_state(stream_state)
|
321
331
|
|
322
332
|
def observe(self, record: Record) -> None:
|
333
|
+
if not self._use_global_cursor and self.limit_reached():
|
334
|
+
self._use_global_cursor = True
|
335
|
+
|
323
336
|
if not record.associated_slice:
|
324
337
|
raise ValueError(
|
325
338
|
"Invalid state as stream slices that are emitted should refer to an existing cursor"
|
@@ -358,3 +371,6 @@ class ConcurrentPerPartitionCursor(Cursor):
|
|
358
371
|
)
|
359
372
|
cursor = self._cursor_per_partition[partition_key]
|
360
373
|
return cursor
|
374
|
+
|
375
|
+
def limit_reached(self) -> bool:
|
376
|
+
return self._over_limit > self.DEFAULT_MAX_PARTITIONS_NUMBER
|
@@ -88,7 +88,7 @@ airbyte_cdk/sources/declarative/extractors/record_selector.py,sha256=tjNwcURmlyD
|
|
88
88
|
airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py,sha256=LhqGDfX06_dDYLKsIVnwQ_nAWCln-v8PV7Wgt_QVeTI,6533
|
89
89
|
airbyte_cdk/sources/declarative/extractors/type_transformer.py,sha256=d6Y2Rfg8pMVEEnHllfVksWZdNVOU55yk34O03dP9muY,1626
|
90
90
|
airbyte_cdk/sources/declarative/incremental/__init__.py,sha256=U1oZKtBaEC6IACmvziY9Wzg7Z8EgF4ZuR7NwvjlB_Sk,1255
|
91
|
-
airbyte_cdk/sources/declarative/incremental/concurrent_partition_cursor.py,sha256=
|
91
|
+
airbyte_cdk/sources/declarative/incremental/concurrent_partition_cursor.py,sha256=ndUZaPW0MsN4_3cGpB-0Uu0otSPnmPmHgbixoJeDmjA,16660
|
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
|
@@ -350,8 +350,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EDxgROHDbfG-QKQb59m7h_7crN1tRiawdf5uU7G
|
|
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.27.
|
354
|
-
airbyte_cdk-6.27.
|
355
|
-
airbyte_cdk-6.27.
|
356
|
-
airbyte_cdk-6.27.
|
357
|
-
airbyte_cdk-6.27.
|
353
|
+
airbyte_cdk-6.27.1.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
|
354
|
+
airbyte_cdk-6.27.1.dist-info/METADATA,sha256=AcPy77_BLTNdNMhoiJ8b1USZzg5ovw8D5FjiFwGzpys,5996
|
355
|
+
airbyte_cdk-6.27.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
356
|
+
airbyte_cdk-6.27.1.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
|
357
|
+
airbyte_cdk-6.27.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|