Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
leseb committed Feb 24, 2025
1 parent 1719a76 commit 76151f9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/providers-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
strategy:
matrix:
template: ${{ fromJson(needs.generate-matrix.outputs.templates) }}
image-type: [venv, container]

steps:
- name: Checkout repository
Expand All @@ -48,6 +49,16 @@ jobs:
source .venv/bin/activate
uv pip install -e .
- name: Print build dependencies
run: |
uv run llama stack build --template ${{ matrix.template }} --image-type ${{ matrix.image-type }} --image-name test --print-deps-only
- name: Run Llama Stack Build
run: |
uv run llama stack build --template ${{ matrix.template }} --image-type venv
uv run llama stack build --template ${{ matrix.template }} --image-type ${{ matrix.image-type }} --image-name test
- name: Print dependencies in the image
if: matrix.image-type == 'venv'
run: |
source test/bin/activate
uv pip list
17 changes: 9 additions & 8 deletions llama_stack/cli/stack/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import json
import os
import shutil
import sys
import textwrap
from functools import lru_cache
from pathlib import Path
Expand Down Expand Up @@ -79,7 +80,7 @@ def run_stack_build_command(args: argparse.Namespace) -> None:
f"Could not find template {args.template}. Please run `llama stack build --list-templates` to check out the available templates",
color="red",
)
return
sys.exit(1)
build_config = available_templates[args.template]
if args.image_type:
build_config.image_type = args.image_type
Expand All @@ -88,7 +89,7 @@ def run_stack_build_command(args: argparse.Namespace) -> None:
f"Please specify a image-type (container | conda | venv) for {args.template}",
color="red",
)
return
sys.exit(1)
elif not args.config and not args.template:
name = prompt(
"> Enter a name for your Llama Stack (e.g. my-local-stack): ",
Expand Down Expand Up @@ -169,14 +170,14 @@ def run_stack_build_command(args: argparse.Namespace) -> None:
f"Could not parse config file {args.config}: {e}",
color="red",
)
return
sys.exit(1)

if build_config.image_type == ImageType.container.value and not args.image_name:
cprint(
"Please specify --image-name when building a container from a config file",
color="red",
)
return
sys.exit(1)

if args.print_deps_only:
print(f"# Dependencies for {args.template or args.config or image_name}")
Expand All @@ -195,18 +196,18 @@ def run_stack_build_command(args: argparse.Namespace) -> None:
template_name=args.template,
)

except Exception as exc:
except (Exception, RuntimeError) as exc:
cprint(
f"Error building stack: {exc}",
color="red",
)
return
sys.exit(1)
if run_config is None:
cprint(
"Run config path is empty",
color="red",
)
return
sys.exit(1)

if args.run:
run_config = Path(run_config)
Expand Down Expand Up @@ -312,7 +313,7 @@ def _run_stack_build_command_from_build_config(
template_or_config=template_name or config_path,
)
if return_code != 0:
return
raise RuntimeError(f"Failed to build image {image_name}")

if template_name:
# copy run.yaml from template to build_dir instead of generating it again
Expand Down
2 changes: 1 addition & 1 deletion llama_stack/distribution/build_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ container_base="$3"
build_file_path="$4"
host_build_dir="$5"
pip_dependencies="$6"
special_pip_deps="$7"
special_pip_deps="${7:-}"


# Define color codes
Expand Down
6 changes: 3 additions & 3 deletions llama_stack/distribution/build_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ -n "$LLAMA_MODELS_DIR" ]; then
echo "Using llama-models-dir=$LLAMA_MODELS_DIR"
fi

if [ "$#" -lt 3 ]; then
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <distribution_type> <env_name> <pip_dependencies> [<special_pip_deps>]" >&2
echo "Example: $0 <distribution_type> mybuild ./my-stack-build.yaml 'numpy pandas scipy'" >&2
exit 1
Expand Down Expand Up @@ -74,8 +74,8 @@ run() {
local env_name="$1"
local pip_dependencies="$2"
local special_pip_deps="$3"
if [ -n "$UV_SYSTEM_PYTHON" ] || [ "$env_name" == "__system__" ]; then

if [ -n "$UV_SYSTEM_PYTHON" ] || [ "$env_name" == "__system__" ]; then
echo "Installing dependencies in system Python environment"
# if env == __system__, ensure we set UV_SYSTEM_PYTHON
export UV_SYSTEM_PYTHON=1
Expand Down

0 comments on commit 76151f9

Please sign in to comment.