mirror of
https://github.com/katanemo/plano.git
synced 2026-05-11 00:32:42 +02:00
improve config validation error messages and update getting started demo
This commit is contained in:
parent
785bf7e021
commit
82a63cc050
2 changed files with 19 additions and 8 deletions
|
|
@ -3,7 +3,7 @@ import os
|
||||||
from planoai.utils import convert_legacy_listeners
|
from planoai.utils import convert_legacy_listeners
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
import yaml
|
import yaml
|
||||||
from jsonschema import validate
|
from jsonschema import validate, ValidationError
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from planoai.consts import DEFAULT_OTEL_TRACING_GRPC_ENDPOINT
|
from planoai.consts import DEFAULT_OTEL_TRACING_GRPC_ENDPOINT
|
||||||
|
|
@ -503,11 +503,13 @@ def validate_prompt_config(plano_config_file, plano_config_schema_file):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
validate(config_yaml, config_schema_yaml)
|
validate(config_yaml, config_schema_yaml)
|
||||||
|
except ValidationError as e:
|
||||||
|
path = " → ".join(str(p) for p in e.absolute_path) if e.absolute_path else "root"
|
||||||
|
raise ValidationError(
|
||||||
|
f"{e.message}\n Location: {path}\n Value: {e.instance}"
|
||||||
|
) from None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(
|
raise
|
||||||
f"Error validating plano_config file: {plano_config_file}, schema file: {plano_config_schema_file}, error: {e}"
|
|
||||||
)
|
|
||||||
raise e
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -420,9 +420,18 @@ def native_validate_config(plano_config_file):
|
||||||
with _temporary_env(overrides):
|
with _temporary_env(overrides):
|
||||||
from planoai.config_generator import validate_and_render_schema
|
from planoai.config_generator import validate_and_render_schema
|
||||||
|
|
||||||
# Suppress verbose print output from config_generator
|
# Suppress verbose print output from config_generator but capture errors
|
||||||
with contextlib.redirect_stdout(io.StringIO()):
|
captured = io.StringIO()
|
||||||
|
try:
|
||||||
|
with contextlib.redirect_stdout(captured):
|
||||||
validate_and_render_schema()
|
validate_and_render_schema()
|
||||||
|
except SystemExit:
|
||||||
|
# validate_and_render_schema calls exit(1) on failure after
|
||||||
|
# printing to stdout; re-raise so the caller gets a useful message.
|
||||||
|
output = captured.getvalue().strip()
|
||||||
|
raise Exception(output) if output else Exception(
|
||||||
|
"Config validation failed"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def native_logs(debug=False, follow=False):
|
def native_logs(debug=False, follow=False):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue