fix build from templates CLI

This commit is contained in:
Xi Yan 2024-10-25 12:44:04 -07:00
parent 7e60a9ca6d
commit 474101a9f7

View file

@ -96,19 +96,22 @@ class StackBuild(Subcommand):
"You must specify a name for the build using --name when using a template" "You must specify a name for the build using --name when using a template"
) )
return return
build_path = TEMPLATES_PATH / f"{args.template}-build.yaml" available_templates = available_templates_specs()
if not build_path.exists(): for build_config in available_templates:
self.parser.error( if build_config.name == args.template:
f"Could not find template {args.template}. Please run `llama stack build --list-templates` to check out the available templates" build_config.name = args.name
) if args.image_type:
return build_config.image_type = args.image_type
with open(build_path, "r") as f: else:
build_config = BuildConfig(**yaml.safe_load(f)) self.parser.error(
build_config.name = args.name f"Please specify a image-type (docker | conda) for {args.template}"
if args.image_type: )
build_config.image_type = args.image_type self._run_stack_build_command_from_build_config(build_config)
self._run_stack_build_command_from_build_config(build_config) return
self.parser.error(
f"Could not find template {args.template}. Please run `llama stack build --list-templates` to check out the available templates"
)
return return
# try to see if we can find a pre-existing build config file through name # try to see if we can find a pre-existing build config file through name