Skip to content

Commit 08f89df

Browse files
committed
Revert fixes for caching
1 parent 9057702 commit 08f89df

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

airbyte_cdk/sources/declarative/incremental/concurrent_partition_cursor.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -295,20 +295,16 @@ def _generate_slices_from_partition(
295295
):
296296
self._partition_parent_state_map[partition_key] = (deepcopy(parent_state), seq)
297297

298-
try:
299-
for cursor_slice, is_last_slice, _ in iterate_with_last_flag_and_state(
300-
cursor.stream_slices(),
301-
lambda: None,
302-
):
303-
self._semaphore_per_partition[partition_key].release()
304-
if is_last_slice:
305-
self._partitions_done_generating_stream_slices.add(partition_key)
306-
yield StreamSlice(
307-
partition=partition, cursor_slice=cursor_slice, extra_fields=partition.extra_fields
308-
)
309-
finally:
310-
del cursor
311-
del partition
298+
for cursor_slice, is_last_slice, _ in iterate_with_last_flag_and_state(
299+
cursor.stream_slices(),
300+
lambda: None,
301+
):
302+
self._semaphore_per_partition[partition_key].release()
303+
if is_last_slice:
304+
self._partitions_done_generating_stream_slices.add(partition_key)
305+
yield StreamSlice(
306+
partition=partition, cursor_slice=cursor_slice, extra_fields=partition.extra_fields
307+
)
312308

313309
def _ensure_partition_limit(self) -> None:
314310
"""
@@ -496,10 +492,11 @@ def _to_dict(self, partition_key: str) -> Mapping[str, Any]:
496492
def _create_cursor(
497493
self, cursor_state: Any, runtime_lookback_window: int = 0
498494
) -> ConcurrentCursor:
499-
return self._cursor_factory.create(
495+
cursor = self._cursor_factory.create(
500496
stream_state=deepcopy(cursor_state),
501497
runtime_lookback_window=timedelta(seconds=runtime_lookback_window),
502498
)
499+
return cursor
503500

504501
def should_be_synced(self, record: Record) -> bool:
505502
return self._get_cursor(record).should_be_synced(record)
@@ -514,7 +511,8 @@ def _get_cursor(self, record: Record) -> ConcurrentCursor:
514511
raise ValueError(
515512
"Invalid state as stream slices that are emitted should refer to an existing cursor"
516513
)
517-
return self._cursor_per_partition[partition_key]
514+
cursor = self._cursor_per_partition[partition_key]
515+
return cursor
518516

519517
def limit_reached(self) -> bool:
520518
return self._number_of_partitions > self.SWITCH_TO_GLOBAL_LIMIT

airbyte_cdk/sources/declarative/interpolation/jinja.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ def _eval(self, s: Optional[str], context: Mapping[str, Any]) -> Optional[str]:
145145
# It can be returned as is
146146
return s
147147

148-
# @cache
148+
@cache
149149
def _find_undeclared_variables(self, s: Optional[str]) -> Set[str]:
150150
"""
151151
Find undeclared variables and cache them
152152
"""
153153
ast = _ENVIRONMENT.parse(s) # type: ignore # parse is able to handle None
154154
return meta.find_undeclared_variables(ast)
155155

156-
# @cache
156+
@cache
157157
def _compile(self, s: str) -> Template:
158158
"""
159159
We must cache the Jinja Template ourselves because we're using `from_string` instead of a template loader

0 commit comments

Comments
 (0)