sunholo 0.56.3__py3-none-any.whl → 0.56.6__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/__init__.py CHANGED
@@ -1,34 +0,0 @@
1
- from . import agents
2
- from . import archive
3
- from . import auth
4
- from . import bots
5
- from . import chunker
6
- from . import components
7
- from . import database
8
- from . import embedder
9
- from . import gcs
10
- from . import langfuse
11
- from . import lookup
12
- from . import patches
13
- from . import qna
14
- from . import streaming
15
- from . import utils
16
- import logging
17
-
18
- __all__ = ['agents',
19
- 'archive',
20
- 'auth',
21
- 'bots',
22
- 'chunker',
23
- 'components',
24
- 'database',
25
- 'embedder',
26
- 'gcs',
27
- 'langfuse',
28
- 'lookup',
29
- 'patches',
30
- 'qna',
31
- 'streaming',
32
- 'utils',
33
- 'logging']
34
-
sunholo/cli/cli.py CHANGED
@@ -1,12 +1,82 @@
1
- # sunholo/cli/cli.py
2
1
  import argparse
2
+ try:
3
+ from google.cloud import build_v1
4
+ except ImportError:
5
+ build_v1 = None
3
6
 
4
- def main():
5
- parser = argparse.ArgumentParser(description="sunholo CLI tool.")
6
- parser.add_argument('--echo', help='Echo the string you use here')
7
- args = parser.parse_args()
8
- if args.echo:
9
- print(args.echo)
7
+ from ..logging import log
8
+
9
+ def trigger_build(args):
10
+ """
11
+ Triggers a Google Cloud Build using an existing build trigger configured in GCP.
12
+
13
+ Args:
14
+ args: argparse.Namespace containing the command line arguments specified for the 'deploy' command.
15
+
16
+ Example:
17
+ trigger_build(args) where args contains project_id, trigger_id, repo_name, and branch_name.
18
+ """
19
+ if not build_v1:
20
+ log.warning("Can't deploy - google-cloud-build not installed, enable via `pip install sunholo[gcp]")
21
+
22
+ return None
23
+
24
+ client = build_v1.services.cloud_build.CloudBuildClient()
25
+ # Assuming the build source uses the path to the cloudbuild.yaml if specified.
26
+ source = build_v1.RepoSource(
27
+ project_id=args.project_id,
28
+ repo_name=args.repo_name,
29
+ branch_name=args.branch_name,
30
+ substitutions=args.substitutions,
31
+ dir=args.config_path # Path to directory containing cloudbuild.yaml
32
+ )
33
+ request = build_v1.RunBuildTriggerRequest(
34
+ project_id=args.project_id,
35
+ trigger_id=args.trigger_id,
36
+ source=source
37
+ )
38
+ operation = client.run_build_trigger(request)
39
+ print(f"Triggered build with id: {operation.metadata.build.id}")
40
+
41
+ def setup_deploy_subparser(subparsers):
42
+ """
43
+ Sets up an argparse subparser for the 'deploy' command.
44
+
45
+ Example command:
46
+ ```bash
47
+ sunholo deploy --project_id "my-gcp-project" --trigger_id "my-trigger-id" --repo_name "my-repo"
48
+ ```
49
+ """
50
+ deploy_parser = subparsers.add_parser('deploy', help='Triggers a deployment using an existing Google Cloud Build trigger.')
51
+ deploy_parser.add_argument('--project_id', required=True, help='Google Cloud Project ID required for deployment.')
52
+ deploy_parser.add_argument('--trigger_id', required=True, help='Google Cloud Build Trigger ID required for deployment.')
53
+ deploy_parser.add_argument('--repo_name', required=True, help='Name of the linked repository in Google Cloud Source Repositories required for deployment.')
54
+ deploy_parser.add_argument('--branch_name', default='dev', help='Branch name to trigger the build from, defaults to "dev".')
55
+ deploy_parser.add_argument('--config_path', default='.', help='Path to the directory containing the cloudbuild.yaml file, defaults to current directory.')
56
+ deploy_parser.set_defaults(func=trigger_build)
57
+
58
+ def main(args=None):
59
+ """
60
+ Entry point for the sunholo console script. This function parses command line arguments
61
+ and invokes the appropriate functionality based on the user input.
62
+
63
+ Example commands:
64
+ ```bash
65
+ sunholo deploy --project_id "my-gcp-project" --trigger_id "my-trigger-id" --repo_name "my-repo" --branch_name "dev" --config_path "app/vac/my_vac/"
66
+ ```
67
+ """
68
+ parser = argparse.ArgumentParser(description="sunholo CLI tool for deploying applications using Google Cloud Build.")
69
+ subparsers = parser.add_subparsers(title='commands', description='Valid commands', help='`sunholo deploy --help`', dest='command', required=True)
70
+
71
+ # Setup deploy command
72
+ setup_deploy_subparser(subparsers)
73
+
74
+ args = parser.parse_args(args)
75
+
76
+ if hasattr(args, 'func'):
77
+ args.func(args)
78
+ else:
79
+ parser.print_help()
10
80
 
11
81
  if __name__ == "__main__":
12
82
  main()
sunholo/components/llm.py CHANGED
@@ -106,9 +106,9 @@ def get_llm(vector_name, model=None):
106
106
  model = load_config_key("model", vector_name, kind="vacConfig")
107
107
 
108
108
  log.debug(f"Chose LLM: {llm_str}")
109
- return llm_str_to_llm(llm_str, model=model, vector_name=vector_name, kind="vacConfig")
109
+ return llm_str_to_llm(llm_str, model=model, vector_name=vector_name)
110
110
 
111
- def get_llm_chat(vector_name, model=None, config_file="config/llm_config.yaml"):
111
+ def get_llm_chat(vector_name, model=None):
112
112
  llm_str = load_config_key("llm", vector_name, kind="vacConfig")
113
113
  if not model:
114
114
  model = load_config_key("model", vector_name, kind="vacConfig")
sunholo/logging.py CHANGED
@@ -214,9 +214,6 @@ def setup_logging(logger_name=None, log_level=logging.INFO, project_id=None):
214
214
  if is_logging_setup(logger):
215
215
  return logger
216
216
 
217
- if project_id is None:
218
- project_id = get_gcp_project()
219
-
220
217
  if logger_name is None:
221
218
  logger_name = "sunholo"
222
219
 
@@ -227,6 +224,8 @@ def setup_logging(logger_name=None, log_level=logging.INFO, project_id=None):
227
224
  print("Found GOOGLE_CLOUD_LOGGING=1 but no GCP Client available, install via `pip install sunholo[gcp]` and/or authenticate")
228
225
 
229
226
  if Client and os.environ.get('GOOGLE_CLOUD_LOGGING') == "1":
227
+ if project_id is None:
228
+ project_id = get_gcp_project()
230
229
  # Instantiate the GoogleCloudLogging class
231
230
  gc_logger = GoogleCloudLogging(project_id, log_level=log_level, logger_name=logger_name)
232
231
  else:
sunholo/utils/__init__.py CHANGED
@@ -1 +1 @@
1
- from .config import fetch_config, load_config_key, load_config
1
+ from .config import load_config_key, load_config
sunholo/utils/config.py CHANGED
@@ -18,54 +18,6 @@ import yaml
18
18
  from datetime import datetime, timedelta
19
19
  from collections import defaultdict
20
20
 
21
- try:
22
- from google.cloud import storage
23
- except ImportError:
24
- storage = None
25
-
26
- def fetch_config(bucket_name: str, blob_name: str):
27
- """
28
- Fetch the configuration file from a Google Cloud Storage bucket.
29
-
30
- Args:
31
- bucket_name (str): The name of the GCS bucket.
32
- blob_name (str): The name of the blob/file to fetch.
33
-
34
- Returns:
35
- datetime or None: The last modified time of the file, or None if the blob does not exist.
36
-
37
- Example:
38
- ```python
39
- last_updated = fetch_config('my-bucket', 'config.yaml')
40
- if last_updated:
41
- print(f'Configuration file was last updated on {last_updated}')
42
- else:
43
- print('Configuration file not found in the specified bucket.')
44
- ```
45
- """
46
- from ..logging import log
47
-
48
- if not storage:
49
- log.debug("No google.cloud.storage client installed. Skipping config load from bucket")
50
- return None
51
-
52
- storage_client = storage.Client()
53
-
54
- bucket = storage_client.bucket(bucket_name)
55
- blob = storage.Blob(blob_name, bucket)
56
-
57
- # Check if the file exists
58
- if not blob.exists():
59
- log.info(f"The blob {blob_name} does not exist in the bucket {bucket_name}")
60
- return None
61
-
62
- # Download the file to a local file
63
- blob.download_to_filename(blob_name)
64
-
65
- # Get the blob's updated time
66
- updated_time = blob.updated
67
-
68
- return updated_time
69
21
 
