diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 072fa21e2..e83e64672 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -77,7 +77,7 @@ repos: name: Distribution Template Codegen additional_dependencies: - uv==0.6.0 - entry: uv run --extra codegen python -m llama_stack.scripts.distro_codegen + entry: uv run --extra codegen ./scripts/distro_codegen.py language: python pass_filenames: false require_serial: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1f188f259..e458fec0a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -159,7 +159,7 @@ LLAMA_STACK_DIR=$(pwd) LLAMA_STACK_CLIENT_DIR=../llama-stack-client-python llama ### Updating Provider Configurations -If you have made changes to a provider's configuration in any form (introducing a new config key, or changing models, etc.), you should run `python llama_stack/scripts/distro_codegen.py` to re-generate various YAML files as well as the documentation. You should not change `docs/source/.../distributions/` files manually as they are auto-generated. +If you have made changes to a provider's configuration in any form (introducing a new config key, or changing models, etc.), you should run `./scripts/distro_codegen.py` to re-generate various YAML files as well as the documentation. You should not change `docs/source/.../distributions/` files manually as they are auto-generated. ### Building the Documentation diff --git a/docs/source/contributing/new_api_provider.md b/docs/source/contributing/new_api_provider.md index a72f71319..c412a350b 100644 --- a/docs/source/contributing/new_api_provider.md +++ b/docs/source/contributing/new_api_provider.md @@ -6,7 +6,7 @@ This guide will walk you through the process of adding a new API provider to Lla - Begin by reviewing the [core concepts](../concepts/index.md) of Llama Stack and choose the API your provider belongs to (Inference, Safety, VectorIO, etc.) - Determine the provider type ({repopath}`Remote::llama_stack/providers/remote` or {repopath}`Inline::llama_stack/providers/inline`). Remote providers make requests to external services, while inline providers execute implementation locally. - Add your provider to the appropriate {repopath}`Registry::llama_stack/providers/registry/`. Specify pip dependencies necessary. -- Update any distribution {repopath}`Templates::llama_stack/templates/` build.yaml and run.yaml files if they should include your provider by default. Run {repopath}`llama_stack/scripts/distro_codegen.py` if necessary. Note that `distro_codegen.py` will fail if the new provider causes any distribution template to attempt to import provider-specific dependencies. This usually means the distribution's `get_distribution_template()` code path should only import any necessary Config or model alias definitions from each provider and not the provider's actual implementation. +- Update any distribution {repopath}`Templates::llama_stack/templates/` build.yaml and run.yaml files if they should include your provider by default. Run {repopath}`./scripts/distro_codegen.py` if necessary. Note that `distro_codegen.py` will fail if the new provider causes any distribution template to attempt to import provider-specific dependencies. This usually means the distribution's `get_distribution_template()` code path should only import any necessary Config or model alias definitions from each provider and not the provider's actual implementation. Here are some example PRs to help you get started: diff --git a/llama_stack/scripts/__init__.py b/llama_stack/scripts/__init__.py deleted file mode 100644 index 756f351d8..000000000 --- a/llama_stack/scripts/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the terms described in the LICENSE file in -# the root directory of this source tree. diff --git a/llama_stack/scripts/run_tests.sh b/llama_stack/scripts/run_tests.sh deleted file mode 100644 index 49229d1b1..000000000 --- a/llama_stack/scripts/run_tests.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the terms described in the LICENSE file in -# the root directory of this source tree. - -THIS_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" - -set -euo pipefail -set -x - -stack_dir=$(dirname $(dirname $THIS_DIR)) -PYTHONPATH=$stack_dir pytest -p no:warnings --asyncio-mode auto --tb=short diff --git a/llama_stack/scripts/distro_codegen.py b/scripts/distro_codegen.py old mode 100644 new mode 100755 similarity index 98% rename from llama_stack/scripts/distro_codegen.py rename to scripts/distro_codegen.py index 92c82983e..e19ba8cb9 --- a/llama_stack/scripts/distro_codegen.py +++ b/scripts/distro_codegen.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # @@ -20,7 +21,7 @@ from llama_stack.distribution.build import ( get_provider_dependencies, ) -REPO_ROOT = Path(__file__).parent.parent.parent +REPO_ROOT = Path(__file__).parent.parent class ChangedPathTracker: diff --git a/scripts/gen-changelog.py b/scripts/gen-changelog.py old mode 100644 new mode 100755 index 668146901..ac4053339 --- a/scripts/gen-changelog.py +++ b/scripts/gen-changelog.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # diff --git a/llama_stack/scripts/generate_prompt_format.py b/scripts/generate_prompt_format.py old mode 100644 new mode 100755 similarity index 98% rename from llama_stack/scripts/generate_prompt_format.py rename to scripts/generate_prompt_format.py index ec4c5e9be..72b057992 --- a/llama_stack/scripts/generate_prompt_format.py +++ b/scripts/generate_prompt_format.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # diff --git a/llama_stack/scripts/run_client_sdk_tests.py b/scripts/run_client_sdk_tests.py old mode 100644 new mode 100755 similarity index 91% rename from llama_stack/scripts/run_client_sdk_tests.py rename to scripts/run_client_sdk_tests.py index e70d187aa..b93316c4f --- a/llama_stack/scripts/run_client_sdk_tests.py +++ b/scripts/run_client_sdk_tests.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # @@ -15,8 +16,7 @@ Script for running api on AsyncLlamaStackAsLibraryClient with templates Assuming directory structure: - llama-stack - - llama_stack - - scripts + - scripts - tests - api @@ -25,10 +25,10 @@ Example command: cd llama-stack EXPORT TOGETHER_API_KEY=<..> EXPORT FIREWORKS_API_KEY=<..> -python llama_stack/scripts/run_client_sdk_tests.py --templates together fireworks --report +./scripts/run_client_sdk_tests.py --templates together fireworks --report """ -REPO_ROOT = Path(__file__).parent.parent.parent +REPO_ROOT = Path(__file__).parent.parent CLIENT_SDK_TESTS_RELATIVE_PATH = "tests/api/"