From 62d266f0188014160898b66d3cde33457f5acd64 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Thu, 3 Oct 2024 11:20:54 -0700 Subject: [PATCH] [CLI] avoid configure twice (#171) * avoid configure twice * cleanup tmp config * update output msg * address comment * update msg * script update --- llama_stack/cli/stack/build.py | 14 ++++++++++---- llama_stack/distribution/build.py | 7 +++++-- llama_stack/distribution/build_container.sh | 11 ++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/llama_stack/cli/stack/build.py b/llama_stack/cli/stack/build.py index d502e4c84..95df6a737 100644 --- a/llama_stack/cli/stack/build.py +++ b/llama_stack/cli/stack/build.py @@ -137,10 +137,16 @@ class StackBuild(Subcommand): if build_config.image_type == "conda" else (f"llamastack-{build_config.name}") ) - cprint( - f"You can now run `llama stack configure {configure_name}`", - color="green", - ) + if build_config.image_type == "conda": + cprint( + f"You can now run `llama stack configure {configure_name}`", + color="green", + ) + else: + cprint( + f"You can now run `llama stack run {build_config.name}`", + color="green", + ) def _run_template_list_cmd(self, args: argparse.Namespace) -> None: import json diff --git a/llama_stack/distribution/build.py b/llama_stack/distribution/build.py index fe778bdb8..56186a5aa 100644 --- a/llama_stack/distribution/build.py +++ b/llama_stack/distribution/build.py @@ -8,15 +8,17 @@ from enum import Enum from typing import List, Optional import pkg_resources + +from llama_stack.distribution.utils.exec import run_with_pty from pydantic import BaseModel from termcolor import cprint -from llama_stack.distribution.utils.exec import run_with_pty - from llama_stack.distribution.datatypes import * # noqa: F403 from pathlib import Path +from llama_stack.distribution.distribution import api_providers, SERVER_DEPENDENCIES +from llama_stack.distribution.utils.config_dirs import BUILDS_BASE_DIR from llama_stack.distribution.distribution import get_provider_registry @@ -95,6 +97,7 @@ def build_image(build_config: BuildConfig, build_file_path: Path): build_config.name, package_deps.docker_image, str(build_file_path), + str(BUILDS_BASE_DIR / ImageType.docker.value), " ".join(deps), ] else: diff --git a/llama_stack/distribution/build_container.sh b/llama_stack/distribution/build_container.sh index 625c8cfc3..056a7c06c 100755 --- a/llama_stack/distribution/build_container.sh +++ b/llama_stack/distribution/build_container.sh @@ -10,7 +10,7 @@ if [ "$#" -lt 4 ]; then exit 1 fi -special_pip_deps="$5" +special_pip_deps="$6" set -euo pipefail @@ -18,7 +18,8 @@ build_name="$1" image_name="llamastack-$build_name" docker_base=$2 build_file_path=$3 -pip_dependencies=$4 +host_build_dir=$4 +pip_dependencies=$5 # Define color codes RED='\033[0;31m' @@ -33,7 +34,8 @@ REPO_CONFIGS_DIR="$REPO_DIR/tmp/configs" TEMP_DIR=$(mktemp -d) -llama stack configure $build_file_path --output-dir $REPO_CONFIGS_DIR +llama stack configure $build_file_path +cp $host_build_dir/$build_name-run.yaml $REPO_CONFIGS_DIR add_to_docker() { local input @@ -132,6 +134,9 @@ fi set -x $DOCKER_BINARY build $DOCKER_OPTS -t $image_name -f "$TEMP_DIR/Dockerfile" "$REPO_DIR" $mounts + +# clean up tmp/configs +rm -rf $REPO_CONFIGS_DIR set +x echo "Success! You can run it with: $DOCKER_BINARY $DOCKER_OPTS run -p 5000:5000 $image_name"