sunholo 0.71.27__py3-none-any.whl → 0.71.28__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/gcs/__init__.py CHANGED
@@ -1 +1 @@
1
- from .download_url import construct_download_link
1
+ from .download_url import construct_download_link, get_bytes_from_gcs
@@ -20,6 +20,46 @@ project_id = None
20
20
  gcs_client = None
21
21
  gcs_bucket_cache = {}
22
22
 
23
+
24
+ def get_bytes_from_gcs(gs_uri):
25
+ """
26
+ Downloads a file from Google Cloud Storage and returns its bytes.
27
+
28
+ Args:
29
+ gs_uri (str): The Google Cloud Storage URI of the file to download (e.g., 'gs://bucket_name/file_name').
30
+
31
+ Returns:
32
+ bytes: The content of the file in bytes, or None if an error occurs.
33
+ """
34
+ if not gs_uri.startswith('gs://'):
35
+ log.error(f"Invalid GCS URI: {gs_uri}")
36
+ return None
37
+
38
+ try:
39
+ storage_client = storage.Client()
40
+ except Exception as err:
41
+ log.error(f"Error creating storage client: {str(err)}")
42
+ return None
43
+
44
+ try:
45
+ # Parse the GCS URI
46
+ path_parts = gs_uri[5:].split('/', 1)
47
+ bucket_name = path_parts[0]
48
+ blob_name = path_parts[1]
49
+
50
+ # Get the bucket and blob
51
+ bucket = storage_client.bucket(bucket_name)
52
+ blob = bucket.blob(blob_name)
53
+
54
+ # Download the blob as bytes
55
+ file_bytes = blob.download_as_bytes()
56
+ return file_bytes
57
+
58
+ except Exception as err:
59
+ log.error(f"Error downloading file from GCS: {str(err)}")
60
+ return None
61
+
62
+
23
63
  if is_running_on_gcp():
24
64
  # Perform a refresh request to get the access token of the current credentials (Else, it's None)
25
65
  gcs_credentials, project_id = google.auth.default()
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.71.27
3
+ Version: 0.71.28
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.71.27.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.71.28.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -66,9 +66,9 @@ sunholo/discovery_engine/create_new.py,sha256=7oZG78T6lW0EspRzlo7-qRyXFSuFxDn2df
66
66
  sunholo/discovery_engine/discovery_engine_client.py,sha256=YYsFeaW41l8jmWCruQnYxJGKEYBZ7dduTBDhdxI63hQ,17719
67
67
  sunholo/embedder/__init__.py,sha256=sI4N_CqgEVcrMDxXgxKp1FsfsB4FpjoXgPGkl4N_u4I,44
68
68
  sunholo/embedder/embed_chunk.py,sha256=d_dIzeNF630Q0Ar-u1hxos60s0tLIImJccAvuo_LTIw,6814
69
- sunholo/gcs/__init__.py,sha256=DtVw_AZwQn-IguR5BJuIi2XJeF_FQXizhJikzRNrXiE,50
69
+ sunholo/gcs/__init__.py,sha256=NBribFzdXMphwIEABP3YaQrbb54R3Kiz-To6MdVy0Kc,70
70
70
  sunholo/gcs/add_file.py,sha256=Nj75z1MH9fp3fvwd1BVLcHNFm0CVCR2uS4uByThos-o,6924
71
- sunholo/gcs/download_url.py,sha256=8XSEf8byfubqs5CMQeF_tn9wxqwUTq3n9mo5mLNIUTA,4801
71
+ sunholo/gcs/download_url.py,sha256=N-fUmZA6HMCiOkAusY-o04ihs_0fpt1quyifv2c_dYs,5922
72
72
  sunholo/gcs/metadata.py,sha256=C9sMPsHsq1ETetdQCqB3EBs3Kws8b8QHS9L7ei_v5aw,891
73
73
  sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
74
  sunholo/langfuse/callback.py,sha256=CTaos8sYcrga949BG6lIZ4I62DiiQSHxwz5re9XjDWQ,1677
@@ -115,9 +115,9 @@ sunholo/vertex/extensions_class.py,sha256=E0ix4YqFQG9EglKeTmp2-zwuZUA2crileGahAh
115
115
  sunholo/vertex/init.py,sha256=-w7b9GKsyJnAJpYHYz6_zBUtmeJeLXlEkgOfwoe4DEI,2715
116
116
  sunholo/vertex/memory_tools.py,sha256=WpedE5yDZcQiFOFBSOtwr-tRCnCXW9G6aZ01rFDfsMo,6862
117
117
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
118
- sunholo-0.71.27.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
119
- sunholo-0.71.27.dist-info/METADATA,sha256=xIbZuxm2LoY9GSE8yn5L1DLNOjX2D2F577PP4JiC3vE,6767
120
- sunholo-0.71.27.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
121
- sunholo-0.71.27.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
122
- sunholo-0.71.27.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
123
- sunholo-0.71.27.dist-info/RECORD,,
118
+ sunholo-0.71.28.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
119
+ sunholo-0.71.28.dist-info/METADATA,sha256=3W-vWbwG0SH58A2Ozl6T0rUjcli3roM4ExlYp-3519w,6767
120
+ sunholo-0.71.28.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
121
+ sunholo-0.71.28.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
122
+ sunholo-0.71.28.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
123
+ sunholo-0.71.28.dist-info/RECORD,,