Skip to content

Commit ed55bcc

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 ed55bcc

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-27
lines changed

.github/workflows/providers-list-deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ jobs:
102102
USE_COPY_NOT_MOUNT: "true"
103103
LLAMA_STACK_DIR: "."
104104
run: |
105-
uv run llama stack list-deps src/llama_stack/distributions/ci-tests/build.yaml
105+
uv run llama stack list-deps src/llama_stack/distributions/ci-tests/run.yaml

.github/workflows/test-external.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ jobs:
4444
4545
- name: Print distro dependencies
4646
run: |
47-
uv run --no-sync llama stack list-deps tests/external/build.yaml
47+
uv run --no-sync llama stack list-deps tests/external/run-byoa.yaml
4848
4949
- name: Build distro from config file
5050
run: |
5151
uv venv ci-test
5252
source ci-test/bin/activate
5353
uv pip install -e .
54-
LLAMA_STACK_LOGGING=all=CRITICAL llama stack list-deps tests/external/build.yaml | xargs -L1 uv pip install
54+
LLAMA_STACK_LOGGING=all=CRITICAL llama stack list-deps tests/external/run-byoa.yaml | xargs -L1 uv pip install
5555
5656
- name: Start Llama Stack server in background
5757
if: ${{ matrix.image-type }} == 'venv'

src/llama_stack/cli/stack/_list_deps.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@
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
22-
from llama_stack.core.stack import replace_env_vars
2317
from llama_stack.log import get_logger
2418
from llama_stack_api import Api
2519

@@ -72,7 +66,7 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
7266
try:
7367
from llama_stack.core.utils.config_resolution import Mode, resolve_config_or_distro
7468

75-
config_file = resolve_config_or_distro(args.config, Mode.BUILD)
69+
config_file = resolve_config_or_distro(args.config, Mode.RUN)
7670
except ValueError as e:
7771
cprint(
7872
f"Could not parse config file {args.config}: {e}",
@@ -84,9 +78,7 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
8478
with open(config_file) as f:
8579
try:
8680
contents = yaml.safe_load(f)
87-
contents = replace_env_vars(contents)
88-
build_config = BuildConfig(**contents)
89-
build_config.image_type = "venv"
81+
run_config = StackRunConfig(**contents)
9082
except Exception as e:
9183
cprint(
9284
f"Could not parse config file {config_file}: {e}",
@@ -95,7 +87,7 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
9587
)
9688
sys.exit(1)
9789
elif args.providers:
98-
provider_list: dict[str, list[BuildProvider]] = dict()
90+
provider_list: dict[str, list[Provider]] = dict()
9991
for api_provider in args.providers.split(","):
10092
if "=" not in api_provider:
10193
cprint(
@@ -114,8 +106,9 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
114106
)
115107
sys.exit(1)
116108
if provider_type in providers_for_api:
117-
provider = BuildProvider(
109+
provider = Provider(
118110
provider_type=provider_type,
111+
provider_id=provider_type.split("::")[1],
119112
module=None,
120113
)
121114
provider_list.setdefault(api, []).append(provider)
@@ -126,20 +119,16 @@ def run_stack_list_deps_command(args: argparse.Namespace) -> None:
126119
file=sys.stderr,
127120
)
128121
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)
122+
run_config = StackRunConfig(providers=provider_list, image_name="providers-run")
134123

135-
normal_deps, special_deps, external_provider_dependencies = get_provider_dependencies(build_config)
124+
normal_deps, special_deps, external_provider_dependencies = get_provider_dependencies(run_config)
136125
normal_deps += SERVER_DEPENDENCIES
137126

138127
# Add external API dependencies
139-
if build_config.external_apis_dir:
128+
if run_config.external_apis_dir:
140129
from llama_stack.core.external import load_external_apis
141130

142-
external_apis = load_external_apis(build_config)
131+
external_apis = load_external_apis(run_config)
143132
if external_apis:
144133
for _, api_spec in external_apis.items():
145134
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ class StackRunConfig(BaseModel):
517517
""",
518518
)
519519
storage: StorageConfig = Field(
520+
default_factory=StorageConfig,
520521
description="Catalog of named storage backends and references available to the stack",
521522
)
522523

@@ -534,6 +535,11 @@ class StackRunConfig(BaseModel):
534535
description="Configuration for the HTTP(S) server",
535536
)
536537

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

0 commit comments

Comments
 (0)