nucliadb-utils 6.9.5.post5447__py3-none-any.whl → 6.10.0.post5617__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.
- nucliadb_utils/audit/audit.py +11 -0
- nucliadb_utils/authentication.py +1 -2
- nucliadb_utils/const.py +1 -1
- nucliadb_utils/featureflagging.py +7 -1
- nucliadb_utils/storages/s3.py +3 -3
- nucliadb_utils/storages/storage.py +7 -11
- nucliadb_utils/utilities.py +6 -4
- {nucliadb_utils-6.9.5.post5447.dist-info → nucliadb_utils-6.10.0.post5617.dist-info}/METADATA +5 -5
- {nucliadb_utils-6.9.5.post5447.dist-info → nucliadb_utils-6.10.0.post5617.dist-info}/RECORD +11 -11
- {nucliadb_utils-6.9.5.post5447.dist-info → nucliadb_utils-6.10.0.post5617.dist-info}/WHEEL +0 -0
- {nucliadb_utils-6.9.5.post5447.dist-info → nucliadb_utils-6.10.0.post5617.dist-info}/top_level.txt +0 -0
nucliadb_utils/audit/audit.py
CHANGED
|
@@ -97,6 +97,17 @@ class AuditStorage:
|
|
|
97
97
|
):
|
|
98
98
|
raise NotImplementedError
|
|
99
99
|
|
|
100
|
+
def retrieve(
|
|
101
|
+
self,
|
|
102
|
+
kbid: str,
|
|
103
|
+
user: str,
|
|
104
|
+
client: int,
|
|
105
|
+
origin: str,
|
|
106
|
+
retrieval_time: float,
|
|
107
|
+
):
|
|
108
|
+
# TODO(decoupled-ask): implement audit for /retrieve
|
|
109
|
+
...
|
|
110
|
+
|
|
100
111
|
def report_storage(self, kbid: str, paragraphs: int, fields: int, bytes: int):
|
|
101
112
|
raise NotImplementedError
|
|
102
113
|
|
nucliadb_utils/authentication.py
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
# You should have received a copy of the GNU Affero General Public License
|
|
18
18
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
19
|
|
|
20
|
-
import asyncio
|
|
21
20
|
import functools
|
|
22
21
|
import inspect
|
|
23
22
|
import typing
|
|
@@ -137,7 +136,7 @@ def requires(
|
|
|
137
136
|
|
|
138
137
|
return websocket_wrapper
|
|
139
138
|
|
|
140
|
-
elif
|
|
139
|
+
elif inspect.iscoroutinefunction(func):
|
|
141
140
|
# Handle async request/response functions.
|
|
142
141
|
@functools.wraps(func)
|
|
143
142
|
async def async_wrapper(*args: typing.Any, **kwargs: typing.Any) -> Response:
|
nucliadb_utils/const.py
CHANGED
|
@@ -41,4 +41,4 @@ class Features:
|
|
|
41
41
|
SKIP_EXTERNAL_INDEX = "nucliadb_skip_external_index"
|
|
42
42
|
LOG_REQUEST_PAYLOADS = "nucliadb_log_request_payloads"
|
|
43
43
|
IGNORE_EXTRACTED_IN_SEARCH = "nucliadb_ignore_extracted_in_search"
|
|
44
|
-
|
|
44
|
+
ASK_DECOUPLED = "nucliadb_ask_decoupled"
|
|
@@ -30,6 +30,9 @@ from nucliadb_utils.settings import nuclia_settings, running_settings
|
|
|
30
30
|
class Settings(pydantic_settings.BaseSettings):
|
|
31
31
|
flag_settings_url: Optional[str] = None
|
|
32
32
|
|
|
33
|
+
# temporary flag to test this FF enabled/disabled easily
|
|
34
|
+
disable_ask_decoupled_ff: bool = False
|
|
35
|
+
|
|
33
36
|
|
|
34
37
|
DEFAULT_FLAG_DATA: dict[str, Any] = {
|
|
35
38
|
# These are just defaults to use for local dev and tests
|
|
@@ -45,7 +48,10 @@ DEFAULT_FLAG_DATA: dict[str, Any] = {
|
|
|
45
48
|
"rollout": 0,
|
|
46
49
|
"variants": {"environment": ["local"]},
|
|
47
50
|
},
|
|
48
|
-
const.Features.
|
|
51
|
+
const.Features.ASK_DECOUPLED: {
|
|
52
|
+
"rollout": 0,
|
|
53
|
+
"variants": {"environment": [] if Settings().disable_ask_decoupled_ff else ["local"]},
|
|
54
|
+
},
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
|
nucliadb_utils/storages/s3.py
CHANGED
|
@@ -55,12 +55,12 @@ RETRIABLE_EXCEPTIONS = (
|
|
|
55
55
|
POLICY_DELETE = {
|
|
56
56
|
"Rules": [
|
|
57
57
|
{
|
|
58
|
-
"Expiration": {"Days":
|
|
58
|
+
"Expiration": {"Days": 7},
|
|
59
59
|
"ID": "FullDelete",
|
|
60
60
|
"Filter": {"Prefix": ""},
|
|
61
61
|
"Status": "Enabled",
|
|
62
|
-
"NoncurrentVersionExpiration": {"NoncurrentDays":
|
|
63
|
-
"AbortIncompleteMultipartUpload": {"DaysAfterInitiation":
|
|
62
|
+
"NoncurrentVersionExpiration": {"NoncurrentDays": 7},
|
|
63
|
+
"AbortIncompleteMultipartUpload": {"DaysAfterInitiation": 7},
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"Expiration": {"ExpiredObjectDeleteMarker": True},
|
|
@@ -370,7 +370,7 @@ class Storage(abc.ABC, metaclass=abc.ABCMeta):
|
|
|
370
370
|
cf.source = self.source # type: ignore
|
|
371
371
|
|
|
372
372
|
if md5 is None:
|
|
373
|
-
md5hash = hashlib.md5(decoded_payload).digest()
|
|
373
|
+
md5hash = hashlib.md5(decoded_payload, usedforsecurity=False).digest()
|
|
374
374
|
cf.md5 = md5hash.decode()
|
|
375
375
|
else:
|
|
376
376
|
cf.md5 = md5
|
|
@@ -437,19 +437,18 @@ class Storage(abc.ABC, metaclass=abc.ABCMeta):
|
|
|
437
437
|
bucket: str,
|
|
438
438
|
key: str,
|
|
439
439
|
range: Optional[Range] = None,
|
|
440
|
-
):
|
|
440
|
+
) -> AsyncGenerator[bytes, None]:
|
|
441
441
|
destination: StorageField = self.field_klass(storage=self, bucket=bucket, fullkey=key)
|
|
442
442
|
try:
|
|
443
443
|
async for data in destination.iter_data(range=range):
|
|
444
444
|
yield data
|
|
445
445
|
except KeyError:
|
|
446
|
-
|
|
446
|
+
pass
|
|
447
447
|
|
|
448
448
|
async def downloadbytes(self, bucket: str, key: str) -> BytesIO:
|
|
449
449
|
result = BytesIO()
|
|
450
450
|
async for data in self.download(bucket, key):
|
|
451
|
-
|
|
452
|
-
result.write(data)
|
|
451
|
+
result.write(data)
|
|
453
452
|
|
|
454
453
|
result.seek(0)
|
|
455
454
|
return result
|
|
@@ -467,18 +466,15 @@ class Storage(abc.ABC, metaclass=abc.ABCMeta):
|
|
|
467
466
|
# this is covered by other tests
|
|
468
467
|
if cf.source == self.source:
|
|
469
468
|
async for data in self.download(cf.bucket_name, cf.uri):
|
|
470
|
-
|
|
471
|
-
yield data
|
|
469
|
+
yield data
|
|
472
470
|
elif cf.source == CloudFile.FLAPS:
|
|
473
471
|
flaps_storage = await get_nuclia_storage()
|
|
474
472
|
async for data in flaps_storage.download(cf):
|
|
475
|
-
|
|
476
|
-
yield data
|
|
473
|
+
yield data
|
|
477
474
|
elif cf.source == CloudFile.LOCAL:
|
|
478
475
|
local_storage = get_local_storage()
|
|
479
476
|
async for data in local_storage.download(cf.bucket_name, cf.uri):
|
|
480
|
-
|
|
481
|
-
yield data
|
|
477
|
+
yield data
|
|
482
478
|
|
|
483
479
|
async def upload_pb(self, sf: StorageField, payload: Any):
|
|
484
480
|
await self.upload_object(sf.bucket, sf.key, payload.SerializeToString())
|
nucliadb_utils/utilities.py
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
from __future__ import annotations
|
|
21
21
|
|
|
22
|
-
import asyncio
|
|
23
22
|
import hashlib
|
|
23
|
+
import inspect
|
|
24
24
|
import logging
|
|
25
25
|
from concurrent.futures.thread import ThreadPoolExecutor
|
|
26
26
|
from enum import Enum
|
|
@@ -273,7 +273,7 @@ def clear_global_cache():
|
|
|
273
273
|
async def finalize_utilities():
|
|
274
274
|
to_delete = []
|
|
275
275
|
for key, util in MAIN.items():
|
|
276
|
-
if hasattr(util, "finalize") and
|
|
276
|
+
if hasattr(util, "finalize") and inspect.iscoroutinefunction(util.finalize):
|
|
277
277
|
await util.finalize()
|
|
278
278
|
elif hasattr(util, "finalize"):
|
|
279
279
|
util.finalize()
|
|
@@ -420,9 +420,11 @@ def has_feature(
|
|
|
420
420
|
context = {}
|
|
421
421
|
if headers is not None:
|
|
422
422
|
if X_USER_HEADER in headers:
|
|
423
|
-
context["
|
|
423
|
+
context["user_id_sha256"] = hashlib.sha256(
|
|
424
|
+
headers[X_USER_HEADER].encode("utf-8")
|
|
425
|
+
).hexdigest()
|
|
424
426
|
if X_ACCOUNT_HEADER in headers:
|
|
425
|
-
context["
|
|
427
|
+
context["account_id_sha256"] = hashlib.sha256(headers[X_ACCOUNT_HEADER].encode()).hexdigest()
|
|
426
428
|
if X_ACCOUNT_TYPE_HEADER in headers:
|
|
427
429
|
context["account_type"] = headers[X_ACCOUNT_TYPE_HEADER]
|
|
428
430
|
return get_feature_flags().enabled(name, default=default, context=context)
|
{nucliadb_utils-6.9.5.post5447.dist-info → nucliadb_utils-6.10.0.post5617.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nucliadb_utils
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.10.0.post5617
|
|
4
4
|
Summary: NucliaDB util library
|
|
5
5
|
Author-email: Nuclia <nucliadb@nuclia.com>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -25,10 +25,10 @@ Requires-Dist: mmh3>=3.0.0
|
|
|
25
25
|
Requires-Dist: nats-py[nkeys]>=2.6.0
|
|
26
26
|
Requires-Dist: PyNaCl
|
|
27
27
|
Requires-Dist: pyjwt>=2.4.0
|
|
28
|
-
Requires-Dist: mrflagly>=0.2.
|
|
29
|
-
Requires-Dist: nidx-protos>=6.
|
|
30
|
-
Requires-Dist: nucliadb-protos>=6.
|
|
31
|
-
Requires-Dist: nucliadb-telemetry>=6.
|
|
28
|
+
Requires-Dist: mrflagly>=0.2.14
|
|
29
|
+
Requires-Dist: nidx-protos>=6.10.0.post5617
|
|
30
|
+
Requires-Dist: nucliadb-protos>=6.10.0.post5617
|
|
31
|
+
Requires-Dist: nucliadb-telemetry>=6.10.0.post5617
|
|
32
32
|
Provides-Extra: cache
|
|
33
33
|
Requires-Dist: redis>=4.3.4; extra == "cache"
|
|
34
34
|
Requires-Dist: orjson>=3.6.7; extra == "cache"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
nucliadb_utils/__init__.py,sha256=EvBCH1iTODe-AgXm48aj4kVUt_Std3PeL8QnwimR5wI,895
|
|
2
2
|
nucliadb_utils/asyncio_utils.py,sha256=h8Y-xpcFFRgNzaiIW0eidz7griAQa7ggbNk34-tAt2c,2888
|
|
3
|
-
nucliadb_utils/authentication.py,sha256=
|
|
4
|
-
nucliadb_utils/const.py,sha256=
|
|
3
|
+
nucliadb_utils/authentication.py,sha256=7fkEvJCvOg3SLiPx3FdKIGSt8ca7ilpLCN1QInjgOHo,6456
|
|
4
|
+
nucliadb_utils/const.py,sha256=F1kZzTSbJvg9YYGhSi-H6KJsfTkTiX8PER4RBAOkq40,1521
|
|
5
5
|
nucliadb_utils/debug.py,sha256=Q56Nx9Dp7V2ae3CU2H0ztaZcHTJXdlflPLKLeOPZ170,2436
|
|
6
6
|
nucliadb_utils/exceptions.py,sha256=y_3wk77WLVUtdo-5FtbBsdSkCtK_DsJkdWb5BoPn3qo,1094
|
|
7
|
-
nucliadb_utils/featureflagging.py,sha256=
|
|
7
|
+
nucliadb_utils/featureflagging.py,sha256=3VyZT8byTkMe7tFWqlxhLdeuIX9713Xy9KDL1A1sSVE,2524
|
|
8
8
|
nucliadb_utils/grpc.py,sha256=apu0uePnkGHCAT7GRQ9YZfRYyFj26kJ440i8jitbM3U,3314
|
|
9
9
|
nucliadb_utils/helpers.py,sha256=eed7_E1MKh9eW3CpqOXka3OvLw5C9eJGC_R-1MPYdfY,3336
|
|
10
10
|
nucliadb_utils/nats.py,sha256=U21Cfg36_IHd3ZLXEC4eZ7nZ1Soh_ZNFFwjryNyd2-8,15248
|
|
@@ -15,9 +15,9 @@ nucliadb_utils/settings.py,sha256=H9yKrHPR5emTxai-D4owg4CjE4_-E0qR0HyuHERQNH4,84
|
|
|
15
15
|
nucliadb_utils/signals.py,sha256=lo_Mk12NIX5Au--3H3WObvDOXq_OMurql2qiC2TnAao,2676
|
|
16
16
|
nucliadb_utils/store.py,sha256=kQ35HemE0v4_Qg6xVqNIJi8vSFAYQtwI3rDtMsNy62Y,890
|
|
17
17
|
nucliadb_utils/transaction.py,sha256=l3ZvrITYMnAs_fv1OOC-1nDZxWPG5qmbBhzvuC3DUzQ,8039
|
|
18
|
-
nucliadb_utils/utilities.py,sha256=
|
|
18
|
+
nucliadb_utils/utilities.py,sha256=yPCZFucWIvtvEaGJLfmLIjWY3Y1qhoTLH16xlaqZbyU,15859
|
|
19
19
|
nucliadb_utils/audit/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
|
20
|
-
nucliadb_utils/audit/audit.py,sha256=
|
|
20
|
+
nucliadb_utils/audit/audit.py,sha256=rDMVIV-W5-TayFrqinMMunrm_nRH9yHUICHiB9btJRo,3822
|
|
21
21
|
nucliadb_utils/audit/basic.py,sha256=fcCYvoFSGVbbB8cSCnm95bN2rf1AAeuWhGfh5no0S-Y,4246
|
|
22
22
|
nucliadb_utils/audit/stream.py,sha256=A0PK-uHW-gXxrDsggbWwbcf2x1CWfP2rYf60wSixg0k,17670
|
|
23
23
|
nucliadb_utils/cache/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
|
|
@@ -41,9 +41,9 @@ nucliadb_utils/storages/gcs.py,sha256=VyT72My34N4pEMmrQc5wdAMNLiuqpYl8OW3d50cJfS
|
|
|
41
41
|
nucliadb_utils/storages/local.py,sha256=2aCHpZymORG_dUc1FDq0VFcgQulu0w2pZiUaj9dphFs,11686
|
|
42
42
|
nucliadb_utils/storages/nuclia.py,sha256=vEv94xAT7QM2g80S25QyrOw2pzvP2BAX-ADgZLtuCVc,2097
|
|
43
43
|
nucliadb_utils/storages/object_store.py,sha256=2PueRP5Q3XOuWgKhj6B9Kp2fyBql5np0T400YRUbqn4,4535
|
|
44
|
-
nucliadb_utils/storages/s3.py,sha256=
|
|
44
|
+
nucliadb_utils/storages/s3.py,sha256=R-ZksX6e0uvp3AxHdG0rGNgvZ5XMnOR_OwGRc_F3o3M,21878
|
|
45
45
|
nucliadb_utils/storages/settings.py,sha256=mepN3wbLGL0Pv5yI6D-sNjSAFinEWT7aRi6N3eClNDg,1384
|
|
46
|
-
nucliadb_utils/storages/storage.py,sha256=
|
|
46
|
+
nucliadb_utils/storages/storage.py,sha256=HKY-2gTMC-KCsJn9jW0OO2yvwkwl5IusLPahDHsIgno,21912
|
|
47
47
|
nucliadb_utils/storages/utils.py,sha256=F4Iboa_0_bhDQr-JOKD9sGPld_-hKwJW5ptyZdn9Oag,1505
|
|
48
48
|
nucliadb_utils/tests/__init__.py,sha256=Oo9CAE7B0eW5VHn8sHd6o30SQzOWUhktLPRXdlDOleA,1456
|
|
49
49
|
nucliadb_utils/tests/asyncbenchmark.py,sha256=vrX_x9ifCXi18PfNShc23w9x_VUiB_Ph-2nuolh9z3Q,10707
|
|
@@ -53,7 +53,7 @@ nucliadb_utils/tests/gcs.py,sha256=JNqp5ymeNNU9Ci8rNYTh7-VqP4fjybElhyB3ap7EV1c,4
|
|
|
53
53
|
nucliadb_utils/tests/local.py,sha256=z9E11_ol1mu7N8Y6PkjKl-WMPPMl7JqQbDj3uhVa1A0,1933
|
|
54
54
|
nucliadb_utils/tests/nats.py,sha256=rbTaC6kv-u6SdZ7N-XBEGS40XCRiUmFUsKHIYWJfxTs,2325
|
|
55
55
|
nucliadb_utils/tests/s3.py,sha256=kz9ULxrAYLVslZ59I8dtweZ9DJz5R8Ioy2XYrveZzHw,3829
|
|
56
|
-
nucliadb_utils-6.
|
|
57
|
-
nucliadb_utils-6.
|
|
58
|
-
nucliadb_utils-6.
|
|
59
|
-
nucliadb_utils-6.
|
|
56
|
+
nucliadb_utils-6.10.0.post5617.dist-info/METADATA,sha256=jQ6YCYc6UPaNF3oaztE-iyHgdwujPX_Os8_6AdfIzB0,2179
|
|
57
|
+
nucliadb_utils-6.10.0.post5617.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
58
|
+
nucliadb_utils-6.10.0.post5617.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
|
59
|
+
nucliadb_utils-6.10.0.post5617.dist-info/RECORD,,
|
|
File without changes
|
{nucliadb_utils-6.9.5.post5447.dist-info → nucliadb_utils-6.10.0.post5617.dist-info}/top_level.txt
RENAMED
|
File without changes
|