forked from phoenix-oss/llama-stack-mirror
allow --name to re-build from config
This commit is contained in:
parent
d28c3dfe0f
commit
4897bf2f85
1 changed files with 30 additions and 0 deletions
|
@ -29,6 +29,26 @@ def available_templates_specs() -> List[BuildConfig]:
|
|||
|
||||
return template_specs
|
||||
|
||||
def get_build_config_from_name(name: str) -> Optional[Path]:
|
||||
if os.getenv("CONDA_PREFIX", ""):
|
||||
conda_dir = (
|
||||
Path(os.getenv("CONDA_PREFIX")).parent / f"llamastack-{args.config}"
|
||||
)
|
||||
else:
|
||||
cprint(
|
||||
"Cannot find CONDA_PREFIX. Trying default conda path ~/.conda/envs...",
|
||||
color="green",
|
||||
)
|
||||
conda_dir = (
|
||||
Path(os.path.expanduser("~/.conda/envs")) / f"llamastack-{args.config}"
|
||||
)
|
||||
|
||||
build_config_file = Path(conda_dir) / f"{args.config}-build.yaml"
|
||||
if build_config_file.exists():
|
||||
return build_config_file
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class StackBuild(Subcommand):
|
||||
def __init__(self, subparsers: argparse._SubParsersAction):
|
||||
|
@ -189,6 +209,16 @@ class StackBuild(Subcommand):
|
|||
|
||||
return
|
||||
|
||||
# try to see if we can find a pre-existing build config file through name
|
||||
if args.name:
|
||||
maybe_build_config = get_build_config_from_name(args.name)
|
||||
if maybe_build_config:
|
||||
print(f"Building from existing build config for {args.name} in {str(maybe_build_config)}")
|
||||
with open(maybe_build_config, "r") as f:
|
||||
build_config = BuildConfig(**yaml.safe_load(f))
|
||||
self._run_stack_build_command_from_build_config(build_config)
|
||||
return
|
||||
|
||||
if not args.config and not args.template:
|
||||
if not args.name:
|
||||
name = prompt(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue