fix: use --template flag for server (#2643)

# What does this PR do?

currently when a template is used, we still use `--config`.

`server.py` has a dedicated `--template` flag and logic, use that
instead

Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
Charlie Doern 2025-07-08 03:48:50 -04:00 committed by GitHub
parent e9926564bd
commit 27b3cd570f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View file

@ -155,8 +155,12 @@ class StackRun(Subcommand):
# func=<bound method StackRun._run_stack_run_cmd of <llama_stack.cli.stack.run.StackRun object at 0x10484b010>> # func=<bound method StackRun._run_stack_run_cmd of <llama_stack.cli.stack.run.StackRun object at 0x10484b010>>
if callable(getattr(args, arg)): if callable(getattr(args, arg)):
continue continue
if arg == "config" and template_name: if arg == "config":
server_args.config = str(config_file) if template_name:
server_args.template = str(template_name)
else:
# Set the config file path
server_args.config = str(config_file)
else: else:
setattr(server_args, arg, getattr(args, arg)) setattr(server_args, arg, getattr(args, arg))
@ -168,7 +172,10 @@ class StackRun(Subcommand):
run_args.extend([str(args.port)]) run_args.extend([str(args.port)])
if config_file: if config_file:
run_args.extend(["--config", str(config_file)]) if template_name:
run_args.extend(["--template", str(template_name)])
else:
run_args.extend(["--config", str(config_file)])
if args.env: if args.env:
for env_var in args.env: for env_var in args.env:

View file

@ -405,13 +405,13 @@ def main(args: argparse.Namespace | None = None):
args = parser.parse_args() args = parser.parse_args()
log_line = "" log_line = ""
if args.config: if hasattr(args, "config") and args.config:
# if the user provided a config file, use it, even if template was specified # if the user provided a config file, use it, even if template was specified
config_file = Path(args.config) config_file = Path(args.config)
if not config_file.exists(): if not config_file.exists():
raise ValueError(f"Config file {config_file} does not exist") raise ValueError(f"Config file {config_file} does not exist")
log_line = f"Using config file: {config_file}" log_line = f"Using config file: {config_file}"
elif args.template: elif hasattr(args, "template") and args.template:
config_file = Path(REPO_ROOT) / "llama_stack" / "templates" / args.template / "run.yaml" config_file = Path(REPO_ROOT) / "llama_stack" / "templates" / args.template / "run.yaml"
if not config_file.exists(): if not config_file.exists():
raise ValueError(f"Template {args.template} does not exist") raise ValueError(f"Template {args.template} does not exist")