Reduce a bunch of dependencies from toolchain

Some improvements to the distribution install script
This commit is contained in:
Ashwin Bharambe 2024-08-07 18:02:35 -07:00
parent 171a178783
commit f27d629fe8
27 changed files with 82 additions and 103 deletions

View file

@ -7,8 +7,9 @@
from enum import Enum
from typing import Any, Dict, List, Optional
from llama_models.schema_utils import json_schema_type
from pydantic import BaseModel, Field
from strong_typing.schema import json_schema_type
@json_schema_type

View file

@ -50,20 +50,30 @@ ensure_conda_env_python310() {
conda create -n "${env_name}" python="${python_version}" -y
fi
# Install pip dependencies
if [ -n "$pip_dependencies" ]; then
echo "Installing pip dependencies: $pip_dependencies"
conda run -n "${env_name}" pip install $pip_dependencies
fi
# Re-installing llama-toolchain in the new conda environment
if git rev-parse --is-inside-work-tree &> /dev/null; then
if git rev-parse --is-inside-work-tree &>/dev/null; then
repo_root=$(git rev-parse --show-toplevel)
cd "$repo_root"
conda run -n "${env_name}" pip install -e .
else
echo -e "${RED}Not inside a Git repository. Please re-run from within llama-toolchain repository.${NC}"
exit 1
conda run -n "${env_name}" pip install llama-toolchain
fi
if [ -n "$LLAMA_MODELS_DIR" ]; then
if [ ! -d "$LLAMA_MODELS_DIR" ]; then
echo -e "${RED}Warning: LLAMA_MODELS_DIR is set but directory does not exist: $LLAMA_MODELS_DIR${NC}" >&2
exit 1
fi
echo "Installing from LLAMA_MODELS_DIR: $LLAMA_MODELS_DIR"
conda run -n "${env_name}" pip uninstall -y llama-models
conda run -n "${env_name}" pip install -e "$LLAMA_MODELS_DIR"
fi
# Install pip dependencies
if [ -n "$pip_dependencies" ]; then
echo "Installing pip dependencies: $pip_dependencies"
conda run -n "${env_name}" pip install $pip_dependencies
fi
}
@ -79,10 +89,11 @@ pip_dependencies="$3"
ensure_conda_env_python310 "$env_name" "$pip_dependencies"
echo -e "${GREEN}Successfully setup distribution environment. Starting to configure ....${NC}"
echo -e "${GREEN}Successfully setup distribution environment. Configuring...${NC}"
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

@ -10,32 +10,11 @@ from typing import List, Optional
from .datatypes import Api, DistributionSpec, RemoteProviderSpec
from .distribution import api_providers
# This is currently duplicated from `requirements.txt` with a few minor changes
# dev-dependencies like "ufmt" etc. are nuked. A few specialized dependencies
# are moved to the appropriate distribution.
# These are the dependencies needed by the distribution server.
# `llama-toolchain` is automatically installed by the installation script.
COMMON_DEPENDENCIES = [
"accelerate",
"black==24.4.2",
"blobfile",
"codeshield",
"fairscale",
"fastapi",
"fire",
"flake8",
"httpx",
"huggingface-hub",
"json-strong-typing",
"llama-models",
"pandas",
"Pillow",
"pydantic==1.10.13",
"pydantic_core==2.18.2",
"python-dotenv",
"python-openapi",
"requests",
"tiktoken",
"torch",
"transformers",
"uvicorn",
]
@ -59,10 +38,22 @@ def available_distribution_specs() -> List[DistributionSpec]:
DistributionSpec(
spec_id="inline",
description="Use code from `llama_toolchain` itself to serve all llama stack APIs",
additional_pip_packages=COMMON_DEPENDENCIES
+ [
"fbgemm-gpu==0.8.0",
],
additional_pip_packages=(
COMMON_DEPENDENCIES
# why do we need any of these? they should be completely covered
# by the provider dependencies themselves
+ [
"accelerate",
"blobfile",
"codeshield",
"fairscale",
"pandas",
"Pillow",
"torch",
"transformers",
"fbgemm-gpu==0.8.0",
]
),
provider_specs={
Api.inference: providers[Api.inference]["meta-reference"],
Api.safety: providers[Api.safety]["meta-reference"],
@ -72,20 +63,7 @@ def available_distribution_specs() -> List[DistributionSpec]:
DistributionSpec(
spec_id="remote",
description="Point to remote services for all llama stack APIs",
additional_pip_packages=[
"python-dotenv",
"blobfile",
"fairscale",
"fastapi",
"fire",
"httpx",
"huggingface-hub",
"json-strong-typing",
"pydantic==1.10.13",
"pydantic_core==2.18.2",
"tiktoken",
"uvicorn",
],
additional_pip_packages=COMMON_DEPENDENCIES,
provider_specs={x: remote_spec(x) for x in providers},
),
DistributionSpec(