mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-31 21:24:33 +00:00
More generic image type for OCI-compliant container technologies
Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
This commit is contained in:
parent
9f14382d82
commit
2deac4879f
28 changed files with 55 additions and 55 deletions
|
|
@ -38,7 +38,7 @@ SERVER_DEPENDENCIES = [
|
|||
|
||||
|
||||
class ImageType(Enum):
|
||||
docker = "docker"
|
||||
container = "container"
|
||||
conda = "conda"
|
||||
venv = "venv"
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ def get_provider_dependencies(
|
|||
|
||||
provider_spec = providers_for_api[provider_type]
|
||||
deps.extend(provider_spec.pip_packages)
|
||||
if provider_spec.docker_image:
|
||||
if provider_spec.container_image:
|
||||
raise ValueError("A stack's dependencies cannot have a docker image")
|
||||
|
||||
normal_deps = []
|
||||
|
|
@ -109,23 +109,23 @@ def build_image(
|
|||
image_name: str,
|
||||
template_name: Optional[str] = None,
|
||||
):
|
||||
docker_image = build_config.distribution_spec.docker_image or "python:3.10-slim"
|
||||
container_image = build_config.distribution_spec.container_image or "python:3.10-slim"
|
||||
|
||||
normal_deps, special_deps = get_provider_dependencies(
|
||||
build_config.distribution_spec.providers
|
||||
)
|
||||
normal_deps += SERVER_DEPENDENCIES
|
||||
|
||||
if build_config.image_type == ImageType.docker.value:
|
||||
if build_config.image_type == ImageType.container.value:
|
||||
script = str(
|
||||
importlib.resources.files("llama_stack") / "distribution/build_container.sh"
|
||||
)
|
||||
args = [
|
||||
script,
|
||||
image_name,
|
||||
docker_image,
|
||||
container_image,
|
||||
str(build_file_path),
|
||||
str(BUILDS_BASE_DIR / ImageType.docker.value),
|
||||
str(BUILDS_BASE_DIR / ImageType.container.value),
|
||||
" ".join(normal_deps),
|
||||
]
|
||||
elif build_config.image_type == ImageType.conda.value:
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if [ $# -lt 2 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
docker_image="$1"
|
||||
container_image="$1"
|
||||
host_build_dir="$2"
|
||||
container_build_dir="/app/builds"
|
||||
|
||||
|
|
@ -43,5 +43,5 @@ $DOCKER_BINARY run $DOCKER_OPTS -it \
|
|||
--entrypoint "/usr/local/bin/llama" \
|
||||
-v $host_build_dir:$container_build_dir \
|
||||
$mounts \
|
||||
$docker_image \
|
||||
$container_image \
|
||||
stack configure ./llamastack-build.yaml --output-dir $container_build_dir
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class AutoRoutedProviderSpec(ProviderSpec):
|
|||
provider_type: str = "router"
|
||||
config_class: str = ""
|
||||
|
||||
docker_image: Optional[str] = None
|
||||
container_image: Optional[str] = None
|
||||
routing_table_api: Api
|
||||
module: str
|
||||
provider_data_validator: Optional[str] = Field(
|
||||
|
|
@ -89,7 +89,7 @@ class AutoRoutedProviderSpec(ProviderSpec):
|
|||
class RoutingTableProviderSpec(ProviderSpec):
|
||||
provider_type: str = "routing_table"
|
||||
config_class: str = ""
|
||||
docker_image: Optional[str] = None
|
||||
container_image: Optional[str] = None
|
||||
|
||||
router_api: Api
|
||||
module: str
|
||||
|
|
@ -101,7 +101,7 @@ class DistributionSpec(BaseModel):
|
|||
default="",
|
||||
description="Description of the distribution",
|
||||
)
|
||||
docker_image: Optional[str] = None
|
||||
container_image: Optional[str] = None
|
||||
providers: Dict[str, Union[str, List[str]]] = Field(
|
||||
default_factory=dict,
|
||||
description="""
|
||||
|
|
@ -127,9 +127,9 @@ Reference to the distribution this package refers to. For unregistered (adhoc) p
|
|||
this could be just a hash
|
||||
""",
|
||||
)
|
||||
docker_image: Optional[str] = Field(
|
||||
container_image: Optional[str] = Field(
|
||||
default=None,
|
||||
description="Reference to the docker image if this package refers to a container",
|
||||
description="Reference to the container image if this package refers to a container",
|
||||
)
|
||||
apis: List[str] = Field(
|
||||
default_factory=list,
|
||||
|
|
@ -168,5 +168,5 @@ class BuildConfig(BaseModel):
|
|||
)
|
||||
image_type: str = Field(
|
||||
default="conda",
|
||||
description="Type of package to build (conda | docker | venv)",
|
||||
description="Type of package to build (conda | container | venv)",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ if [ $# -lt 3 ]; then
|
|||
fi
|
||||
|
||||
build_name="$1"
|
||||
docker_image="localhost/distribution-$build_name"
|
||||
container_image="localhost/distribution-$build_name"
|
||||
shift
|
||||
|
||||
yaml_config="$1"
|
||||
|
|
@ -92,4 +92,4 @@ $DOCKER_BINARY run $DOCKER_OPTS -it \
|
|||
$mounts \
|
||||
--env LLAMA_STACK_PORT=$port \
|
||||
--entrypoint='["python", "-m", "llama_stack.distribution.server.server", "--yaml-config", "/app/config.yaml"]' \
|
||||
$docker_image:$version_tag
|
||||
$container_image:$version_tag
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue