Skip to content

Commit 2ade31d

Browse files
committed
feat: remove usage of build yaml for list-deps
the build.yaml is only used in the following ways: 1. list-deps 2. distribution code-gen since `llama stack build` no longer exists, I found myself asking "why do we need two different files for list-deps and run"? Removing the BuildConfig and DistributionTemplate from llama stack list-deps is the first step in removing the build yaml entirely. Removing the BuildConfig and build.yaml cuts the files users need to maintain in half, and allows us to focus on the stability of _just_ the run.yaml The build.yaml made sense for when we were managing the build process for the user and actually _producing_ a run.yaml _from_ the build.yaml, but now that we are simply just getting the provider registry and listing the deps, switching to run.yaml simplifies the scope here greatly Signed-off-by: Charlie Doern <[email protected]>
1 parent 91f1b35 commit 2ade31d

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

src/llama_stack/cli/stack/_list_deps.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@
1111
import yaml
1212
from termcolor import cprint
1313

14-
from llama_stack.cli.stack.utils import ImageType
1514
from llama_stack.core.build import get_provider_dependencies
16-
from llama_stack.core.datatypes import (
17-
BuildConfig,
18-
BuildProvider,
19-
DistributionSpec,
20-
)
15+
from llama_stack.core.datatypes import Provider, StackRunConfig
2116
from llama_stack.core.distribution import get_provider_registry
2217
from llama_stack.core.stack import replace_env_vars
2318
from llama_stack.log import get_logger
@@ -72,7 +67,7 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
7267
try:
7368
from llama_stack.core.utils.config_resolution import Mode, resolve_config_or_distro
7469

75-
config_file = resolve_config_or_distro(args.config, Mode.BUILD)
70+
config_file = resolve_config_or_distro(args.config, Mode.RUN)
7671
except ValueError as e:
7772
cprint(
7873
f"Could not parse config file {args.config}: {e}",
@@ -85,8 +80,7 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
8580
try:
8681
contents = yaml.safe_load(f)
8782
contents = replace_env_vars(contents)
88-
build_config = BuildConfig(**contents)
89-
build_config.image_type = "venv"
83+
run_config = StackRunConfig(**contents)
9084
except Exception as e:
9185
cprint(
9286
f"Could not parse config file {config_file}: {e}",
@@ -95,7 +89,7 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
9589
)
9690
sys.exit(1)
9791
elif args.providers:
98-
provider_list: dict[str, list[BuildProvider]] = dict()
92+
provider_list: dict[str, list[Provider]] = dict()
9993
for api_provider in args.providers.split(","):
10094
if "=" not in api_provider:
10195
cprint(
@@ -114,8 +108,9 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
114108
)
115109
sys.exit(1)
116110
if provider_type in providers_for_api:
117-
provider = BuildProvider(
111+
provider = Provider(
118112
provider_type=provider_type,
113+
provider_id=provider_type.split("::")[1],
119114
module=None,
120115
)
121116
provider_list.setdefault(api, []).append(provider)
@@ -126,20 +121,16 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
126121
file=sys.stderr,
127122
)
128123
sys.exit(1)
129-
distribution_spec = DistributionSpec(
130-
providers=provider_list,
131-
description=",".join(args.providers),
132-
)
133-
build_config = BuildConfig(image_type=ImageType.VENV.value, distribution_spec=distribution_spec)
124+
run_config = StackRunConfig(providers=provider_list, image_name="providers-run")
134125

135-
normal_deps, special_deps, external_provider_dependencies = get_provider_dependencies(build_config)
126+
normal_deps, special_deps, external_provider_dependencies = get_provider_dependencies(run_config)
136127
normal_deps += SERVER_DEPENDENCIES
137128

138129
# Add external API dependencies
139-
if build_config.external_apis_dir:
130+
if run_config.external_apis_dir:
140131
from llama_stack.core.external import load_external_apis
141132

142-
external_apis = load_external_apis(build_config)
133+
external_apis = load_external_apis(run_config)
143134
if external_apis:
144135
for _, api_spec in external_apis.items():
145136
normal_deps.extend(api_spec.pip_packages)

src/llama_stack/core/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pydantic import BaseModel
1010
from termcolor import cprint
1111

12-
from llama_stack.core.datatypes import BuildConfig
12+
from llama_stack.core.datatypes import BuildConfig, StackRunConfig
1313
from llama_stack.core.distribution import get_provider_registry
1414
from llama_stack.distributions.template import DistributionTemplate
1515
from llama_stack.log import get_logger
@@ -36,13 +36,13 @@ class ApiInput(BaseModel):
3636

3737

3838
def get_provider_dependencies(
39-
config: BuildConfig | DistributionTemplate,
39+
config: StackRunConfig,
4040
) -> tuple[list[str], list[str], list[str]]:
4141
"""Get normal and special dependencies from provider configuration."""
4242
if isinstance(config, DistributionTemplate):
4343
config = config.build_config()
4444

45-
providers = config.distribution_spec.providers
45+
providers = config.providers
4646
additional_pip_packages = config.additional_pip_packages
4747

4848
deps = []

src/llama_stack/core/datatypes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,11 @@ class StackRunConfig(BaseModel):
534534
description="Configuration for the HTTP(S) server",
535535
)
536536

537+
additional_pip_packages: list[str] = Field(
538+
default_factory=list,
539+
description="Additional pip packages to install in the distribution. These packages will be installed in the distribution environment.",
540+
)
541+
537542
external_providers_dir: Path | None = Field(
538543
default=None,
539544
description="Path to directory containing external provider implementations. The providers code and dependencies must be installed on the system.",

0 commit comments

Comments
 (0)