sunholo 0.58.5__py3-none-any.whl → 0.59.0__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/cli/configs.py CHANGED
@@ -1,29 +1,111 @@
1
1
  from ..utils.config import load_all_configs
2
-
2
+ from ..utils.config_schema import SCHEMAS, VAC_SUBCONFIG_SCHEMA
3
+ from jsonschema import validate, ValidationError
3
4
  from pprint import pprint
4
5
 
6
+ def validate_config(config, schema):
7
+ try:
8
+ validate(instance=config, schema=schema)
9
+ print("OK: Validated schema")
10
+ return True
11
+ except ValidationError as err:
12
+ error_path = " -> ".join(map(str, err.path))
13
+ #print(f"ERROR: Validation error at '{error_path}': {err.message}")
14
+ raise ValidationError(f"Validation error at '{error_path}': {err.message}")
15
+
5
16
  def list_configs(args):
6
17
  """
7
- Lists configuration files, filtered by kind if specified.
18
+ Lists configuration files, filtered by kind or VAC name if specified, and optionally validates them.
19
+
20
+ Args:
21
+ args: Command-line arguments including 'kind', 'vac', and 'validate' for filtering and validation.
22
+
23
+ Examples:
24
+ # List all configurations
25
+ list_configs(args)
26
+
27
+ # List configurations filtered by kind
28
+ args.kind = 'vacConfig'
29
+ list_configs(args)
30
+
31
+ # List configurations filtered by VAC name
32
+ args.vac = 'edmonbrain'
33
+ list_configs(args)
34
+
35
+ # List configurations filtered by both kind and VAC name
36
+ args.kind = 'vacConfig'
37
+ args.vac = 'edmonbrain'
38
+ list_configs(args)
39
+
40
+ # Validate configurations
41
+ args.validate = True
42
+ list_configs(args)
8
43
  """
9
44
  print("Listing configuration files")
10
45
  configs = load_all_configs()
46
+ filtered_configs = {}
11
47
 
12
- if args.kind:
48
+ if args.kind and args.vac:
13
49
  if args.kind in configs:
14
- print(f"## Config kind: {args.kind}")
15
- pprint(configs[args.kind])
50
+ kind_config = configs[args.kind]
51
+ vac_config = kind_config.get('vac', {}).get(args.vac)
52
+ if vac_config:
53
+ filtered_configs[args.kind] = {args.vac: vac_config}
54
+ else:
55
+ print(f"No configurations found for kind: {args.kind} with VAC: {args.vac}")
16
56
  else:
17
57
  print(f"No configurations found for kind: {args.kind}")
18
- else:
58
+ elif args.kind:
59
+ if args.kind in configs:
60
+ filtered_configs[args.kind] = configs[args.kind]
61
+ else:
62
+ print(f"No configurations found for kind: {args.kind}")
63
+ elif args.vac:
19
64
  for kind, config in configs.items():
20
- pprint(f"## Config kind: {kind}")
21
- pprint(config)
65
+ vac_config = config.get('vac', {}).get(args.vac)
66
+ if vac_config:
67
+ if kind not in filtered_configs:
68
+ filtered_configs[kind] = {}
69
+ filtered_configs[kind][args.vac] = vac_config
70
+ if not filtered_configs:
71
+ print(f"No configurations found with VAC: {args.vac}")
72
+ else:
73
+ filtered_configs = configs
74
+
75
+ for kind, config in filtered_configs.items():
76
+ print(f"## Config kind: {kind}")
77
+ pprint(config)
78
+
79
+ if args.validate:
80
+ for kind, config in filtered_configs.items():
81
+ print(f"Validating configuration for kind: {kind}")
82
+ if args.kind == "vacConfig" and args.vac:
83
+ print(f"Validating vacConfig for {args.vac}")
84
+ if not validate_config(config[args.vac], VAC_SUBCONFIG_SCHEMA):
85
+ print(f"Validation failed for sub-kind: {args.vac}")
86
+ elif kind in SCHEMAS:
87
+ if not validate_config(config, SCHEMAS[kind]):
88
+ print(f"FAIL: Validation failed for kind: {kind}")
89
+ else:
90
+ print(f"No schema available to validate configuration for kind: {kind}")
91
+
92
+
22
93
 
23
94
  def setup_list_configs_subparser(subparsers):
24
95
  """
25
96
  Sets up an argparse subparser for the 'list-configs' command.
97
+
98
+ Args:
99
+ subparsers: The subparsers object from argparse.ArgumentParser().
100
+
101
+ Examples:
102
+ # Set up the subparser for the 'list-configs' command
103
+ parser = argparse.ArgumentParser()
104
+ subparsers = parser.add_subparsers()
105
+ setup_list_configs_subparser(subparsers)
26
106
  """
27
- list_configs_parser = subparsers.add_parser('list-configs', help='Lists all configuration files and their details.')
28
- list_configs_parser.add_argument('--kind', help='Filter configurations by kind.')
107
+ list_configs_parser = subparsers.add_parser('list-configs', help='Lists all configuration files and their details e.g. `sunholo list-configs --kind=vacConfig --vac=edmonbrain`')
108
+ list_configs_parser.add_argument('--kind', help='Filter configurations by kind e.g. `--kind=vacConfig`')
109
+ list_configs_parser.add_argument('--vac', help='Filter configurations by VAC name e.g. `--vac=edmonbrain`')
110
+ list_configs_parser.add_argument('--validate', action='store_true', help='Validate the configuration files.')
29
111
  list_configs_parser.set_defaults(func=list_configs)
@@ -0,0 +1,121 @@
1
+ VAC_SUBCONFIG_SCHEMA = {
2
+ "type": "object",
3
+ "properties": {
4
+ "llm": {"type": "string"},
5
+ "agent": {"type": "string"},
6
+ "model": {"type": "string"},
7
+ "prompt": {"type": "string"},
8
+ "chunker": {
9
+ "type": "object",
10
+ "properties": {
11
+ "type": {"type": "string"},
12
+ "llm": {"type": "string"},
13
+ "chunk_size": {"type": "integer"},
14
+ "overlap": {"type": "integer"}
15
+ },
16
+ "additionalProperties": False
17
+ },
18
+ "memory": {
19
+ "type": "array",
20
+ "items": {
21
+ "type": "object",
22
+ "patternProperties": {
23
+ ".*-vectorstore": {
24
+ "type": "object",
25
+ "properties": {
26
+ "vectorstore": {"type": "string"},
27
+ "self_query": {"type": "boolean"},
28
+ "provider": {"type": "string"},
29
+ "k": {"type": "integer"},
30
+ "vector_name": {"type": "string"},
31
+ "read_only": {"type": "boolean"},
32
+ "llm": {"type": "string"}
33
+ },
34
+ "required": ["vectorstore"]
35
+ }
36
+ }
37
+ }
38
+ },
39
+ "gcp_config": {
40
+ "type": "object",
41
+ "properties": {
42
+ "project_id": {"type": "string"},
43
+ "endpoint_id": {"type": "integer"},
44
+ "location": {"type": "string"}
45
+ }
46
+ },
47
+ "alloydb_config": {
48
+ "type": "object",
49
+ "properties": {
50
+ "project_id": {"type": "string"},
51
+ "region": {"type": "string"},
52
+ "cluster": {"type": "string"},
53
+ "instance": {"type": "string"},
54
+ "database": {"type": "string"}
55
+ }
56
+ },
57
+ "secrets": {
58
+ "type": "array",
59
+ "items": {"type": "string"}
60
+ },
61
+ "display_name": {"type": "string"},
62
+ "avatar_url": {"type": "string"},
63
+ "description": {"type": "string"},
64
+ "memory_k": {"type": "integer"}
65
+ },
66
+ "required": ["llm", "agent"]
67
+ }
68
+
69
+
70
+ VAC_CONFIG_SCHEMA = {
71
+ "type": "object",
72
+ "properties": {
73
+ "kind": {"type": "string"},
74
+ "apiVersion": {"type": "string"},
75
+ "gcp_config": {
76
+ "type": "object",
77
+ "properties": {
78
+ "project_id": {"type": "string"},
79
+ "location": {"type": "string"}
80
+ },
81
+ "required": ["project_id", "location"]
82
+ },
83
+ "vac": {
84
+ "type": "object",
85
+ "patternProperties": {
86
+ ".*": VAC_SUBCONFIG_SCHEMA
87
+ }
88
+ }
89
+ },
90
+ "required": ["kind", "apiVersion", "gcp_config", "vac"]
91
+ }
92
+
93
+ PROMPT_CONFIG_SCHEMA = {
94
+ "type": "object",
95
+ "properties": {
96
+ "kind": {"type": "string"},
97
+ "apiVersion": {"type": "string"},
98
+ "prompts": {
99
+ "type": "object",
100
+ "patternProperties": {
101
+ ".*": {
102
+ "type": "object",
103
+ "properties": {
104
+ "chunk_summary": {"type": "string"},
105
+ "intro": {"type": "string"},
106
+ "template": {"type": "string"},
107
+ "chat_summary": {"type": "string"},
108
+ "summarise_known_question": {"type": "string"}
109
+ }
110
+ }
111
+ }
112
+ }
113
+ },
114
+ "required": ["kind", "apiVersion", "prompts"]
115
+ }
116
+
117
+ SCHEMAS = {
118
+ "vacConfig": VAC_CONFIG_SCHEMA,
119
+ "promptConfig": PROMPT_CONFIG_SCHEMA
120
+ }
121
+
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.58.5
3
+ Version: 0.59.0
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.58.5.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.59.0.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE.txt
21
+ Requires-Dist: jsonschema
21
22
  Requires-Dist: langchain
22
23
  Requires-Dist: langchain-experimental
23
24
  Requires-Dist: langchain-community
@@ -33,7 +33,7 @@ sunholo/chunker/splitter.py,sha256=ug_v-h0wos3b7OkhmedVQs5jtLuDdFDWypvsZVYgxbU,6
33
33
  sunholo/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  sunholo/cli/cli.py,sha256=rcO1hMthy5nWC_5sOHqRm7ut70c9JfxFTSjFRBNYuYg,1248
35
35
  sunholo/cli/cli_init.py,sha256=WReZuMQwDfkRUvssYT7TirUoG6SiT1dTDol8nLI8O70,3418
36
- sunholo/cli/configs.py,sha256=wLRSL-Z58B7dQ_gxTK_d8HjNP5pABhegLqjB0-IKGjg,992
36
+ sunholo/cli/configs.py,sha256=0Yl7lmnPAMfl-QOOEg2qopbbRUXcDntDsILs-RkJrhk,4411
37
37
  sunholo/cli/deploy.py,sha256=zxdwUsRTRMC8U5vyRv0JiKBLFn84Ug_Tc88-_h9hJSs,1609
38
38
  sunholo/components/__init__.py,sha256=RJGNEihwvRIiDScKis04RHJv4yZGI1UpXlOmuCptNZI,208
39
39
  sunholo/components/llm.py,sha256=T4we3tGmqUj4tPwxQr9M6AXv_BALqZV_dRSvINan-oU,10374
@@ -85,13 +85,14 @@ sunholo/summarise/summarise.py,sha256=C3HhjepTjUhUC8FLk4jMQIBvq1BcORniwuTFHjPVhV
85
85
  sunholo/utils/__init__.py,sha256=G11nN_6ATjxpuMfG_BvcUr9UU8onPIgkpTK6CjOcbr8,48
86
86
  sunholo/utils/big_context.py,sha256=qHYtds4Ecf9eZRHVqXho4_q8Je7HD44-vS6RJ6s9Z0Q,5387
87
87
  sunholo/utils/config.py,sha256=Ve1sb68Av9_SPGqXs33g5FAJSIQ3GODoeuUCW3MNCwU,8802
88
+ sunholo/utils/config_schema.py,sha256=bx3SHHuZ3SCOOXNRU91Mk-b4pHXt7D-EElv7Q85gAdw,3758
88
89
  sunholo/utils/gcp.py,sha256=B2G1YKjeD7X9dqO86Jrp2vPuFwZ223Xl5Tg09Ndw-oc,5760
89
90
  sunholo/utils/parsers.py,sha256=OrHmASqIbI45atVOhiGodgLvnfrzkvVzyHnSvAXD89I,3841
90
91
  sunholo/vertex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
91
92
  sunholo/vertex/init_vertex.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
92
- sunholo-0.58.5.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
93
- sunholo-0.58.5.dist-info/METADATA,sha256=W0NKzdTVytQX9Uohr7xXtvcaq7nx9RwyVar7-Gu_zFc,7877
94
- sunholo-0.58.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
95
- sunholo-0.58.5.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
96
- sunholo-0.58.5.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
97
- sunholo-0.58.5.dist-info/RECORD,,
93
+ sunholo-0.59.0.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
94
+ sunholo-0.59.0.dist-info/METADATA,sha256=Mdw-w8TIyRiYxNXRNPtiHxC-VF16EddkPBc22tfnGDs,7903
95
+ sunholo-0.59.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
96
+ sunholo-0.59.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
97
+ sunholo-0.59.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
98
+ sunholo-0.59.0.dist-info/RECORD,,