mirror of
https://github.com/katanemo/plano.git
synced 2026-06-17 15:25:17 +02:00
fix cli
This commit is contained in:
parent
b1d150123e
commit
ba74f6e313
4 changed files with 47 additions and 25 deletions
|
|
@ -56,7 +56,6 @@ def validate_and_render_schema():
|
|||
"port": 80, # default port
|
||||
}
|
||||
|
||||
print(inferred_clusters)
|
||||
endpoints = config_yaml.get("endpoints", {})
|
||||
|
||||
# override the inferred clusters with the ones defined in the config
|
||||
|
|
@ -88,7 +87,6 @@ def validate_and_render_schema():
|
|||
}
|
||||
|
||||
rendered = template.render(data)
|
||||
print(rendered)
|
||||
print(ENVOY_CONFIG_FILE_RENDERED)
|
||||
with open(ENVOY_CONFIG_FILE_RENDERED, "w") as file:
|
||||
file.write(rendered)
|
||||
|
|
@ -108,7 +106,7 @@ def validate_prompt_config(arch_config_file, arch_config_schema_file):
|
|||
validate(config_yaml, config_schema_yaml)
|
||||
except Exception as e:
|
||||
print(
|
||||
f"Error validating arch_config file: {arch_config_file}, error: {e.message}"
|
||||
f"Error validating arch_config file: {arch_config_file}, schema file: {arch_config_schema_file}, error: {e.message}"
|
||||
)
|
||||
raise e
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,12 @@ import multiprocessing
|
|||
import importlib.metadata
|
||||
from cli import targets
|
||||
from cli import config_generator
|
||||
from cli.utils import getLogger, get_llm_provider_access_keys, load_env_file_to_dict
|
||||
from cli.utils import (
|
||||
getLogger,
|
||||
get_llm_provider_access_keys,
|
||||
load_env_file_to_dict,
|
||||
validate_schema,
|
||||
)
|
||||
from cli.core import (
|
||||
start_arch_modelserver,
|
||||
stop_arch_modelserver,
|
||||
|
|
@ -160,17 +165,12 @@ def up(file, path, service):
|
|||
return
|
||||
|
||||
log.info(f"Validating {arch_config_file}")
|
||||
arch_schema_config = pkg_resources.resource_filename(
|
||||
__name__, "../config/arch_config_schema.yaml"
|
||||
)
|
||||
|
||||
try:
|
||||
config_generator.validate_prompt_config(
|
||||
arch_config_file=arch_config_file,
|
||||
arch_config_schema_file=arch_schema_config,
|
||||
)
|
||||
validate_schema(arch_config_file)
|
||||
except Exception as e:
|
||||
log.info(f"Exiting archgw up: validation failed")
|
||||
log.info(f"Error: {str(e)}")
|
||||
sys.exit(1)
|
||||
|
||||
log.info("Starging arch model server and arch gateway")
|
||||
|
|
@ -213,12 +213,6 @@ def up(file, path, service):
|
|||
else:
|
||||
env_stage[access_key] = env_file_dict[access_key]
|
||||
|
||||
with open(
|
||||
pkg_resources.resource_filename(__name__, "../config/env.list"), "w"
|
||||
) as file:
|
||||
for key, value in env_stage.items():
|
||||
file.write(f"{key}={value}\n")
|
||||
|
||||
env.update(env_stage)
|
||||
env["ARCH_CONFIG_FILE"] = arch_config_file
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import shlex
|
|||
import yaml
|
||||
import json
|
||||
import logging
|
||||
import docker
|
||||
|
||||
from cli.consts import ARCHGW_DOCKER_IMAGE, ARCHGW_DOCKER_NAME
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
|
|
@ -22,6 +25,41 @@ def getLogger(name="cli"):
|
|||
log = getLogger(__name__)
|
||||
|
||||
|
||||
def validate_schema(arch_config_file: str) -> None:
|
||||
try:
|
||||
client = docker.from_env()
|
||||
# Run the container with detach=True to avoid blocking main process
|
||||
container = client.containers.run(
|
||||
image=ARCHGW_DOCKER_IMAGE,
|
||||
volumes={
|
||||
f"{arch_config_file}": {
|
||||
"bind": "/app/arch_config.yaml",
|
||||
"mode": "ro",
|
||||
},
|
||||
},
|
||||
entrypoint=["python", "config_generator.py"],
|
||||
detach=True,
|
||||
)
|
||||
|
||||
# Wait for the container to finish and get the exit code
|
||||
exit_code = container.wait()
|
||||
|
||||
# Check exit code for validation success
|
||||
if exit_code["StatusCode"] != 0:
|
||||
# Validation failed (non-zero exit code)
|
||||
logs = container.logs().decode() # Get container logs for debugging
|
||||
raise ValueError(
|
||||
f"Validation failed. Container exited with code {exit_code}.\nLogs:\n{logs}"
|
||||
)
|
||||
|
||||
# Successful validation (exit code 0)
|
||||
log.info("Schema validation successful!")
|
||||
|
||||
except docker.errors.APIError as e:
|
||||
# Handle container creation error
|
||||
raise ValueError(f"Failed to create container: {e}")
|
||||
|
||||
|
||||
def run_docker_compose_ps(compose_file, env):
|
||||
"""
|
||||
Check if all Docker Compose services are in a healthy state.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import yaml
|
|||
import torch
|
||||
import string
|
||||
import logging
|
||||
import pkg_resources
|
||||
|
||||
from openai import OpenAI
|
||||
|
||||
|
|
@ -11,13 +10,6 @@ from openai import OpenAI
|
|||
logger_instance = None
|
||||
|
||||
|
||||
def load_yaml_config(file_name):
|
||||
# Load the YAML file from the package
|
||||
yaml_path = pkg_resources.resource_filename("app", file_name)
|
||||
with open(yaml_path, "r") as yaml_file:
|
||||
return yaml.safe_load(yaml_file)
|
||||
|
||||
|
||||
def get_device():
|
||||
available_device = {
|
||||
"cpu": True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue