sunholo 0.69.6__py3-none-any.whl → 0.69.8__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.
@@ -1,6 +1,8 @@
1
1
  try:
2
2
  from google.api_core.client_options import ClientOptions
3
3
  from google.cloud import discoveryengine_v1alpha as discoveryengine
4
+ from google.api_core.retry import Retry, if_exception_type
5
+ from google.api_core.exceptions import ResourceExhausted
4
6
  except ImportError:
5
7
  ClientOptions = None
6
8
  discoveryengine = None
@@ -65,6 +67,16 @@ class DiscoveryEngineClient:
65
67
  self.doc_client = discoveryengine.DocumentServiceClient(client_options=client_options)
66
68
  self.search_client = discoveryengine.SearchServiceClient(client_options=client_options)
67
69
 
70
+ @classmethod
71
+ def my_retry(cls):
72
+ return Retry(
73
+ initial=1.0, # Initial delay before retrying (in seconds)
74
+ maximum=60.0, # Maximum delay between retries (in seconds)
75
+ multiplier=2.0, # Multiplier for the delay between retries
76
+ timeout=300.0, # Maximum total time to wait before giving up (in seconds)
77
+ predicate=if_exception_type(ResourceExhausted) # Retry if a ResourceExhausted error occurs
78
+ )
79
+
68
80
  def create_data_store(
69
81
  self, chunk_size: int = 500,
70
82
  collection: str = "default_collection"
@@ -237,17 +249,16 @@ class DiscoveryEngineClient:
237
249
  )
238
250
 
239
251
  # Make the request
240
- operation = self.doc_client.import_documents(request=request)
241
-
242
- log.info(f"Waiting for operation to complete: {operation.operation.name}")
243
- response = operation.result()
244
-
245
- # Once the operation is complete,
246
- # get information from operation metadata
247
- metadata = discoveryengine.ImportDocumentsMetadata(operation.metadata)
248
-
249
- # Handle the response
250
- log.info(f"{response=} {metadata=}")
252
+ @self.my_retry()
253
+ def import_documents_with_retry(doc_client, request):
254
+ return doc_client.import_documents(request=request)
255
+
256
+ try:
257
+ operation = import_documents_with_retry(self.doc_client, request)
258
+ except ResourceExhausted as e:
259
+ print(f"Operation failed after retries due to quota exceeded: {e}")
260
+ except Exception as e:
261
+ print(f"An unexpected error occurred: {e}")
251
262
 
252
263
  return operation.operation.name
253
264
 
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.69.6
3
+ Version: 0.69.8
4
4
  Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
5
5
  Home-page: https://github.com/sunholo-data/sunholo-py
6
- Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.69.6.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.69.8.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -63,7 +63,7 @@ sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3
63
63
  sunholo/discovery_engine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  sunholo/discovery_engine/chunker_handler.py,sha256=eqRI8R-AVIhtqpzw62glCucvX_r1MXzdrF_DAKcPhtM,4793
65
65
  sunholo/discovery_engine/create_new.py,sha256=31NK8ZzgKURFT2e1kBJCiyfFxfP6I_WCSbcjFpbp_fM,1144
66
- sunholo/discovery_engine/discovery_engine_client.py,sha256=PDoRO-6uc9u3lYUy6oUc-jbgxijfJMNaitScoz5nUCk,11775
66
+ sunholo/discovery_engine/discovery_engine_client.py,sha256=UYMhXtGWXuyyg4fA1piVjqfrWXkSP_MFimh6NzaUlZ8,12413
67
67
  sunholo/embedder/__init__.py,sha256=sI4N_CqgEVcrMDxXgxKp1FsfsB4FpjoXgPGkl4N_u4I,44
68
68
  sunholo/embedder/embed_chunk.py,sha256=P744zUQJgqrjILunzaqtTerB9AwoXFU6tXBtz4rjWgQ,6673
69
69
  sunholo/gcs/__init__.py,sha256=DtVw_AZwQn-IguR5BJuIi2XJeF_FQXizhJikzRNrXiE,50
@@ -111,9 +111,9 @@ sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,13
111
111
  sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
112
112
  sunholo/vertex/memory_tools.py,sha256=8F1iTWnqEK9mX4W5RzCVKIjydIcNp6OFxjn_dtQ3GXo,5379
113
113
  sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
114
- sunholo-0.69.6.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
115
- sunholo-0.69.6.dist-info/METADATA,sha256=Gl6zh8Ke9yDX47I-UG6bj-Q1ijFm317f-HVbjdq7kWg,6155
116
- sunholo-0.69.6.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
117
- sunholo-0.69.6.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
118
- sunholo-0.69.6.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
119
- sunholo-0.69.6.dist-info/RECORD,,
114
+ sunholo-0.69.8.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
115
+ sunholo-0.69.8.dist-info/METADATA,sha256=SEe57-886plXFH-T-Kkn2acgw4WlJKYqh3Ab6hJzKMQ,6155
116
+ sunholo-0.69.8.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
117
+ sunholo-0.69.8.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
118
+ sunholo-0.69.8.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
119
+ sunholo-0.69.8.dist-info/RECORD,,