nucliadb-utils 5.0.1.post1100__py3-none-any.whl → 5.0.1.post1105__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/nats.py +4 -1
- nucliadb_utils/storages/gcs.py +22 -7
- {nucliadb_utils-5.0.1.post1100.dist-info → nucliadb_utils-5.0.1.post1105.dist-info}/METADATA +3 -3
- {nucliadb_utils-5.0.1.post1100.dist-info → nucliadb_utils-5.0.1.post1105.dist-info}/RECORD +7 -7
- {nucliadb_utils-5.0.1.post1100.dist-info → nucliadb_utils-5.0.1.post1105.dist-info}/WHEEL +0 -0
- {nucliadb_utils-5.0.1.post1100.dist-info → nucliadb_utils-5.0.1.post1105.dist-info}/top_level.txt +0 -0
- {nucliadb_utils-5.0.1.post1100.dist-info → nucliadb_utils-5.0.1.post1105.dist-info}/zip-safe +0 -0
nucliadb_utils/nats.py
CHANGED
@@ -31,6 +31,7 @@ from nats.aio.client import Msg
|
|
31
31
|
from nats.aio.subscription import Subscription
|
32
32
|
from nats.js.client import JetStreamContext
|
33
33
|
|
34
|
+
from nucliadb_telemetry.errors import capture_exception
|
34
35
|
from nucliadb_telemetry.jetstream import JetStreamContextTelemetry
|
35
36
|
from nucliadb_telemetry.utils import get_telemetry
|
36
37
|
|
@@ -74,7 +75,9 @@ class MessageProgressUpdater:
|
|
74
75
|
await self._task
|
75
76
|
except asyncio.CancelledError: # pragma: no cover
|
76
77
|
pass
|
77
|
-
except Exception: # pragma: no cover
|
78
|
+
except Exception as exc: # pragma: no cover
|
79
|
+
capture_exception(exc)
|
80
|
+
logger.exception("Error in MessageProgressUpdater")
|
78
81
|
pass
|
79
82
|
|
80
83
|
async def __aenter__(self):
|
nucliadb_utils/storages/gcs.py
CHANGED
@@ -34,6 +34,7 @@ import aiohttp.client_exceptions
|
|
34
34
|
import backoff
|
35
35
|
import google.auth.transport.requests # type: ignore
|
36
36
|
import yarl
|
37
|
+
from google.auth.exceptions import DefaultCredentialsError # type: ignore
|
37
38
|
from google.oauth2 import service_account # type: ignore
|
38
39
|
|
39
40
|
from nucliadb_protos.resources_pb2 import CloudFile
|
@@ -458,12 +459,25 @@ class GCSStorage(Storage):
|
|
458
459
|
url: str = "https://www.googleapis.com",
|
459
460
|
scopes: Optional[List[str]] = None,
|
460
461
|
):
|
461
|
-
if account_credentials is
|
462
|
+
if account_credentials is None:
|
463
|
+
self._json_credentials = None
|
464
|
+
elif isinstance(account_credentials, str) and account_credentials.strip() == "":
|
465
|
+
self._json_credentials = None
|
466
|
+
else:
|
462
467
|
self._json_credentials = json.loads(base64.b64decode(account_credentials))
|
468
|
+
|
469
|
+
if self._json_credentials is not None:
|
463
470
|
self._credentials = service_account.Credentials.from_service_account_info(
|
464
471
|
self._json_credentials,
|
465
472
|
scopes=DEFAULT_SCOPES if scopes is None else scopes,
|
466
473
|
)
|
474
|
+
else:
|
475
|
+
try:
|
476
|
+
self._credentials, self._project = google.auth.default()
|
477
|
+
except DefaultCredentialsError:
|
478
|
+
logger.warning("Setting up without credentials as couldn't find workload identity")
|
479
|
+
self._credentials = None
|
480
|
+
|
467
481
|
self.source = CloudFile.GCS
|
468
482
|
self.deadletter_bucket = deadletter_bucket
|
469
483
|
self.indexing_bucket = indexing_bucket
|
@@ -473,16 +487,15 @@ class GCSStorage(Storage):
|
|
473
487
|
# https://cloud.google.com/storage/docs/bucket-locations
|
474
488
|
self._bucket_labels = labels or {}
|
475
489
|
self._executor = executor
|
476
|
-
self._creation_access_token = datetime.now()
|
477
490
|
self._upload_url = url + "/upload/storage/v1/b/{bucket}/o?uploadType=resumable" # noqa
|
478
491
|
self.object_base_url = url + "/storage/v1/b"
|
479
492
|
self._client = None
|
480
493
|
|
481
494
|
def _get_access_token(self):
|
482
|
-
if self._credentials.valid is False:
|
483
|
-
|
484
|
-
self._credentials.refresh(
|
485
|
-
|
495
|
+
if self._credentials.expired or self._credentials.valid is False:
|
496
|
+
request = google.auth.transport.requests.Request()
|
497
|
+
self._credentials.refresh(request)
|
498
|
+
|
486
499
|
return self._credentials.token
|
487
500
|
|
488
501
|
@storage_ops_observer.wrap({"type": "initialize"})
|
@@ -552,7 +565,9 @@ class GCSStorage(Storage):
|
|
552
565
|
raise AttributeError()
|
553
566
|
|
554
567
|
headers = await self.get_access_headers()
|
555
|
-
url
|
568
|
+
# Using object access url instead of bucket access to avoid
|
569
|
+
# giving admin permission to the SA, needed to GET a bucket
|
570
|
+
url = f"{self.object_base_url}/{bucket_name}/o"
|
556
571
|
async with self.session.get(
|
557
572
|
url,
|
558
573
|
headers=headers,
|
{nucliadb_utils-5.0.1.post1100.dist-info → nucliadb_utils-5.0.1.post1105.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nucliadb_utils
|
3
|
-
Version: 5.0.1.
|
3
|
+
Version: 5.0.1.post1105
|
4
4
|
Home-page: https://nuclia.com
|
5
5
|
License: BSD
|
6
6
|
Classifier: Development Status :: 4 - Beta
|
@@ -24,8 +24,8 @@ Requires-Dist: PyNaCl
|
|
24
24
|
Requires-Dist: pyjwt>=2.4.0
|
25
25
|
Requires-Dist: memorylru>=1.1.2
|
26
26
|
Requires-Dist: mrflagly>=0.2.9
|
27
|
-
Requires-Dist: nucliadb-protos>=5.0.1.
|
28
|
-
Requires-Dist: nucliadb-telemetry>=5.0.1.
|
27
|
+
Requires-Dist: nucliadb-protos>=5.0.1.post1105
|
28
|
+
Requires-Dist: nucliadb-telemetry>=5.0.1.post1105
|
29
29
|
Provides-Extra: cache
|
30
30
|
Requires-Dist: redis>=4.3.4; extra == "cache"
|
31
31
|
Requires-Dist: orjson>=3.6.7; extra == "cache"
|
@@ -8,7 +8,7 @@ nucliadb_utils/featureflagging.py,sha256=0nN3vmtaEs6rB2uFQn0kI88It9568gcZ0GWWeWI
|
|
8
8
|
nucliadb_utils/grpc.py,sha256=apu0uePnkGHCAT7GRQ9YZfRYyFj26kJ440i8jitbM3U,3314
|
9
9
|
nucliadb_utils/helpers.py,sha256=nPw8yod3hP-pxq80VF8QC36s7ygSg0dBUdfI-LatvCs,1600
|
10
10
|
nucliadb_utils/indexing.py,sha256=Luaqcar3CySpdYOFp6Q9Fyr8ZYwhYhaKRHQ_VGL78f8,2318
|
11
|
-
nucliadb_utils/nats.py,sha256=
|
11
|
+
nucliadb_utils/nats.py,sha256=b7_ZqBTtacnfTeErfeozXTLXbTL27JwqF1-SUEe9VmM,8370
|
12
12
|
nucliadb_utils/partition.py,sha256=jBgy4Hu5Iwn4gjbPPcthSykwf-qNx-GcLAIwbzPd1d0,1157
|
13
13
|
nucliadb_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
14
|
nucliadb_utils/run.py,sha256=HpAIM8xbR7UpVC2_7xOjB4fYbUVykyPP6yHrv2RD3DI,1707
|
@@ -47,7 +47,7 @@ nucliadb_utils/nuclia_usage/utils/kb_usage_report.py,sha256=lTr9CMBpdk34KtkH5K8v
|
|
47
47
|
nucliadb_utils/storages/__init__.py,sha256=5Qc8AUWiJv9_JbGCBpAn88AIJhwDlm0OPQpg2ZdRL4U,872
|
48
48
|
nucliadb_utils/storages/azure.py,sha256=egMDwLNIGSQyVevuySt2AswzFdNAcih05BbRg3-p8IU,16015
|
49
49
|
nucliadb_utils/storages/exceptions.py,sha256=mm_wX4YRtp7u7enkk_4pMSlX5AQQuFbq4xLmupVDt3Y,2502
|
50
|
-
nucliadb_utils/storages/gcs.py,sha256=
|
50
|
+
nucliadb_utils/storages/gcs.py,sha256=TQlPpg9HzfHbOu_iCLPUo9KAql1IIjWxJ9mVJ9_CrV8,27658
|
51
51
|
nucliadb_utils/storages/local.py,sha256=NxC_nMBd38NDsR266DSgoBLdQlvUwf0_sd50r-BLI0E,10288
|
52
52
|
nucliadb_utils/storages/nuclia.py,sha256=vEv94xAT7QM2g80S25QyrOw2pzvP2BAX-ADgZLtuCVc,2097
|
53
53
|
nucliadb_utils/storages/object_store.py,sha256=Tw10GmpYfM5TMqJ3Tk9pLQ9wLMBk1-snL_m6uasiZDQ,4257
|
@@ -64,8 +64,8 @@ nucliadb_utils/tests/indexing.py,sha256=YW2QhkhO9Q_8A4kKWJaWSvXvyQ_AiAwY1VylcfVQ
|
|
64
64
|
nucliadb_utils/tests/local.py,sha256=7nuP8EFUAiA8ZH50R1iPV9EUXBySQxOanVm3Zht_e0g,1835
|
65
65
|
nucliadb_utils/tests/nats.py,sha256=xqpww4jZjTKY9oPGlJdDJG67L3FIBQsa9qDHxILR8r8,7687
|
66
66
|
nucliadb_utils/tests/s3.py,sha256=IdMxK_cNdSHLvO1u8BwsKFzD87Hk1MVPDZ57zx6h-rA,3656
|
67
|
-
nucliadb_utils-5.0.1.
|
68
|
-
nucliadb_utils-5.0.1.
|
69
|
-
nucliadb_utils-5.0.1.
|
70
|
-
nucliadb_utils-5.0.1.
|
71
|
-
nucliadb_utils-5.0.1.
|
67
|
+
nucliadb_utils-5.0.1.post1105.dist-info/METADATA,sha256=y9QyvD9UC_-nFbonzN0VXqeBjILdE2Qv5oD99unablE,2071
|
68
|
+
nucliadb_utils-5.0.1.post1105.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
69
|
+
nucliadb_utils-5.0.1.post1105.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
70
|
+
nucliadb_utils-5.0.1.post1105.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
71
|
+
nucliadb_utils-5.0.1.post1105.dist-info/RECORD,,
|
File without changes
|
{nucliadb_utils-5.0.1.post1100.dist-info → nucliadb_utils-5.0.1.post1105.dist-info}/top_level.txt
RENAMED
File without changes
|
{nucliadb_utils-5.0.1.post1100.dist-info → nucliadb_utils-5.0.1.post1105.dist-info}/zip-safe
RENAMED
File without changes
|