port-ocean 0.30.5__py3-none-any.whl → 0.30.6__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.
- port_ocean/tests/utils/test_cache.py +34 -0
- port_ocean/utils/cache.py +3 -2
- {port_ocean-0.30.5.dist-info → port_ocean-0.30.6.dist-info}/METADATA +1 -1
- {port_ocean-0.30.5.dist-info → port_ocean-0.30.6.dist-info}/RECORD +7 -7
- {port_ocean-0.30.5.dist-info → port_ocean-0.30.6.dist-info}/LICENSE.md +0 -0
- {port_ocean-0.30.5.dist-info → port_ocean-0.30.6.dist-info}/WHEEL +0 -0
- {port_ocean-0.30.5.dist-info → port_ocean-0.30.6.dist-info}/entry_points.txt +0 -0
|
@@ -512,3 +512,37 @@ async def test_regular_coroutine_with_self_param_not_filtered(
|
|
|
512
512
|
|
|
513
513
|
# Keys should not be the same because 'self' is not filtered
|
|
514
514
|
assert key1 != key2
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
@pytest.mark.asyncio
|
|
518
|
+
async def test_cache_iterator_maintains_chunks(
|
|
519
|
+
mock_ocean: Any, monkeypatch: Any
|
|
520
|
+
) -> None:
|
|
521
|
+
monkeypatch.setattr(cache, "ocean", mock_ocean)
|
|
522
|
+
|
|
523
|
+
call_count = 0
|
|
524
|
+
|
|
525
|
+
@cache.cache_iterator_result()
|
|
526
|
+
async def chunked_iterator() -> AsyncGenerator[List[int], None]:
|
|
527
|
+
nonlocal call_count
|
|
528
|
+
call_count += 1
|
|
529
|
+
yield [1, 2]
|
|
530
|
+
await asyncio.sleep(0.01)
|
|
531
|
+
yield [3, 4]
|
|
532
|
+
|
|
533
|
+
# First call - populates cache
|
|
534
|
+
results1 = []
|
|
535
|
+
async for chunk in chunked_iterator():
|
|
536
|
+
results1.append(chunk)
|
|
537
|
+
|
|
538
|
+
assert results1 == [[1, 2], [3, 4]]
|
|
539
|
+
assert call_count == 1
|
|
540
|
+
|
|
541
|
+
# Second call - reads from cache
|
|
542
|
+
results2 = []
|
|
543
|
+
async for chunk in chunked_iterator():
|
|
544
|
+
results2.append(chunk)
|
|
545
|
+
|
|
546
|
+
# Verify structure is preserved (chunks remain separate)
|
|
547
|
+
assert results2 == [[1, 2], [3, 4]]
|
|
548
|
+
assert call_count == 1
|
port_ocean/utils/cache.py
CHANGED
|
@@ -86,7 +86,8 @@ def cache_iterator_result() -> Callable[[AsyncIteratorCallable], AsyncIteratorCa
|
|
|
86
86
|
# Check if the result is already in the cache
|
|
87
87
|
try:
|
|
88
88
|
if cache := await ocean.app.cache_provider.get(cache_key):
|
|
89
|
-
|
|
89
|
+
for chunk in cache:
|
|
90
|
+
yield chunk
|
|
90
91
|
return
|
|
91
92
|
except FailedToReadCacheError as e:
|
|
92
93
|
logger.warning(f"Failed to read cache for {cache_key}: {str(e)}")
|
|
@@ -94,7 +95,7 @@ def cache_iterator_result() -> Callable[[AsyncIteratorCallable], AsyncIteratorCa
|
|
|
94
95
|
# If not in cache, fetch the data
|
|
95
96
|
cached_results = list()
|
|
96
97
|
async for result in func(*args, **kwargs):
|
|
97
|
-
cached_results.
|
|
98
|
+
cached_results.append(result)
|
|
98
99
|
yield result
|
|
99
100
|
|
|
100
101
|
# Cache the results
|
|
@@ -210,11 +210,11 @@ port_ocean/tests/test_metrics_endpoints.py,sha256=cOljs3NweC1hyP03iEaPKGv1Vt_y0O
|
|
|
210
210
|
port_ocean/tests/test_ocean.py,sha256=bsXKGTVEjwLSbR7-qSmI4GZ-EzDo0eBE3TNSMsWzYxM,1502
|
|
211
211
|
port_ocean/tests/test_smoke.py,sha256=uix2uIg_yOm8BHDgHw2hTFPy1fiIyxBGW3ENU_KoFlo,2557
|
|
212
212
|
port_ocean/tests/utils/test_async_iterators.py,sha256=3PLk1emEXekb8LcC5GgVh3OicaX15i5WyaJT_eFnu_4,1336
|
|
213
|
-
port_ocean/tests/utils/test_cache.py,sha256=
|
|
213
|
+
port_ocean/tests/utils/test_cache.py,sha256=EKXZeUrCuMOr1XW1E0ObqOXyRiziy9z2-EDG1pIRhWc,16441
|
|
214
214
|
port_ocean/utils/__init__.py,sha256=KMGnCPXZJbNwtgxtyMycapkDz8tpSyw23MSYT3iVeHs,91
|
|
215
215
|
port_ocean/utils/async_http.py,sha256=aDsw3gQIMwt6qLegbZtkHqD8em48tKvbITnblsrTY3g,1260
|
|
216
216
|
port_ocean/utils/async_iterators.py,sha256=CPXskYWkhkZtAG-ducEwM8537t3z5usPEqXR9vcivzw,3715
|
|
217
|
-
port_ocean/utils/cache.py,sha256=
|
|
217
|
+
port_ocean/utils/cache.py,sha256=yLifQ4HWDxsAcHnigmq3CKUmFuc-X5uwuoFOEEfQWec,5444
|
|
218
218
|
port_ocean/utils/ipc.py,sha256=eTjTTvsKl6IXYeOkIjP5iyrw-8gLQ9rf15WeyxCqXog,912
|
|
219
219
|
port_ocean/utils/misc.py,sha256=cQGBWL9IN7ER6s7xyHzeKvj60ntW70WiYIq9MyLe1nY,2123
|
|
220
220
|
port_ocean/utils/queue_utils.py,sha256=KWWl8YVnG-glcfIHhM6nefY-2sou_C6DVP1VynQwzB4,2762
|
|
@@ -222,8 +222,8 @@ port_ocean/utils/repeat.py,sha256=U2OeCkHPWXmRTVoPV-VcJRlQhcYqPWI5NfmPlb1JIbc,32
|
|
|
222
222
|
port_ocean/utils/signal.py,sha256=J1sI-e_32VHP_VUa5bskLMFoJjJOAk5isrnewKDikUI,2125
|
|
223
223
|
port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
|
|
224
224
|
port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
|
|
225
|
-
port_ocean-0.30.
|
|
226
|
-
port_ocean-0.30.
|
|
227
|
-
port_ocean-0.30.
|
|
228
|
-
port_ocean-0.30.
|
|
229
|
-
port_ocean-0.30.
|
|
225
|
+
port_ocean-0.30.6.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
226
|
+
port_ocean-0.30.6.dist-info/METADATA,sha256=BlLsJnW8QY_XFDiUKrofacXtzp277VrkaaCiFSEeFSc,7095
|
|
227
|
+
port_ocean-0.30.6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
228
|
+
port_ocean-0.30.6.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
|
|
229
|
+
port_ocean-0.30.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|