peak-sdk 1.18.1__py3-none-any.whl → 1.18.2__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.
- peak/_version.py +1 -1
- peak/resources/cache.py +47 -11
- {peak_sdk-1.18.1.dist-info → peak_sdk-1.18.2.dist-info}/METADATA +3 -3
- {peak_sdk-1.18.1.dist-info → peak_sdk-1.18.2.dist-info}/RECORD +7 -7
- {peak_sdk-1.18.1.dist-info → peak_sdk-1.18.2.dist-info}/LICENSE +0 -0
- {peak_sdk-1.18.1.dist-info → peak_sdk-1.18.2.dist-info}/WHEEL +0 -0
- {peak_sdk-1.18.1.dist-info → peak_sdk-1.18.2.dist-info}/entry_points.txt +0 -0
peak/_version.py
CHANGED
peak/resources/cache.py
CHANGED
@@ -458,7 +458,7 @@ class CacheClient(BaseClient):
|
|
458
458
|
except json.JSONDecodeError:
|
459
459
|
pass
|
460
460
|
else:
|
461
|
-
continue
|
461
|
+
continue # pragma: no cover ; test is added still coverage issue
|
462
462
|
|
463
463
|
results.append(value_str)
|
464
464
|
|
@@ -509,6 +509,46 @@ class CacheClient(BaseClient):
|
|
509
509
|
self._debug_log(f"Set {len(mapping)} keys via mset")
|
510
510
|
return bool(result)
|
511
511
|
|
512
|
+
def _flush_keys_with_crossslot_fallback(self, keys: List[str], operation_name: str) -> int:
|
513
|
+
"""Helper method to flush keys with CROSSSLOT fallback.
|
514
|
+
|
515
|
+
Args:
|
516
|
+
keys: List of keys to delete
|
517
|
+
operation_name: Name of the operation for logging (e.g., "tenant", "pattern 'user:*'")
|
518
|
+
|
519
|
+
Returns:
|
520
|
+
int: Number of keys deleted
|
521
|
+
|
522
|
+
Raises:
|
523
|
+
ValkeyError: If non-CROSSSLOT Valkey errors occur
|
524
|
+
"""
|
525
|
+
if not keys:
|
526
|
+
return 0
|
527
|
+
|
528
|
+
client = self._get_client()
|
529
|
+
|
530
|
+
try:
|
531
|
+
result = client.delete(*keys)
|
532
|
+
deleted_count = int(cast(int, result)) if result else 0
|
533
|
+
self._debug_log(f"Flushed {deleted_count} keys for {operation_name}")
|
534
|
+
except ValkeyError as e:
|
535
|
+
if "CROSSSLOT" not in str(e):
|
536
|
+
raise
|
537
|
+
|
538
|
+
self._debug_log(f"CROSSSLOT error for {operation_name}, falling back to individual deletions")
|
539
|
+
|
540
|
+
deleted_count = 0
|
541
|
+
|
542
|
+
for key in keys:
|
543
|
+
result = client.delete(key)
|
544
|
+
if result:
|
545
|
+
deleted_count += int(cast(int, result))
|
546
|
+
|
547
|
+
self._debug_log(f"Flushed {deleted_count} keys for {operation_name} (individual)")
|
548
|
+
return deleted_count
|
549
|
+
else:
|
550
|
+
return deleted_count
|
551
|
+
|
512
552
|
def flush_tenant(self) -> int:
|
513
553
|
"""Flush all keys for the current tenant.
|
514
554
|
|
@@ -517,22 +557,20 @@ class CacheClient(BaseClient):
|
|
517
557
|
|
518
558
|
Raises:
|
519
559
|
CacheError: If the operation fails
|
560
|
+
ValkeyError: If CROSSSLOT or other Valkey-specific errors occur
|
520
561
|
"""
|
521
562
|
try:
|
522
|
-
client = self._get_client()
|
523
563
|
if not self._tenant_name:
|
524
564
|
self._get_connection_config()
|
525
565
|
|
526
566
|
pattern = f"{self._tenant_name}:*"
|
527
|
-
keys = list(
|
567
|
+
keys = list(self._get_client().scan_iter(match=pattern))
|
528
568
|
|
529
569
|
if not keys:
|
530
570
|
self._debug_log("No keys found for tenant flush")
|
531
571
|
return 0
|
532
572
|
|
533
|
-
|
534
|
-
self._debug_log(f"Flushed {result} keys for tenant: {self._tenant_name}")
|
535
|
-
return int(cast(int, result))
|
573
|
+
return self._flush_keys_with_crossslot_fallback(keys, f"tenant: {self._tenant_name}")
|
536
574
|
|
537
575
|
except (ConnectionError, TimeoutError, ValkeyError) as e:
|
538
576
|
logger.exception("Cache flush_tenant operation failed")
|
@@ -550,22 +588,20 @@ class CacheClient(BaseClient):
|
|
550
588
|
|
551
589
|
Raises:
|
552
590
|
CacheError: If the operation fails
|
591
|
+
ValkeyError: If CROSSSLOT or other Valkey-specific errors occur
|
553
592
|
"""
|
554
593
|
try:
|
555
|
-
client = self._get_client()
|
556
594
|
if not self._tenant_name:
|
557
595
|
self._get_connection_config()
|
558
596
|
|
559
597
|
prefixed_pattern = self._prefix_key(pattern)
|
560
|
-
keys = list(
|
598
|
+
keys = list(self._get_client().scan_iter(match=prefixed_pattern))
|
561
599
|
|
562
600
|
if not keys:
|
563
601
|
self._debug_log(f"No keys found for pattern: {pattern}")
|
564
602
|
return 0
|
565
603
|
|
566
|
-
|
567
|
-
self._debug_log(f"Flushed {result} keys for pattern: {pattern}")
|
568
|
-
return int(cast(int, result))
|
604
|
+
return self._flush_keys_with_crossslot_fallback(keys, f"pattern: {pattern}")
|
569
605
|
|
570
606
|
except (ConnectionError, TimeoutError, ValkeyError) as e:
|
571
607
|
logger.exception("Cache flush_by_pattern operation failed for pattern: %s", pattern)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: peak-sdk
|
3
|
-
Version: 1.18.
|
3
|
+
Version: 1.18.2
|
4
4
|
Summary: Python SDK for interacting with the Peak platform
|
5
5
|
Home-page: https://docs.peak.ai/sdk/latest/
|
6
6
|
License: Apache-2.0
|
@@ -107,7 +107,7 @@ Follow these steps to create a virtual environment using Python's built-in `venv
|
|
107
107
|
This should return a response of the following format
|
108
108
|
|
109
109
|
```bash
|
110
|
-
peak-cli==1.18.
|
110
|
+
peak-cli==1.18.2
|
111
111
|
Python==3.12.3
|
112
112
|
System==Darwin(23.6.0)
|
113
113
|
```
|
@@ -123,7 +123,7 @@ Follow these steps to create a virtual environment using Python's built-in `venv
|
|
123
123
|
This should print the version of the SDK
|
124
124
|
|
125
125
|
```
|
126
|
-
1.18.
|
126
|
+
1.18.2
|
127
127
|
```
|
128
128
|
|
129
129
|
### Using the SDK and CLI
|
@@ -1,6 +1,6 @@
|
|
1
1
|
peak/__init__.py,sha256=UaVwsRIPq0Wuti8j2x4ijGRVYywglfjvZGz6ALBA7Oo,1284
|
2
2
|
peak/_metadata.py,sha256=8w0pXN03pDvh1toM-divY6HNVF8znTqGGG2T9Q4hEl4,30672
|
3
|
-
peak/_version.py,sha256=
|
3
|
+
peak/_version.py,sha256=u8vHMdf5N2r6RSKTELvV0nQdP8TU5jS1D7c20wRgPMA,887
|
4
4
|
peak/auth.py,sha256=A6nM9VGUdPJpFTFmb1zeeHjhKfBIsAyIMmnF9ajZkgs,904
|
5
5
|
peak/base_client.py,sha256=UO25ZViCQfKbBEDEfCdKS-eLXaVzb1aGnYDntBZ77ko,1808
|
6
6
|
peak/callbacks.py,sha256=WRVxSpg0Ur3uzG1aqxX4dQ5YV_Dr4GBrwYddppztcdM,3775
|
@@ -51,7 +51,7 @@ peak/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
51
|
peak/resources/__init__.py,sha256=gB20p9gb_ImrRpOMzj9H5HjoBjRRfdpLLi1e3Y28x0c,1262
|
52
52
|
peak/resources/alerts.py,sha256=1H6n_7lsR5rNI6FUfni8ye7KCPPArcm0fTpQOYLB6lg,12792
|
53
53
|
peak/resources/artifacts.py,sha256=gKlt9bzb1xkN7meM2r5p7AcWepgFFgxFyP1tvpq57qE,15648
|
54
|
-
peak/resources/cache.py,sha256=
|
54
|
+
peak/resources/cache.py,sha256=lAPkiBpIW8xj3boR26MCh4UQlf1JkLZXwC8qJAHNZg8,24261
|
55
55
|
peak/resources/images.py,sha256=dgYOlPhwOjbiBIz0xum3PfCT9RAP4GVGxBvr8ItiJEY,46715
|
56
56
|
peak/resources/services.py,sha256=MHV4Mxm0GHf5UpQUrnwFBmC9T5qHMI4j7PuD271gV0I,17176
|
57
57
|
peak/resources/tenants.py,sha256=_rNLWQxCJeaT0mA8_fipYRjSeZ9PIlTD1u_5STbcN-c,4380
|
@@ -125,8 +125,8 @@ peak/tools/logging/log_level.py,sha256=FVe94CEtow3nfHhNr5oQk0gEt2_5mpfaiV-xTfagX
|
|
125
125
|
peak/tools/logging/logger.py,sha256=DHe--A2J7RRb5N-u0Gb3bbEApPyoUD060A1IeNvJ87Y,15986
|
126
126
|
peak/tools/logging/utils.py,sha256=XRQ0nw_lmV_iiRel-o83EE84UTjvrzLTt4H7BHlPbLg,3330
|
127
127
|
peak/validators.py,sha256=mY17UDGKJ879wY3EApqrGVs3hJvRkPhgwftvmvnKAdI,2715
|
128
|
-
peak_sdk-1.18.
|
129
|
-
peak_sdk-1.18.
|
130
|
-
peak_sdk-1.18.
|
131
|
-
peak_sdk-1.18.
|
132
|
-
peak_sdk-1.18.
|
128
|
+
peak_sdk-1.18.2.dist-info/LICENSE,sha256=W0jszenKx7YdFA7BDnyg8xDKXzCP8AperJb_PHh9paQ,11340
|
129
|
+
peak_sdk-1.18.2.dist-info/METADATA,sha256=6uS2CI1sCUx8m3PS78-GFkft1oVTk-5Nul-6bpntIWk,7974
|
130
|
+
peak_sdk-1.18.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
131
|
+
peak_sdk-1.18.2.dist-info/entry_points.txt,sha256=zHCEjuOTjkfmqivgEZQsPGm4zFA4W3Q_vKCjPr7W6lE,47
|
132
|
+
peak_sdk-1.18.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|