mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-01 16:24:44 +00:00
update docker build script
This commit is contained in:
parent
d1f0d17644
commit
4ed1f38134
3 changed files with 9 additions and 84 deletions
|
@ -41,7 +41,7 @@ class StackConfigure(Subcommand):
|
|||
self.parser.add_argument(
|
||||
"config",
|
||||
type=str,
|
||||
help="Path to the build config file (e.g. ~/.llama/builds/<distribution>/<image_type>/<name>-build.yaml)",
|
||||
help="Path to the build config file (e.g. ~/.llama/builds/<image_type>/<name>-build.yaml)",
|
||||
)
|
||||
|
||||
def _run_stack_configure_cmd(self, args: argparse.Namespace) -> None:
|
||||
|
|
|
@ -4,18 +4,17 @@ LLAMA_MODELS_DIR=${LLAMA_MODELS_DIR:-}
|
|||
LLAMA_TOOLCHAIN_DIR=${LLAMA_TOOLCHAIN_DIR:-}
|
||||
TEST_PYPI_VERSION=${TEST_PYPI_VERSION:-}
|
||||
|
||||
if [ "$#" -ne 5 ]; then
|
||||
echo "Usage: $0 <distribution_type> <build_name> <docker_base> <pip_dependencies>
|
||||
echo "Example: $0 distribution_type my-fastapi-app python:3.9-slim 'fastapi uvicorn'
|
||||
if [ "$#" -ne 3 ]; then
|
||||
echo "Usage: $0 <build_name> <docker_base> <pip_dependencies>
|
||||
echo "Example: $0 my-fastapi-app python:3.9-slim 'fastapi uvicorn'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
distribution_type=$1
|
||||
build_name="$2"
|
||||
# distribution_type=$1
|
||||
build_name="$1"
|
||||
image_name="llamastack-$build_name"
|
||||
docker_base=$3
|
||||
config_file=$4
|
||||
pip_dependencies=$5
|
||||
docker_base=$2
|
||||
pip_dependencies=$3
|
||||
|
||||
# Define color codes
|
||||
RED='\033[0;31m'
|
||||
|
|
|
@ -65,10 +65,8 @@ def build_package(build_config: BuildConfig):
|
|||
)
|
||||
args = [
|
||||
script,
|
||||
distribution_type,
|
||||
package_name,
|
||||
build_config.name,
|
||||
package_deps.docker_image,
|
||||
str(package_file),
|
||||
" ".join(package_deps.pip_packages),
|
||||
]
|
||||
else:
|
||||
|
@ -88,75 +86,3 @@ def build_package(build_config: BuildConfig):
|
|||
color="red",
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
def build_package_deprecated(
|
||||
api_inputs: List[ApiInput],
|
||||
image_type: ImageType,
|
||||
name: str,
|
||||
distribution_type: Optional[str] = None,
|
||||
docker_image: Optional[str] = None,
|
||||
):
|
||||
if not distribution_type:
|
||||
distribution_type = "adhoc"
|
||||
|
||||
build_dir = BUILDS_BASE_DIR / distribution_type / image_type.value
|
||||
os.makedirs(build_dir, exist_ok=True)
|
||||
|
||||
package_name = name.replace("::", "-")
|
||||
package_file = build_dir / f"{package_name}.yaml"
|
||||
|
||||
all_providers = api_providers()
|
||||
|
||||
package_deps = Dependencies(
|
||||
docker_image=docker_image or "python:3.10-slim",
|
||||
pip_packages=SERVER_DEPENDENCIES,
|
||||
)
|
||||
|
||||
stub_config = {}
|
||||
for api_input in api_inputs:
|
||||
api = api_input.api
|
||||
providers_for_api = all_providers[api]
|
||||
if api_input.provider not in providers_for_api:
|
||||
raise ValueError(
|
||||
f"Provider `{api_input.provider}` is not available for API `{api}`"
|
||||
)
|
||||
|
||||
provider = providers_for_api[api_input.provider]
|
||||
package_deps.pip_packages.extend(provider.pip_packages)
|
||||
if provider.docker_image:
|
||||
raise ValueError("A stack's dependencies cannot have a docker image")
|
||||
|
||||
stub_config[api.value] = {"provider_type": api_input.provider}
|
||||
|
||||
if image_type == ImageType.docker:
|
||||
script = pkg_resources.resource_filename(
|
||||
"llama_toolchain", "core/build_container.sh"
|
||||
)
|
||||
args = [
|
||||
script,
|
||||
distribution_type,
|
||||
package_name,
|
||||
package_deps.docker_image,
|
||||
str(package_file),
|
||||
" ".join(package_deps.pip_packages),
|
||||
]
|
||||
else:
|
||||
script = pkg_resources.resource_filename(
|
||||
"llama_toolchain", "core/build_conda_env.sh"
|
||||
)
|
||||
args = [
|
||||
script,
|
||||
distribution_type,
|
||||
package_name,
|
||||
str(package_file),
|
||||
" ".join(package_deps.pip_packages),
|
||||
]
|
||||
|
||||
return_code = run_with_pty(args)
|
||||
if return_code != 0:
|
||||
cprint(
|
||||
f"Failed to build target {package_name} with return code {return_code}",
|
||||
color="red",
|
||||
)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue