nucliadb-utils 5.0.1.post1116__py3-none-any.whl → 5.0.1.post1123__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/const.py CHANGED
@@ -83,4 +83,4 @@ class Features:
83
83
  PG_CATALOG_WRITE = "nucliadb_pg_catalog_write"
84
84
  VECTORSETS_V0 = "vectorsets_v0_new_kbs_with_multiple_vectorsets"
85
85
  SKIP_EXTERNAL_INDEX = "nucliadb_skip_external_index"
86
- NATS_ASYNC_ACK = "nucliadb_nats_async_ack"
86
+ NATS_SYNC_ACK = "nucliadb_nats_sync_ack"
@@ -81,7 +81,7 @@ DEFAULT_FLAG_DATA: dict[str, Any] = {
81
81
  "rollout": 0,
82
82
  "variants": {"environment": ["none"]},
83
83
  },
84
- const.Features.NATS_ASYNC_ACK: {
84
+ const.Features.NATS_SYNC_ACK: {
85
85
  "rollout": 0,
86
86
  "variants": {"environment": ["local"]},
87
87
  },
@@ -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 not None:
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
- req = google.auth.transport.requests.Request()
484
- self._credentials.refresh(req)
485
- self._creation_access_token = datetime.now()
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 = f"{self.object_base_url}/{bucket_name}?project={self._project}"
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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nucliadb_utils
3
- Version: 5.0.1.post1116
3
+ Version: 5.0.1.post1123
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.post1116
28
- Requires-Dist: nucliadb-telemetry>=5.0.1.post1116
27
+ Requires-Dist: nucliadb-protos>=5.0.1.post1123
28
+ Requires-Dist: nucliadb-telemetry>=5.0.1.post1123
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"
@@ -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
3
  nucliadb_utils/authentication.py,sha256=N__d2Ez3JHJv5asYK5TgUcIkKqcAC8ZTLlnfLhfSneM,5837
4
- nucliadb_utils/const.py,sha256=AYtxOqOoyDXYzsca0UTXbt6ACZsgoyfItorybDGKHdc,2723
4
+ nucliadb_utils/const.py,sha256=siuc-LfMeLjSWxw84QoAoGNhPt5YwLOArMiytCrHOlQ,2721
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=H_qW7nE2k5wS7mv1m5SXayuvDDhTHYPwqTfW5-eVzEI,3422
7
+ nucliadb_utils/featureflagging.py,sha256=TLJl8J5BlI0ypvsNg75qseKuBhP4FcLGXBQyhATI4pI,3421
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
@@ -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=k1WXZDBQXSizO_3kEJef7EmyInnASJsAy5VTtEw8ly4,27020
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.post1116.dist-info/METADATA,sha256=KpdqhX5ztjM8y5_ScL4v-NM9eAhMDLxbtJDEzeoXv6s,2071
68
- nucliadb_utils-5.0.1.post1116.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
69
- nucliadb_utils-5.0.1.post1116.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
70
- nucliadb_utils-5.0.1.post1116.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
71
- nucliadb_utils-5.0.1.post1116.dist-info/RECORD,,
67
+ nucliadb_utils-5.0.1.post1123.dist-info/METADATA,sha256=tCZ3-_OkPMlbK_M8G-TxzG4H3qGv8mZ_SiK-58VEiWI,2071
68
+ nucliadb_utils-5.0.1.post1123.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
69
+ nucliadb_utils-5.0.1.post1123.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
70
+ nucliadb_utils-5.0.1.post1123.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
71
+ nucliadb_utils-5.0.1.post1123.dist-info/RECORD,,