Make install + start scripts do proper configuration automatically

This commit is contained in:
Ashwin Bharambe 2024-08-06 21:34:09 -07:00
parent 9e1ca4eeb1
commit e1a7aa4773
5 changed files with 84 additions and 39 deletions

View file

@ -66,13 +66,20 @@ ensure_conda_env_python310() {
fi
}
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <environment_name> <pip_dependencies>" >&2
echo "Example: $0 my_env 'numpy pandas scipy'" >&2
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <environment_name> <distribution_name> <pip_dependencies>" >&2
echo "Example: $0 my_env local-inline 'numpy pandas scipy'" >&2
exit 1
fi
env_name="$1"
pip_dependencies="$2"
distribution_name="$2"
pip_dependencies="$3"
ensure_conda_env_python310 "$env_name" "$pip_dependencies"
eval "$(conda shell.bash hook)"
conda deactivate && conda activate "$env_name"
python_interp=$(conda run -n "$env_name" which python)
$python_interp -m llama_toolchain.cli.llama distribution configure --name "$distribution_name"

View file

@ -73,7 +73,6 @@ def available_distribution_specs() -> List[DistributionSpec]:
additional_pip_packages=[
"python-dotenv",
"blobfile",
"codeshield",
"fairscale",
"fastapi",
"fire",
@ -82,6 +81,7 @@ def available_distribution_specs() -> List[DistributionSpec]:
"json-strong-typing",
"pydantic==1.10.13",
"pydantic_core==2.18.2",
"tiktoken",
"uvicorn",
],
provider_specs={x: remote_spec(x) for x in providers},

View file

@ -0,0 +1,36 @@
#!/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
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color
error_handler() {
echo "Error occurred in script at line: ${1}" >&2
exit 1
}
# Set up the error trap
trap 'error_handler ${LINENO}' ERR
if [ $# -lt 2 ]; then
echo "Usage: $0 <environment_name> <script_args...>"
exit 1
fi
env_name="$1"
shift
eval "$(conda shell.bash hook)"
conda deactivate && conda activate "$env_name"
python_interp=$(conda run -n "$env_name" which python)
$python_interp -m llama_toolchain.distribution.server "$@"