From adfa2c3413d7a34dd2f5550a87e5dbc543fc4643 Mon Sep 17 00:00:00 2001 From: Yuan Tang Date: Fri, 17 Jan 2025 12:16:04 -0500 Subject: [PATCH] Some leftovers Signed-off-by: Yuan Tang --- docs/source/distributions/building_distro.md | 20 ++++---- llama_stack/cli/stack/configure.py | 2 +- llama_stack/cli/stack/run.py | 2 +- llama_stack/distribution/build.py | 2 +- llama_stack/distribution/build_container.sh | 46 +++++++++---------- .../distribution/configure_container.sh | 8 ++-- llama_stack/distribution/start_container.sh | 10 ++-- llama_stack/providers/datatypes.py | 2 +- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/docs/source/distributions/building_distro.md b/docs/source/distributions/building_distro.md index c662d43b6..83069aa05 100644 --- a/docs/source/distributions/building_distro.md +++ b/docs/source/distributions/building_distro.md @@ -17,13 +17,13 @@ pip install -e . llama stack build -h ``` -We will start build our distribution (in the form of a Conda environment, or Docker image). In this step, we will specify: +We will start build our distribution (in the form of a Conda environment, or Container image). In this step, we will specify: - `name`: the name for our distribution (e.g. `my-stack`) - `image_type`: our build image type (`conda | container`) - `distribution_spec`: our distribution specs for specifying API providers - `description`: a short description of the configurations for the distribution - `providers`: specifies the underlying implementation for serving each API endpoint - - `image_type`: `conda` | `container` to specify whether to build the distribution in the form of Docker image or Conda environment. + - `image_type`: `conda` | `container` to specify whether to build the distribution in the form of Container image or Conda environment. After this step is complete, a file named `-build.yaml` and template file `-run.yaml` will be generated and saved at the output file path specified at the end of the command. @@ -35,7 +35,7 @@ After this step is complete, a file named `-build.yaml` and template file llama stack build > Enter a name for your Llama Stack (e.g. my-local-stack): my-stack -> Enter the image type you want your Llama Stack to be built as (docker or conda): conda +> Enter the image type you want your Llama Stack to be built as (container or conda): conda Llama Stack is composed of several APIs working together. Let's select the provider types (implementations) you want to use for these APIs. @@ -348,26 +348,26 @@ llama stack build --config llama_stack/templates/ollama/build.yaml ``` ::: -:::{tab-item} Building Docker +:::{tab-item} Building Container > [!TIP] -> Podman is supported as an alternative to Docker. Set `DOCKER_BINARY` to `podman` in your environment to use Podman. +> Podman is supported as an alternative to Docker. Set `CONTAINER_BINARY` to `podman` in your environment to use Podman. -To build a docker image, you may start off from a template and use the `--image-type docker` flag to specify `docker` as the build image type. +To build a container image, you may start off from a template and use the `--image-type container` flag to specify `container` as the build image type. ``` -llama stack build --template ollama --image-type docker +llama stack build --template ollama --image-type container ``` ``` -$ llama stack build --template ollama --image-type docker +$ llama stack build --template ollama --image-type container ... -Dockerfile created successfully in /tmp/tmp.viA3a3Rdsg/DockerfileFROM python:3.10-slim +Containerfile created successfully in /tmp/tmp.viA3a3Rdsg/ContainerfileFROM python:3.10-slim ... You can now edit ~/meta-llama/llama-stack/tmp/configs/ollama-run.yaml and run `llama stack run ~/meta-llama/llama-stack/tmp/configs/ollama-run.yaml` ``` -After this step is successful, you should be able to find the built docker image and test it with `llama stack run `. +After this step is successful, you should be able to find the built container image and test it with `llama stack run `. ::: :::: diff --git a/llama_stack/cli/stack/configure.py b/llama_stack/cli/stack/configure.py index 11d3f705a..56f4feceb 100644 --- a/llama_stack/cli/stack/configure.py +++ b/llama_stack/cli/stack/configure.py @@ -27,7 +27,7 @@ class StackConfigure(Subcommand): self.parser.add_argument( "config", type=str, - help="Path to the build config file (e.g. ~/.llama/builds//-build.yaml). For docker, this could also be the name of the docker image. ", + help="Path to the build config file (e.g. ~/.llama/builds//-build.yaml). For container, this could also be the name of the container image. ", ) self.parser.add_argument( diff --git a/llama_stack/cli/stack/run.py b/llama_stack/cli/stack/run.py index 78d92a130..e1e02d10c 100644 --- a/llama_stack/cli/stack/run.py +++ b/llama_stack/cli/stack/run.py @@ -92,7 +92,7 @@ class StackRun(Subcommand): ) if not config_file.exists() and not has_yaml_suffix: - # check if it's a build config saved to docker dir + # check if it's a build config saved to container dir config_file = Path( BUILDS_BASE_DIR / ImageType.container.value / f"{args.config}-run.yaml" ) diff --git a/llama_stack/distribution/build.py b/llama_stack/distribution/build.py index dd201b42b..b8d35ccdc 100644 --- a/llama_stack/distribution/build.py +++ b/llama_stack/distribution/build.py @@ -78,7 +78,7 @@ def get_provider_dependencies( provider_spec = providers_for_api[provider_type] deps.extend(provider_spec.pip_packages) if provider_spec.container_image: - raise ValueError("A stack's dependencies cannot have a docker image") + raise ValueError("A stack's dependencies cannot have a container image") normal_deps = [] special_deps = [] diff --git a/llama_stack/distribution/build_container.sh b/llama_stack/distribution/build_container.sh index 17902de0a..4c2425004 100755 --- a/llama_stack/distribution/build_container.sh +++ b/llama_stack/distribution/build_container.sh @@ -13,7 +13,7 @@ PYPI_VERSION=${PYPI_VERSION:-} BUILD_PLATFORM=${BUILD_PLATFORM:-} if [ "$#" -lt 4 ]; then - echo "Usage: $0 []" >&2 + echo "Usage: $0 []" >&2 echo "Example: $0 my-fastapi-app python:3.9-slim 'fastapi uvicorn' " >&2 exit 1 fi @@ -24,7 +24,7 @@ set -euo pipefail build_name="$1" image_name="distribution-$build_name" -docker_base=$2 +container_base=$2 build_file_path=$3 host_build_dir=$4 pip_dependencies=$5 @@ -36,14 +36,14 @@ NC='\033[0m' # No Color SCRIPT_DIR=$(dirname "$(readlink -f "$0")") REPO_DIR=$(dirname $(dirname "$SCRIPT_DIR")) -DOCKER_BINARY=${DOCKER_BINARY:-docker} -DOCKER_OPTS=${DOCKER_OPTS:-} +CONTAINER_BINARY=${CONTAINER_BINARY:-docker} +CONTAINER_OPTS=${CONTAINER_OPTS:-} TEMP_DIR=$(mktemp -d) -add_to_docker() { +add_to_container() { local input - output_file="$TEMP_DIR/Dockerfile" + output_file="$TEMP_DIR/Containerfile" if [ -t 0 ]; then printf '%s\n' "$1" >>"$output_file" else @@ -53,9 +53,9 @@ add_to_docker() { } # Update and install UBI9 components if UBI9 base image is used -if [[ $docker_base == *"registry.access.redhat.com/ubi9"* ]]; then - add_to_docker << EOF -FROM $docker_base +if [[ $container_base == *"registry.access.redhat.com/ubi9"* ]]; then + add_to_container << EOF +FROM $container_base WORKDIR /app RUN microdnf -y update && microdnf install -y iputils net-tools wget \ @@ -64,8 +64,8 @@ RUN microdnf -y update && microdnf install -y iputils net-tools wget \ EOF else - add_to_docker << EOF -FROM $docker_base + add_to_container << EOF +FROM $container_base WORKDIR /app RUN apt-get update && apt-get install -y \ @@ -82,7 +82,7 @@ fi # Add pip dependencies first since llama-stack is what will change most often # so we can reuse layers. if [ -n "$pip_dependencies" ]; then - add_to_docker << EOF + add_to_container << EOF RUN pip install --no-cache $pip_dependencies EOF fi @@ -90,7 +90,7 @@ fi if [ -n "$special_pip_deps" ]; then IFS='#' read -ra parts <<<"$special_pip_deps" for part in "${parts[@]}"; do - add_to_docker </dev/null && selinuxenabled; then # Disable SELinux labels -- we don't want to relabel the llama-stack source dir - DOCKER_OPTS="$DOCKER_OPTS --security-opt label=disable" + CONTAINER_OPTS="$CONTAINER_OPTS --security-opt label=disable" fi # Set version tag based on PyPI version @@ -200,7 +200,7 @@ else fi set -x -$DOCKER_BINARY build $DOCKER_OPTS $PLATFORM -t $image_tag -f "$TEMP_DIR/Dockerfile" "$REPO_DIR" $mounts +$CONTAINER_BINARY build $CONTAINER_OPTS $PLATFORM -t $image_tag -f "$TEMP_DIR/Containerfile" "$REPO_DIR" $mounts # clean up tmp/configs set +x diff --git a/llama_stack/distribution/configure_container.sh b/llama_stack/distribution/configure_container.sh index 712044ca6..b01251e46 100755 --- a/llama_stack/distribution/configure_container.sh +++ b/llama_stack/distribution/configure_container.sh @@ -6,8 +6,8 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. -DOCKER_BINARY=${DOCKER_BINARY:-docker} -DOCKER_OPTS=${DOCKER_OPTS:-} +CONTAINER_BINARY=${CONTAINER_BINARY:-docker} +CONTAINER_OPTS=${CONTAINER_OPTS:-} LLAMA_STACK_DIR=${LLAMA_STACK_DIR:-} set -euo pipefail @@ -30,7 +30,7 @@ container_build_dir="/app/builds" if command -v selinuxenabled &> /dev/null && selinuxenabled; then # Disable SELinux labels - DOCKER_OPTS="$DOCKER_OPTS --security-opt label=disable" + CONTAINER_OPTS="$CONTAINER_OPTS --security-opt label=disable" fi mounts="" @@ -39,7 +39,7 @@ if [ -n "$LLAMA_STACK_DIR" ]; then fi set -x -$DOCKER_BINARY run $DOCKER_OPTS -it \ +$CONTAINER_BINARY run $CONTAINER_OPTS -it \ --entrypoint "/usr/local/bin/llama" \ -v $host_build_dir:$container_build_dir \ $mounts \ diff --git a/llama_stack/distribution/start_container.sh b/llama_stack/distribution/start_container.sh index 951c65f36..1a55bf96d 100755 --- a/llama_stack/distribution/start_container.sh +++ b/llama_stack/distribution/start_container.sh @@ -6,8 +6,8 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. -DOCKER_BINARY=${DOCKER_BINARY:-docker} -DOCKER_OPTS=${DOCKER_OPTS:-} +CONTAINER_BINARY=${CONTAINER_BINARY:-docker} +CONTAINER_OPTS=${CONTAINER_OPTS:-} LLAMA_CHECKPOINT_DIR=${LLAMA_CHECKPOINT_DIR:-} LLAMA_STACK_DIR=${LLAMA_STACK_DIR:-} TEST_PYPI_VERSION=${TEST_PYPI_VERSION:-} @@ -64,7 +64,7 @@ set -x if command -v selinuxenabled &> /dev/null && selinuxenabled; then # Disable SELinux labels - DOCKER_OPTS="$DOCKER_OPTS --security-opt label=disable" + CONTAINER_OPTS="$CONTAINER_OPTS --security-opt label=disable" fi mounts="" @@ -73,7 +73,7 @@ if [ -n "$LLAMA_STACK_DIR" ]; then fi if [ -n "$LLAMA_CHECKPOINT_DIR" ]; then mounts="$mounts -v $LLAMA_CHECKPOINT_DIR:/root/.llama" - DOCKER_OPTS="$DOCKER_OPTS --gpus=all" + CONTAINER_OPTS="$CONTAINER_OPTS --gpus=all" fi version_tag="latest" @@ -85,7 +85,7 @@ elif [ -n "$TEST_PYPI_VERSION" ]; then version_tag="test-$TEST_PYPI_VERSION" fi -$DOCKER_BINARY run $DOCKER_OPTS -it \ +$CONTAINER_BINARY run $CONTAINER_OPTS -it \ -p $port:$port \ $env_vars \ -v "$yaml_config:/app/config.yaml" \ diff --git a/llama_stack/providers/datatypes.py b/llama_stack/providers/datatypes.py index 163f8e5dc..d176d6ec4 100644 --- a/llama_stack/providers/datatypes.py +++ b/llama_stack/providers/datatypes.py @@ -150,7 +150,7 @@ class InlineProviderSpec(ProviderSpec): container_image: Optional[str] = Field( default=None, description=""" -The docker image to use for this implementation. If one is provided, pip_packages will be ignored. +The container image to use for this implementation. If one is provided, pip_packages will be ignored. If a provider depends on other providers, the dependencies MUST NOT specify a container image. """, )