sunholo 0.81.1__py3-none-any.whl → 0.81.2__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.
sunholo/auth/refresh.py CHANGED
@@ -7,12 +7,14 @@ from ..utils.gcp import is_running_on_gcp
7
7
  from ..custom_logging import log
8
8
 
9
9
  def get_default_email():
10
- if not refresh_credentials():
11
- log.error("Could not refresh the credentials properly.")
12
- return None
10
+
13
11
  # https://stackoverflow.com/questions/64234214/how-to-generate-a-blob-signed-url-in-google-cloud-run
14
12
 
15
- gcs_credentials, project_id = get_default_creds()
13
+ gcs_credentials, project_id = refresh_credentials()
14
+
15
+ if gcs_credentials is None:
16
+ log.error("Could not refresh the credentials properly.")
17
+ return None
16
18
 
17
19
  service_account_email = getattr(gcs_credentials, 'service_account_email', None)
18
20
  # If you use a service account credential, you can use the embedded email
@@ -34,20 +36,24 @@ def get_default_creds():
34
36
  return gcs_credentials, project_id
35
37
 
36
38
  def refresh_credentials():
39
+ """
40
+ Need to refresh to get a valid email/token for signing URLs from a default service account
41
+ """
37
42
  if not is_running_on_gcp():
38
43
  log.debug("Not running on Google Cloud so no credentials available for GCS.")
39
- return False
44
+ return None, None
40
45
 
41
46
  gcs_credentials, project_id = get_default_creds()
42
47
 
43
48
  if not gcs_credentials.token or gcs_credentials.expired or not gcs_credentials.valid:
44
49
  try:
45
- gcs_credentials.refresh(requests.Request())
50
+ r = requests.Request()
51
+ gcs_credentials.refresh(r)
46
52
 
47
- return True
53
+ return gcs_credentials, project_id
48
54
 
49
55
  except Exception as e:
50
56
  log.error(f"Failed to refresh gcs credentials: {e}")
51
57
 
52
- return False
58
+ return None, None
53
59
 
@@ -123,8 +123,8 @@ def sign_gcs_url(bucket_name:str, object_name:str, expiry_secs:int = 86400) -> O
123
123
  return url
124
124
  except RefreshError:
125
125
  log.info("Refreshing gcs_credentials due to token expiration.")
126
- refreshed = refresh_credentials()
127
- if refreshed:
126
+ credentials, token = refresh_credentials()
127
+ if credentials:
128
128
  return sign_gcs_url(bucket_name, object_name, expiry_secs)
129
129
  log.error("Failed to refresh gcs credentials")
130
130
  return None
@@ -161,9 +161,9 @@ def construct_download_link_simple(bucket_name:str, object_name:str) -> Tuple[st
161
161
  """
162
162
 
163
163
  if object_name.startswith("gs://"):
164
- object_name = object_name.replace("gs://", "https://storage.cloud.google.com")
165
-
166
- public_url = f"https://storage.cloud.google.com/{bucket_name}/{quote(object_name)}"
164
+ public_url = object_name.replace("gs://", "https://storage.cloud.google.com")
165
+ else:
166
+ public_url = f"https://storage.cloud.google.com/{bucket_name}/{quote(object_name)}"
167
167
  filename = os.path.basename(object_name)
168
168
  return public_url, filename, False
169
169
 
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.81.1
3
+ Version: 0.81.2
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.81.1.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.81.2.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -19,7 +19,7 @@ sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,3
19
19
  sunholo/archive/archive.py,sha256=PxVfDtO2_2ZEEbnhXSCbXLdeoHoQVImo4y3Jr2XkCFY,1204
20
20
  sunholo/auth/__init__.py,sha256=TeP-OY0XGxYV_8AQcVGoh35bvyWhNUcMRfhuD5l44Sk,91
21
21
  sunholo/auth/gcloud.py,sha256=PdbwkuTdRi4RKBmgG9uwsReegqC4VG15_tw5uzmA7Fs,298
22
- sunholo/auth/refresh.py,sha256=V4w_-Hydgh-jNpwYmM8qOFLSueucAXS5B3fs8BHEMlE,1853
22
+ sunholo/auth/refresh.py,sha256=6AEWX87G3I9BCqrgGJjHGrrWABBXHuaGDKU9ZEcVeXM,2017
23
23
  sunholo/auth/run.py,sha256=zZWRIxfG93eZMCE-feiHRQTLMcHz4U6-yseGgZfu1LI,2776
24
24
  sunholo/azure/__init__.py,sha256=S1WQ5jndzNgzhSBh9UpX_yw7hRVm3hCzkAWNxUdK4dA,48
25
25
  sunholo/azure/auth.py,sha256=Y3fDqFLYwbsIyi5hS5L-3hYnwrLWVL96yPng5Sj5c2c,2236
@@ -80,7 +80,7 @@ sunholo/embedder/embed_chunk.py,sha256=MCbTePWjUbIRVDFFhHJ94BvOZvIom62-mTr0PmfQy
80
80
  sunholo/gcs/__init__.py,sha256=SZvbsMFDko40sIRHTHppA37IijvJTae54vrhooEF5-4,90
81
81
  sunholo/gcs/add_file.py,sha256=wkBQBfnjUbItnRNGiG9oBr7Jf2QfLpZf2nA5zT435ss,7107
82
82
  sunholo/gcs/download_folder.py,sha256=ijJTnS595JqZhBH8iHFErQilMbkuKgL-bnTCMLGuvlA,1614
83
- sunholo/gcs/download_url.py,sha256=kmeMI2yBGbO6y3QTX2Mdc0dtF_DzJ7MDNypJ1Siq2Z8,5915
83
+ sunholo/gcs/download_url.py,sha256=Al7IbNXiaZ-zV09GHhUE9hx013lghJtE9nW8SJx_sas,5938
84
84
  sunholo/gcs/metadata.py,sha256=oQLcXi4brsZ74aegWyC1JZmhlaEV270HS5_UWtAYYWE,898
85
85
  sunholo/invoke/__init__.py,sha256=bELcqIjzKvaupcIN5OQmDgGx_8jARtH9T6PCe8UgcvE,99
86
86
  sunholo/invoke/direct_vac_func.py,sha256=wvrYDZNLoLeO_uQiqRdGUlhwjhLr05dVNBST9TxwwBA,4478
@@ -134,9 +134,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
134
134
  sunholo/vertex/memory_tools.py,sha256=pgSahVDh7GPEulu3nl-w0jb5lTClb4TCnVxPnMokNZY,7533
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.81.1.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
138
- sunholo-0.81.1.dist-info/METADATA,sha256=FzL5AaYW5MbloglNxQuAVT9DDwtpmA-Ai6R8FPmnE7w,7348
139
- sunholo-0.81.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
140
- sunholo-0.81.1.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
141
- sunholo-0.81.1.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
142
- sunholo-0.81.1.dist-info/RECORD,,
137
+ sunholo-0.81.2.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
138
+ sunholo-0.81.2.dist-info/METADATA,sha256=qIVU2f03S9E678dvZfzckg3hw8bkVTGQ-8ytTlesoek,7348
139
+ sunholo-0.81.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
140
+ sunholo-0.81.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
141
+ sunholo-0.81.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
142
+ sunholo-0.81.2.dist-info/RECORD,,