sunholo 0.69.5__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.
@@ -2,18 +2,20 @@ from .discovery_engine_client import DiscoveryEngineClient
2
2
  from ..utils.config import load_config_key
3
3
 
4
4
  def create_new_discovery_engine(vector_name):
5
+ global_config = load_config_key("gcp_config", "global", kind="vacConfig")
5
6
  gcp_config = load_config_key("gcp_config", vector_name=vector_name, kind="vacConfig")
6
7
 
7
8
  chunker_config = load_config_key("chunker", vector_name=vector_name, kind="vacConfig")
8
9
 
10
+ chunk_size = 500
9
11
  if chunker_config:
10
- chunk_size = chunker_config.get("chunk_size")
11
-
12
- if not chunk_size:
13
- chunk_size = 500
14
-
12
+ if "chunk_size" in chunker_config:
13
+ chunk_size = chunker_config["chunk_size"]
15
14
 
16
- project_id = gcp_config.get('project_id')
15
+ project_id = gcp_config.get('project_id') or global_config.get('project_id')
16
+ if not project_id:
17
+ raise ValueError("Could not find project_id in gcp_config")
18
+
17
19
  #location = gcp_config.get('location')
18
20
 
19
21
  de = DiscoveryEngineClient(
@@ -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.5
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.5.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
@@ -62,8 +62,8 @@ sunholo/database/sql/sb/return_sources.sql,sha256=89KAnxfK8n_qGK9jy1OQT8f9n4uYUt
62
62
  sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3-zZI,89
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
- sunholo/discovery_engine/create_new.py,sha256=6sowAvblLDBZq6skYwdc6n99YlyHvNLaIs6kYMnkdO8,921
66
- sunholo/discovery_engine/discovery_engine_client.py,sha256=PDoRO-6uc9u3lYUy6oUc-jbgxijfJMNaitScoz5nUCk,11775
65
+ sunholo/discovery_engine/create_new.py,sha256=31NK8ZzgKURFT2e1kBJCiyfFxfP6I_WCSbcjFpbp_fM,1144
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.5.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
115
- sunholo-0.69.5.dist-info/METADATA,sha256=z_-h8LDKsg8u64WDv7MY41Id1MYczH7HJabwdfOeW5Y,6155
116
- sunholo-0.69.5.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
117
- sunholo-0.69.5.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
118
- sunholo-0.69.5.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
119
- sunholo-0.69.5.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,,