Update llama stack configure to be very simple also

This commit is contained in:
Ashwin Bharambe 2024-08-30 14:55:20 -07:00
parent f8517e4688
commit 5172d9a79d

View file

@ -36,28 +36,21 @@ class StackConfigure(Subcommand):
) )
from llama_toolchain.core.package import BuildType from llama_toolchain.core.package import BuildType
self.parser.add_argument(
"--build-name",
type=str,
help="(Fully qualified) name of the stack build to configure. Alternatively, provider --distribution and --name",
required=False,
)
allowed_ids = [d.distribution_id for d in available_distribution_specs()] allowed_ids = [d.distribution_id for d in available_distribution_specs()]
self.parser.add_argument( self.parser.add_argument(
"--distribution", "distribution",
type=str, type=str,
choices=allowed_ids, choices=allowed_ids,
help="Distribution (one of: {})".format(allowed_ids), help="Distribution (one of: {})".format(allowed_ids),
required=False,
) )
self.parser.add_argument( self.parser.add_argument(
"--name", "--build-name",
type=str, type=str,
help="Name of the build", help="Name of the build",
required=False, required=True,
) )
self.parser.add_argument( self.parser.add_argument(
"--type", "--build-type",
type=str, type=str,
default="conda_env", default="conda_env",
choices=[v.value for v in BuildType], choices=[v.value for v in BuildType],
@ -66,15 +59,14 @@ class StackConfigure(Subcommand):
def _run_stack_configure_cmd(self, args: argparse.Namespace) -> None: def _run_stack_configure_cmd(self, args: argparse.Namespace) -> None:
from llama_toolchain.core.package import BuildType from llama_toolchain.core.package import BuildType
if args.build_name: build_type = BuildType(args.build_type)
name = args.build_name name = args.build_name
if name.endswith(".yaml"): config_file = (
name = name.replace(".yaml", "") BUILDS_BASE_DIR
else: / args.distribution
build_type = BuildType(args.type) / build_type.descriptor()
name = f"{build_type.descriptor()}-{args.distribution}-{args.name}" / f"{name}.yaml"
)
config_file = BUILDS_BASE_DIR / "stack" / f"{name}.yaml"
if not config_file.exists(): if not config_file.exists():
self.parser.error( self.parser.error(
f"Could not find {config_file}. Please run `llama stack build` first" f"Could not find {config_file}. Please run `llama stack build` first"