sunholo 0.83.1__py3-none-any.whl → 0.83.3__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.
@@ -43,6 +43,7 @@ class AlloyDBClient:
43
43
  cluster_name:str=None,
44
44
  instance_name:str=None,
45
45
  user:str=None,
46
+ password:str=None,
46
47
  db="postgres"):
47
48
  """Initializes the AlloyDB client.
48
49
  - project_id (str): GCP project ID where the AlloyDB instance resides.
@@ -71,11 +72,40 @@ class AlloyDBClient:
71
72
 
72
73
  self.database = alloydb_config.get("database") or ALLOYDB_DB
73
74
 
74
- if user and not user.endswith(".iam"):
75
- raise ValueError("If you supply an IAM user it must end with .iam e.g. 'sa-cloudbuild@multivac-deploy.iam'")
76
-
77
75
  self.user = user
78
- self.engine = self._create_engine()
76
+ self.password = password
77
+ self.inst_url = ""
78
+ if user:
79
+ log.info("User specified {user} - using pg8000 engine")
80
+ self.inst_url = self._build_instance_uri(project_id, region, cluster_name, instance_name)
81
+ self.engine = self._create_engine_from_pg8000()
82
+ else:
83
+ log.info("Build with Langchain engine - will use default service account for auth")
84
+ self.engine = self._create_engine()
85
+
86
+ def _build_instance_uri(self, project_id, region, cluster_name, instance_name):
87
+ return f"projects/{project_id}/locations/{region}/clusters/{cluster_name}/instances/{instance_name}"
88
+
89
+ def _create_engine_from_pg8000(self, user, password, db):
90
+ def getconn() -> pg8000.dbapi.Connection:
91
+ conn = self.connector.connect(
92
+ self.inst_uri,
93
+ "pg8000",
94
+ user=user,
95
+ password=password,
96
+ db=db,
97
+ enable_iam_auth=True,
98
+ )
99
+ return conn
100
+
101
+ engine = sqlalchemy.create_engine(
102
+ "postgresql+pg8000://",
103
+ isolation_level="AUTOCOMMIT",
104
+ creator=getconn)
105
+ engine.dialect.description_encoding = None
106
+
107
+ log.info(f"Created AlloyDB engine for {self.inst_uri} and user: {user}")
108
+ return engine
79
109
 
80
110
  def _create_engine(self):
81
111
  if not AlloyDBEngine:
@@ -90,7 +120,7 @@ class AlloyDBClient:
90
120
  region=self.config["region"],
91
121
  cluster=self.config["cluster"],
92
122
  instance=self.config["instance"],
93
- user=self.user,
123
+ password=self.password,
94
124
  database=self.database,
95
125
  ip_type=self.config.get("ip_type") or IPTypes.PRIVATE
96
126
  )
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.83.1
3
+ Version: 0.83.3
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.83.1.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.83.3.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -59,7 +59,7 @@ sunholo/components/retriever.py,sha256=bKIVT7_18Ut3OJd0E0jyiISPnD9qkHWVjcQPT4i1_
59
59
  sunholo/components/vectorstore.py,sha256=xKk7micTRwZckaI7U6PxvFz_ZSjCH48xPTDYiDcv2tc,5913
60
60
  sunholo/database/__init__.py,sha256=bpB5Nk21kwqYj-qdVnvNgXjLsbflnH4g-San7OHMqR4,283
61
61
  sunholo/database/alloydb.py,sha256=YH8wNPS8gN-TDZEXQcVHxwd1NScHRfAxma3gK4R6KCk,11740
62
- sunholo/database/alloydb_client.py,sha256=3Jdye7vTfAVQhAmEd5FjxBQ0a_iENFmvzoOIP-pNz6I,11554
62
+ sunholo/database/alloydb_client.py,sha256=138gtbPzgcFT9j6hLQ1QD263ny_wJ0qPXCjKIK49Xts,12722
63
63
  sunholo/database/database.py,sha256=VqhZdkXUNdvWn8sUcUV3YNby1JDVf7IykPVXWBtxo9U,7361
64
64
  sunholo/database/lancedb.py,sha256=DyfZntiFKBlVPaFooNN1Z6Pl-LAs4nxWKKuq8GBqN58,715
65
65
  sunholo/database/static_dbs.py,sha256=8cvcMwUK6c32AS2e_WguKXWMkFf5iN3g9WHzsh0C07Q,442
@@ -134,9 +134,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
134
134
  sunholo/vertex/memory_tools.py,sha256=q_phxgGX2TG2j2MXNULF2xGzQnQPENwjPN9nZ_A9Gh0,7526
135
135
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
136
136
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
137
- sunholo-0.83.1.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
138
- sunholo-0.83.1.dist-info/METADATA,sha256=yihJkACY1C9pmb-C1dCKwI714WHSYVr_DkcCrPU_gCs,7413
139
- sunholo-0.83.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
140
- sunholo-0.83.1.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
141
- sunholo-0.83.1.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
142
- sunholo-0.83.1.dist-info/RECORD,,
137
+ sunholo-0.83.3.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
138
+ sunholo-0.83.3.dist-info/METADATA,sha256=SIKK5jlQKCKbpXixBWG5EJZiU_BUku1ytzEbiz0tnWE,7413
139
+ sunholo-0.83.3.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
140
+ sunholo-0.83.3.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
141
+ sunholo-0.83.3.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
142
+ sunholo-0.83.3.dist-info/RECORD,,