70
22
  def get_module_filepath(filepath: str):
71
23
  """
@@ -105,13 +57,14 @@ def load_all_configs():
105
57
  from ..logging import log
106
58
 
107
59
  config_folder = os.getenv("_CONFIG_FOLDER", os.getcwd())
108
- config_file = os.path.join(config_folder, "config")
109
-
60
+ config_folder = os.path.join(config_folder, "config")
61
+
110
62
  log.info(f"Loading all configs from folder: {config_folder}")
111
63
  current_time = datetime.now()
112
64
 
113
65
  configs_by_kind = defaultdict(dict)
114
66
  for filename in os.listdir(config_folder):
67
+ log.info(f"config file: {filename}")
115
68
  if filename.endswith(('.yaml', '.yml', '.json')):
116
69
  config_file = os.path.join(config_folder, filename)
117
70
 
@@ -237,6 +190,15 @@ def load_config_key(key: str, vector_name: str, filename: str=None, kind: str=No
237
190
 
238
191
  configs_by_kind = load_all_configs()
239
192
  log.info(f"configs by kind: {configs_by_kind}")
193
+
194
+ if kind:
195
+ log.info(f"Got kind: {kind} - applying to configs")
196
+
197
+ if filename:
198
+ log.warning(f"Got filename argument: {filename} for config - deprecated - use `kind='vacConfig'` instead")
199
+
200
+ if not configs_by_kind:
201
+ log.warning("Did not load configs via folder")
240
202
 
241
203
  if kind and configs_by_kind.get(kind):
242
204
  config = configs_by_kind[kind]
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.56.3
3
+ Version: 0.56.6
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.56.3.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.56.6.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -27,6 +27,7 @@ Requires-Dist: flask ; extra == 'all'
27
27
  Requires-Dist: google-cloud-aiplatform ; extra == 'all'
28
28
  Requires-Dist: google-api-python-client ; extra == 'all'
29
29
  Requires-Dist: google-cloud-alloydb-connector[pg8000] ; extra == 'all'
30
+ Requires-Dist: google-cloud-build ; extra == 'all'
30
31
  Requires-Dist: google-cloud-logging ; extra == 'all'
31
32
  Requires-Dist: google-cloud-storage ; extra == 'all'
32
33
  Requires-Dist: google-cloud-pubsub ; extra == 'all'
@@ -54,6 +55,7 @@ Requires-Dist: pg8000 ; extra == 'database'
54
55
  Requires-Dist: lancedb ; extra == 'database'
55
56
  Provides-Extra: gcp
56
57
  Requires-Dist: google-cloud-aiplatform ; extra == 'gcp'
58
+ Requires-Dist: google-cloud-build ; extra == 'gcp'
57
59
  Requires-Dist: google-cloud-storage ; extra == 'gcp'
58
60
  Requires-Dist: google-cloud-logging ; extra == 'gcp'
59
61
  Requires-Dist: google-cloud-pubsub ; extra == 'gcp'
@@ -1,5 +1,5 @@
1
- sunholo/__init__.py,sha256=hEN0kOEikUGBot_YIMra1nnPNmcwmO_kwvPOmLW8-_8,692
2
- sunholo/logging.py,sha256=wvaT33baueD2VV5oP84duhwKKpH4os_3LtqZVWaGPIw,11226
1
+ sunholo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ sunholo/logging.py,sha256=_poZ61TbLl6yHox2eO78BvIGQCUCrAIjWio70sGJIag,11233
3
3
  sunholo/agents/__init__.py,sha256=CnlbVohPt-Doth9PyROSlN3P8xMV9j9yS19YE-wCS90,341
4
4
  sunholo/agents/chat_history.py,sha256=PbwYmw1TwzI8H-cwQIGgHZ6UIr2Qb-JWow0RG3ayLM8,5195
5
5
  sunholo/agents/dispatch_to_qa.py,sha256=kWrO-CJel5kJAyyCShShpACUuZpqDOP7DN8vo_7ciao,8056
@@ -31,9 +31,9 @@ sunholo/chunker/pdfs.py,sha256=daCZ1xjn1YvxlifIyxskWNpLJLe-Q9D_Jq12MWx3tZo,2473
31
31
  sunholo/chunker/publish.py,sha256=PoT8q3XJeFCg10WrLkYhuaaXIrGVkvUD3-R9IfoWoH4,2703
32
32
  sunholo/chunker/splitter.py,sha256=CZ33xVWeYdjckd1VTrZnxuLypzzn-yKXQBFZaN7UcjI,6697
33
33
  sunholo/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
- sunholo/cli/cli.py,sha256=i6L729GLkxcYNGFtujYxrkoILUxMvNiHmv_-Zlo7nAY,304
34
+ sunholo/cli/cli.py,sha256=ljOso32M1u9_PAx_T2vGQtZcCTNRw8TLblinob8btAo,3352
35
35
  sunholo/components/__init__.py,sha256=RJGNEihwvRIiDScKis04RHJv4yZGI1UpXlOmuCptNZI,208
36
- sunholo/components/llm.py,sha256=clZktcwEOwZwHE0Bl8hDRt5aDhOOEgCi1STcW0PBxc8,10430
36
+ sunholo/components/llm.py,sha256=T4we3tGmqUj4tPwxQr9M6AXv_BALqZV_dRSvINan-oU,10374
37
37
  sunholo/components/prompt.py,sha256=eZSghXkIlRzXiSrzgkG7e5ytUYq6R6LV-qjHU8jStig,6353
38
38
  sunholo/components/retriever.py,sha256=TiM-axCeaZ6CZ8rGKGx-io16JKDe8z0pnMccBi1yqHw,3509
39
39
  sunholo/components/vectorstore.py,sha256=J5zzW7Acc7A4W6dGnYTYDxST3p6W4OtckXUUwAEeaqE,4941
@@ -79,13 +79,13 @@ sunholo/streaming/langserve.py,sha256=6isOvFwZBfmiQY5N41PYPyrdJj9IgJXXHLfTzPvewG
79
79
  sunholo/streaming/streaming.py,sha256=TLLBamDs5ihvA77I30xAXu_J8vMVUmhyeJFJkTN9ess,16723
80
80
  sunholo/summarise/__init__.py,sha256=MZk3dblUMODcPb1crq4v-Z508NrFIpkSWNf9FIO8BcU,38
81
81
  sunholo/summarise/summarise.py,sha256=C3HhjepTjUhUC8FLk4jMQIBvq1BcORniwuTFHjPVhVo,3784
82
- sunholo/utils/__init__.py,sha256=MxuxoJ-oOie_skGnB4mOagVYjzvfmX9Gz9N5heI8azM,62
83
- sunholo/utils/config.py,sha256=KD3mcLg7GadpT884mtORC7fP9XbDy-gHetUSuV-VonQ,9714
82
+ sunholo/utils/__init__.py,sha256=G11nN_6ATjxpuMfG_BvcUr9UU8onPIgkpTK6CjOcbr8,48
83
+ sunholo/utils/config.py,sha256=NW2FFyNNTwCyopOvSzDQ0I0l92LAfJJ7hEzatSuoZho,8689
84
84
  sunholo/utils/gcp.py,sha256=B2G1YKjeD7X9dqO86Jrp2vPuFwZ223Xl5Tg09Ndw-oc,5760
85
85
  sunholo/utils/parsers.py,sha256=OrHmASqIbI45atVOhiGodgLvnfrzkvVzyHnSvAXD89I,3841
86
- sunholo-0.56.3.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
87
- sunholo-0.56.3.dist-info/METADATA,sha256=YMpQxhWTwBnpy2saOxsZ9sArk4rliKvS6s5dQAyLs0Q,6515
88
- sunholo-0.56.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
89
- sunholo-0.56.3.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
90
- sunholo-0.56.3.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
91
- sunholo-0.56.3.dist-info/RECORD,,
86
+ sunholo-0.56.6.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
87
+ sunholo-0.56.6.dist-info/METADATA,sha256=Izjem6siNara4nKFRwQbfpeXK9AsuO74q-p_fbi6-mo,6617
88
+ sunholo-0.56.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
89
+ sunholo-0.56.6.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
90
+ sunholo-0.56.6.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
91
+ sunholo-0.56.6.dist-info/RECORD,,