minor fixes to make sure PR is clean. Ready to ship

This commit is contained in:
Salman Paracha 2025-09-29 14:13:04 -07:00
parent 5f7f38ad24
commit e771912a86
4 changed files with 49 additions and 106 deletions

View file

@ -1,10 +1,11 @@
import json
import subprocess
import os
import time
import sys
import yaml
from cli.utils import getLogger, read_config_file
from cli.utils import getLogger
from cli.consts import (
ARCHGW_DOCKER_IMAGE,
ARCHGW_DOCKER_NAME,
@ -189,26 +190,13 @@ def stop_arch_modelserver():
def start_cli_agent(arch_config_file=None, settings_json="{}"):
"""Start a CLI client connected to Arch."""
import json
# Use current directory for config if not specified
if arch_config_file is None:
config_path = "."
else:
config_path = (
os.path.dirname(arch_config_file)
if os.path.dirname(arch_config_file)
else "."
)
# Get port and host from arch_config.yaml listeners > egress
arch_config = read_config_file(config_path)
if not arch_config:
log.error(f"Config file not found in {config_path}")
sys.exit(1)
with open(arch_config_file, "r") as file:
arch_config = file.read()
arch_config_yaml = yaml.safe_load(arch_config)
# Get egress listener configuration
egress_config = arch_config.get("listeners", {}).get("egress_traffic", {})
egress_config = arch_config_yaml.get("listeners", {}).get("egress_traffic", {})
host = egress_config.get("host", "127.0.0.1")
port = egress_config.get("port", 12000)
@ -240,7 +228,7 @@ def start_cli_agent(arch_config_file=None, settings_json="{}"):
]
else:
# Check if arch.claude.code.small.fast alias exists in model_aliases
model_aliases = arch_config.get("model_aliases", {})
model_aliases = arch_config_yaml.get("model_aliases", {})
if "arch.claude.code.small.fast" in model_aliases:
env["ANTHROPIC_SMALL_FAST_MODEL"] = "arch.claude.code.small.fast"
else:
@ -276,7 +264,7 @@ def start_cli_agent(arch_config_file=None, settings_json="{}"):
# Use claude from PATH
claude_path = "claude"
log.info(f"Starting Claude CLI Agent to Arch at {host}:{port}")
log.info(f"Connecting Claude Code Agent to Arch at {host}:{port}")
try:
subprocess.run([claude_path] + claude_args, env=env, check=True)

View file

@ -17,7 +17,6 @@ from cli.utils import (
has_ingress_listener,
load_env_file_to_dict,
stream_access_logs,
read_config_file,
find_config_file,
)
from cli.core import (
@ -189,7 +188,6 @@ def up(file, path, service, foreground):
return
log.info(f"Validating {arch_config_file}")
(
validation_return_code,
validation_stdout,

View file

@ -88,23 +88,6 @@ def load_env_file_to_dict(file_path):
return env_dict
def read_config_file(path="."):
"""Read configuration from arch_config.yaml or config.yaml in the specified path."""
config_files = ["arch_config.yaml", "config.yaml"]
for config_file in config_files:
config_path = os.path.abspath(os.path.join(path, config_file))
if os.path.exists(config_path):
try:
with open(config_path, "r") as f:
return yaml.safe_load(f)
except Exception as e:
log.warning(f"Error reading {config_path}: {e}")
continue
return {}
def find_config_file(path=".", file=None):
"""Find the appropriate config file path."""
if file: