mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 19:04:19 +00:00
## What does this PR do? So far `llama stack build` has always created a separate conda environment for packaging the dependencies of a distribution. The main reason to do so is isolation -- distributions are composed of providers which can have a variety of potentially conflicting dependencies. That said, this has created significant annoyance for new users since it is not at all transparent. The fact that `llama stack run` is actually running the code in some other conda is very surprising. This PR tries to make things better. - Both `llama stack build` and `llama stack run` now accept an `--image-name` argument which represents the (conda, docker, virtualenv) image you want to operate upon. - For the default (conda) mode, the script checks if a current conda environment exists. If one exists, it uses it. - If `--image-name` is provided, that option is used. In this case, an environment is created if needed. - There is no automatic `llamastack-` prefixing of the environment names done anymore. ## Test Plan Start in a conda environment, run `llama stack build --template fireworks`; verify that it successfully built into the current environment and stored the build file at `$CONDA_PREFIX/llamastack-build.yaml`. Run `llama stack run fireworks` which started correctly in the current environment. Ran the same build command outside of conda. It failed asking for `--image-name`. Ran it with `llama stack build --template fireworks --image-name foo`. This successfully created a conda environment called `foo` and installed deps. Ran `llama stack run fireworks` outside conda which failed. Activated a different conda, ran again, it failed saying it did not find the `llamastack-build.yaml` file. Then used `--image-name foo` option and it ran successfully.
64 lines
1.2 KiB
Bash
Executable file
64 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
set -euo pipefail
|
|
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
error_handler() {
|
|
echo "Error occurred in script at line: ${1}" >&2
|
|
exit 1
|
|
}
|
|
|
|
trap 'error_handler ${LINENO}' ERR
|
|
|
|
if [ $# -lt 3 ]; then
|
|
echo "Usage: $0 <build_name> <yaml_config> <port> <script_args...>"
|
|
exit 1
|
|
fi
|
|
|
|
env_name="$1"
|
|
shift
|
|
|
|
yaml_config="$1"
|
|
shift
|
|
|
|
port="$1"
|
|
shift
|
|
|
|
# Process environment variables from --env arguments
|
|
env_vars=""
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--env)
|
|
|
|
if [[ -n "$2" ]]; then
|
|
# collect environment variables so we can set them after activating the conda env
|
|
env_vars="$env_vars --env $2"
|
|
shift 2
|
|
else
|
|
echo -e "${RED}Error: --env requires a KEY=VALUE argument${NC}" >&2
|
|
exit 1
|
|
fi
|
|
;;
|
|
*)
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
eval "$(conda shell.bash hook)"
|
|
conda deactivate && conda activate "$env_name"
|
|
|
|
set -x
|
|
$CONDA_PREFIX/bin/python \
|
|
-m llama_stack.distribution.server.server \
|
|
--yaml-config "$yaml_config" \
|
|
--port "$port" \
|
|
$env_vars
|