nucliadb-utils 5.0.1.post1105__py3-none-any.whl → 5.0.1.post1114__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 CHANGED
@@ -74,6 +74,7 @@ class MessageProgressUpdater:
74
74
  try:
75
75
  await self._task
76
76
  except asyncio.CancelledError: # pragma: no cover
77
+ logger.info("MessageProgressUpdater cancelled")
77
78
  pass
78
79
  except Exception as exc: # pragma: no cover
79
80
  capture_exception(exc)
@@ -34,7 +34,6 @@ 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
38
37
  from google.oauth2 import service_account # type: ignore
39
38
 
40
39
  from nucliadb_protos.resources_pb2 import CloudFile
@@ -459,25 +458,12 @@ class GCSStorage(Storage):
459
458
  url: str = "https://www.googleapis.com",
460
459
  scopes: Optional[List[str]] = None,
461
460
  ):
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:
461
+ if account_credentials is not None:
467
462
  self._json_credentials = json.loads(base64.b64decode(account_credentials))
468
-
469
- if self._json_credentials is not None:
470
463
  self._credentials = service_account.Credentials.from_service_account_info(
471
464
  self._json_credentials,
472
465
  scopes=DEFAULT_SCOPES if scopes is None else scopes,
473
466
  )
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
-
481
467
  self.source = CloudFile.GCS
482
468
  self.deadletter_bucket = deadletter_bucket
483
469
  self.indexing_bucket = indexing_bucket
@@ -487,15 +473,16 @@ class GCSStorage(Storage):
487
473
  # https://cloud.google.com/storage/docs/bucket-locations
488
474
  self._bucket_labels = labels or {}
489
475
  self._executor = executor
476
+ self._creation_access_token = datetime.now()
490
477
  self._upload_url = url + "/upload/storage/v1/b/{bucket}/o?uploadType=resumable" # noqa
491
478
  self.object_base_url = url + "/storage/v1/b"
492
479
  self._client = None
493
480
 
494
481
  def _get_access_token(self):
495
- if self._credentials.expired or self._credentials.valid is False:
496
- request = google.auth.transport.requests.Request()
497
- self._credentials.refresh(request)
498
-
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()
499
486
  return self._credentials.token
500
487
 
501
488
  @storage_ops_observer.wrap({"type": "initialize"})
@@ -565,9 +552,7 @@ class GCSStorage(Storage):
565
552
  raise AttributeError()
566
553
 
567
554
  headers = await self.get_access_headers()
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"
555
+ url = f"{self.object_base_url}/{bucket_name}?project={self._project}"
571
556
  async with self.session.get(
572
557
  url,
573
558
  headers=headers,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nucliadb_utils
3
- Version: 5.0.1.post1105
3
+ Version: 5.0.1.post1114
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.post1105
28
- Requires-Dist: nucliadb-telemetry>=5.0.1.post1105
27
+ Requires-Dist: nucliadb-protos>=5.0.1.post1114
28
+ Requires-Dist: nucliadb-telemetry>=5.0.1.post1114
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=b7_ZqBTtacnfTeErfeozXTLXbTL27JwqF1-SUEe9VmM,8370
11
+ nucliadb_utils/nats.py,sha256=prs98dIrGh2-WchQcRBloc5wYhpjEnB0VtCERPnoReg,8430
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=TQlPpg9HzfHbOu_iCLPUo9KAql1IIjWxJ9mVJ9_CrV8,27658
50
+ nucliadb_utils/storages/gcs.py,sha256=k1WXZDBQXSizO_3kEJef7EmyInnASJsAy5VTtEw8ly4,27020
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.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,,
67
+ nucliadb_utils-5.0.1.post1114.dist-info/METADATA,sha256=w9SzKmmFle6yh9jsS6evLbMQ_9i74tGlyriqpdok3hs,2071
68
+ nucliadb_utils-5.0.1.post1114.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
69
+ nucliadb_utils-5.0.1.post1114.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
70
+ nucliadb_utils-5.0.1.post1114.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
71
+ nucliadb_utils-5.0.1.post1114.dist-info/RECORD,,