diff --git a/llama_stack/cli/stack/_build.py b/llama_stack/cli/stack/_build.py index 8909486b3..f7262e9a6 100644 --- a/llama_stack/cli/stack/_build.py +++ b/llama_stack/cli/stack/_build.py @@ -241,6 +241,7 @@ def run_stack_build_command(args: argparse.Namespace) -> None: image_name=image_name, config_path=args.config, template_name=args.template, + exit_after_containerfile=args.exit_after_containerfile, ) except (Exception, RuntimeError) as exc: @@ -354,6 +355,7 @@ def _run_stack_build_command_from_build_config( image_name: str | None = None, template_name: str | None = None, config_path: str | None = None, + exit_after_containerfile: bool = False, ) -> Path | Traversable: image_name = image_name or build_config.image_name if build_config.image_type == LlamaStackImageType.CONTAINER.value: @@ -396,6 +398,7 @@ def _run_stack_build_command_from_build_config( image_name, template_or_config=template_name or config_path or str(build_file_path), run_config=run_config_file, + exit_after_containerfile=exit_after_containerfile, ) if return_code != 0: raise RuntimeError(f"Failed to build image {image_name}") diff --git a/llama_stack/cli/stack/build.py b/llama_stack/cli/stack/build.py index 2c402beeb..f96d2376b 100644 --- a/llama_stack/cli/stack/build.py +++ b/llama_stack/cli/stack/build.py @@ -82,6 +82,13 @@ the build. If not specified, currently active environment will be used if found. help="Build a config for a list of providers and only those providers. This list is formatted like: api1=provider1,api2=provider2. Where there can be multiple providers per API.", ) + self.parser.add_argument( + "--exit-after-containerfile", + action="store_true", + default=False, + help="For container builds, exit after creating the Containerfile without building the image", + ) + def _run_stack_build_command(self, args: argparse.Namespace) -> None: # always keep implementation completely silo-ed away from CLI so CLI # can be fast to load and reduces dependencies diff --git a/llama_stack/distribution/build.py b/llama_stack/distribution/build.py index 072f9c425..01c4b4f53 100644 --- a/llama_stack/distribution/build.py +++ b/llama_stack/distribution/build.py @@ -110,6 +110,7 @@ def build_image( image_name: str, template_or_config: str, run_config: str | None = None, + exit_after_containerfile: bool = False, ): container_base = build_config.distribution_spec.container_image or "python:3.10-slim" @@ -130,6 +131,10 @@ def build_image( # build arguments if run_config is not None: args.append(run_config) + + # Add exit_after_containerfile flag if specified + if exit_after_containerfile: + args.append("--exit-after-containerfile") elif build_config.image_type == LlamaStackImageType.CONDA.value: script = str(importlib.resources.files("llama_stack") / "distribution/build_conda_env.sh") args = [ diff --git a/llama_stack/distribution/build_container.sh b/llama_stack/distribution/build_container.sh index c128729e1..ec52448fb 100755 --- a/llama_stack/distribution/build_container.sh +++ b/llama_stack/distribution/build_container.sh @@ -43,6 +43,7 @@ shift # Handle optional arguments run_config="" special_pip_deps="" +exit_after_containerfile=false # Check if there are more arguments # The logics is becoming cumbersom, we should refactor it if we can do better @@ -53,11 +54,19 @@ if [ $# -gt 0 ]; then shift # If there's another argument after .yaml, it must be special_pip_deps if [ $# -gt 0 ]; then - special_pip_deps="$1" + if [[ "$1" == "--exit-after-containerfile" ]]; then + exit_after_containerfile=true + else + special_pip_deps="$1" + fi fi else - # If it's not .yaml, it must be special_pip_deps - special_pip_deps="$1" + # If it's not .yaml, check if it's the exit flag + if [[ "$1" == "--exit-after-containerfile" ]]; then + exit_after_containerfile=true + else + special_pip_deps="$1" + fi fi fi @@ -270,6 +279,15 @@ printf "Containerfile created successfully in %s/Containerfile\n\n" "$TEMP_DIR" cat "$TEMP_DIR"/Containerfile printf "\n" +# Exit after creating Containerfile if requested +if [ "$exit_after_containerfile" = true ]; then + # Copy Containerfile to current directory + cp "$TEMP_DIR/Containerfile" "$BUILD_CONTEXT_DIR/Containerfile" + echo "Containerfile has been copied to $(pwd)/Containerfile" + echo "Exiting after Containerfile creation as requested" + exit 0 +fi + # Start building the CLI arguments CLI_ARGS=() diff --git a/llama_stack/providers/utils/kvstore/config.py b/llama_stack/providers/utils/kvstore/config.py index e9aac6e8c..0a6fae58b 100644 --- a/llama_stack/providers/utils/kvstore/config.py +++ b/llama_stack/providers/utils/kvstore/config.py @@ -47,7 +47,7 @@ class RedisKVStoreConfig(CommonConfig): class SqliteKVStoreConfig(CommonConfig): - type: Literal[KVStoreType.sqlite.value] = KVStoreType.sqlite.value + type: Literal[KVStoreType.sqlite] = KVStoreType.sqlite.value db_path: str = Field( default=(RUNTIME_BASE_DIR / "kvstore.db").as_posix(), description="File path for the sqlite database", @@ -63,7 +63,7 @@ class SqliteKVStoreConfig(CommonConfig): class PostgresKVStoreConfig(CommonConfig): - type: Literal[KVStoreType.postgres.value] = KVStoreType.postgres.value + type: Literal[KVStoreType.postgres] = KVStoreType.postgres.value host: str = "localhost" port: int = 5432 db: str = "llamastack" @@ -102,7 +102,7 @@ class PostgresKVStoreConfig(CommonConfig): class MongoDBKVStoreConfig(CommonConfig): - type: Literal[KVStoreType.mongodb.value] = KVStoreType.mongodb.value + type: Literal[KVStoreType.mongodb] = KVStoreType.mongodb.value host: str = "localhost" port: int = 27017 db: str = "llamastack" @@ -125,6 +125,6 @@ class MongoDBKVStoreConfig(CommonConfig): KVStoreConfig = Annotated[ - RedisKVStoreConfig | SqliteKVStoreConfig | PostgresKVStoreConfig | MongoDBKVStoreConfig, - Field(discriminator="type", default=KVStoreType.sqlite.value), + PostgresKVStoreConfig, + Field(discriminator="type", default=KVStoreType.postgres.value), ] diff --git a/llama_stack/providers/utils/kvstore/kvstore.py b/llama_stack/providers/utils/kvstore/kvstore.py index 3a1ee8a26..680ee153d 100644 --- a/llama_stack/providers/utils/kvstore/kvstore.py +++ b/llama_stack/providers/utils/kvstore/kvstore.py @@ -10,7 +10,7 @@ from .config import KVStoreConfig, KVStoreType def kvstore_dependencies(): - return ["aiosqlite", "psycopg2-binary", "redis", "pymongo"] + return ["aiosqlite", "psycopg2-binary"] class InmemoryKVStoreImpl(KVStore): diff --git a/llama_stack/templates/ollama/ollama.py b/llama_stack/templates/ollama/ollama.py index 0b4f05128..18799776d 100644 --- a/llama_stack/templates/ollama/ollama.py +++ b/llama_stack/templates/ollama/ollama.py @@ -22,14 +22,13 @@ from llama_stack.templates.template import DistributionTemplate, RunConfigSettin def get_distribution_template() -> DistributionTemplate: providers = { "inference": ["remote::ollama"], - "vector_io": ["inline::faiss", "remote::chromadb", "remote::pgvector"], + "vector_io": ["remote::chromadb"], "safety": ["inline::llama-guard"], "agents": ["inline::meta-reference"], "telemetry": ["inline::meta-reference"], "eval": ["inline::meta-reference"], - "datasetio": ["remote::huggingface", "inline::localfs"], - "scoring": ["inline::basic", "inline::llm-as-judge", "inline::braintrust"], - "post_training": ["inline::huggingface"], + "datasetio": ["inline::localfs"], + "scoring": ["inline::basic", "inline::llm-as-judge"], "tool_runtime": [ "remote::brave-search", "remote::tavily-search", @@ -49,11 +48,6 @@ def get_distribution_template() -> DistributionTemplate: provider_type="inline::faiss", config=FaissVectorIOConfig.sample_run_config(f"~/.llama/distributions/{name}"), ) - posttraining_provider = Provider( - provider_id="huggingface", - provider_type="inline::huggingface", - config=HuggingFacePostTrainingConfig.sample_run_config(f"~/.llama/distributions/{name}"), - ) inference_model = ModelInput( model_id="${env.INFERENCE_MODEL}", provider_id="ollama", @@ -98,7 +92,6 @@ def get_distribution_template() -> DistributionTemplate: provider_overrides={ "inference": [inference_provider], "vector_io": [vector_io_provider_faiss], - "post_training": [posttraining_provider], }, default_models=[inference_model, embedding_model], default_tool_groups=default_tool_groups, @@ -106,8 +99,7 @@ def get_distribution_template() -> DistributionTemplate: "run-with-safety.yaml": RunConfigSettings( provider_overrides={ "inference": [inference_provider], - "vector_io": [vector_io_provider_faiss], - "post_training": [posttraining_provider], + "vector_io": [vector_io_provider_faiss] "safety": [ Provider( provider_id="llama-guard", diff --git a/llama_stack/templates/ollama/run.yaml b/llama_stack/templates/ollama/run.yaml index d208cd7f0..6b665ca78 100644 --- a/llama_stack/templates/ollama/run.yaml +++ b/llama_stack/templates/ollama/run.yaml @@ -5,7 +5,6 @@ apis: - datasetio - eval - inference -- post_training - safety - scoring - telemetry @@ -82,13 +81,6 @@ providers: provider_type: inline::braintrust config: openai_api_key: ${env.OPENAI_API_KEY:} - post_training: - - provider_id: huggingface - provider_type: inline::huggingface - config: - checkpoint_format: huggingface - distributed_backend: null - device: cpu tool_runtime: - provider_id: brave-search provider_type: remote::brave-search