chore(package): migrate to src/ layout (#3920)

Migrates package structure to src/ layout following Python packaging
best practices.

All code moved from `llama_stack/` to `src/llama_stack/`. Public API
unchanged - imports remain `import llama_stack.*`.

Updated build configs, pre-commit hooks, scripts, and GitHub workflows
accordingly. All hooks pass, package builds cleanly.

**Developer note**: Reinstall after pulling: `pip install -e .`
This commit is contained in:
Ashwin Bharambe 2025-10-27 12:02:21 -07:00 committed by GitHub
parent 98a5047f9d
commit 471b1b248b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
791 changed files with 2983 additions and 456 deletions

View file

@ -9,8 +9,8 @@ on:
branches: [ main ]
paths:
- 'distributions/**'
- 'llama_stack/**'
- '!llama_stack/ui/**'
- 'src/llama_stack/**'
- '!src/llama_stack/ui/**'
- 'tests/integration/**'
- 'uv.lock'
- 'pyproject.toml'

View file

@ -8,7 +8,7 @@ on:
pull_request:
branches: [ main ]
paths:
- 'llama_stack/providers/utils/sqlstore/**'
- 'src/llama_stack/providers/utils/sqlstore/**'
- 'tests/integration/sqlstore/**'
- 'uv.lock'
- 'pyproject.toml'

View file

@ -9,8 +9,8 @@ on:
branches: [ main ]
types: [opened, synchronize, reopened]
paths:
- 'llama_stack/**'
- '!llama_stack/ui/**'
- 'src/llama_stack/**'
- '!src/llama_stack/ui/**'
- 'tests/**'
- 'uv.lock'
- 'pyproject.toml'

View file

@ -8,8 +8,8 @@ on:
pull_request:
branches: [ main ]
paths:
- 'llama_stack/**'
- '!llama_stack/ui/**'
- 'src/llama_stack/**'
- '!src/llama_stack/ui/**'
- 'tests/integration/vector_io/**'
- 'uv.lock'
- 'pyproject.toml'

View file

@ -41,11 +41,11 @@ jobs:
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'llama_stack/ui/'
cache-dependency-path: 'src/llama_stack/ui/'
- name: Install npm dependencies
run: npm ci
working-directory: llama_stack/ui
working-directory: src/llama_stack/ui
- name: Run pre-commit
id: precommit

View file

@ -145,12 +145,12 @@ jobs:
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'llama_stack/ui/'
cache-dependency-path: 'src/llama_stack/ui/'
- name: Install npm dependencies
if: steps.check_author.outputs.authorized == 'true'
run: npm ci
working-directory: llama_stack/ui
working-directory: src/llama_stack/ui
- name: Run pre-commit
if: steps.check_author.outputs.authorized == 'true'

View file

@ -7,24 +7,24 @@ on:
branches:
- main
paths:
- 'llama_stack/cli/stack/build.py'
- 'llama_stack/cli/stack/_build.py'
- 'llama_stack/core/build.*'
- 'llama_stack/core/*.sh'
- 'src/llama_stack/cli/stack/build.py'
- 'src/llama_stack/cli/stack/_build.py'
- 'src/llama_stack/core/build.*'
- 'src/llama_stack/core/*.sh'
- '.github/workflows/providers-build.yml'
- 'llama_stack/distributions/**'
- 'src/llama_stack/distributions/**'
- 'pyproject.toml'
- 'containers/Containerfile'
- '.dockerignore'
pull_request:
paths:
- 'llama_stack/cli/stack/build.py'
- 'llama_stack/cli/stack/_build.py'
- 'llama_stack/core/build.*'
- 'llama_stack/core/*.sh'
- 'src/llama_stack/cli/stack/build.py'
- 'src/llama_stack/cli/stack/_build.py'
- 'src/llama_stack/core/build.*'
- 'src/llama_stack/core/*.sh'
- '.github/workflows/providers-build.yml'
- 'llama_stack/distributions/**'
- 'src/llama_stack/distributions/**'
- 'pyproject.toml'
- 'containers/Containerfile'
- '.dockerignore'
@ -45,7 +45,7 @@ jobs:
- name: Generate Distribution List
id: set-matrix
run: |
distros=$(ls llama_stack/distributions/*/*build.yaml | awk -F'/' '{print $(NF-1)}' | jq -R -s -c 'split("\n")[:-1]')
distros=$(ls src/llama_stack/distributions/*/*build.yaml | awk -F'/' '{print $(NF-1)}' | jq -R -s -c 'split("\n")[:-1]')
echo "distros=$distros" >> "$GITHUB_OUTPUT"
build:
@ -107,13 +107,13 @@ jobs:
- name: Build container image
run: |
BASE_IMAGE=$(yq -r '.distribution_spec.container_image // "python:3.12-slim"' llama_stack/distributions/ci-tests/build.yaml)
BASE_IMAGE=$(yq -r '.distribution_spec.container_image // "python:3.12-slim"' src/llama_stack/distributions/ci-tests/build.yaml)
docker build . \
-f containers/Containerfile \
--build-arg INSTALL_MODE=editable \
--build-arg DISTRO_NAME=ci-tests \
--build-arg BASE_IMAGE="$BASE_IMAGE" \
--build-arg RUN_CONFIG_PATH=/workspace/llama_stack/distributions/ci-tests/run.yaml \
--build-arg RUN_CONFIG_PATH=/workspace/src/llama_stack/distributions/ci-tests/run.yaml \
-t llama-stack:ci-tests
- name: Inspect the container image entrypoint
@ -143,17 +143,17 @@ jobs:
run: |
yq -i '
.distribution_spec.container_image = "registry.access.redhat.com/ubi9:latest"
' llama_stack/distributions/ci-tests/build.yaml
' src/llama_stack/distributions/ci-tests/build.yaml
- name: Build UBI9 container image
run: |
BASE_IMAGE=$(yq -r '.distribution_spec.container_image // "registry.access.redhat.com/ubi9:latest"' llama_stack/distributions/ci-tests/build.yaml)
BASE_IMAGE=$(yq -r '.distribution_spec.container_image // "registry.access.redhat.com/ubi9:latest"' src/llama_stack/distributions/ci-tests/build.yaml)
docker build . \
-f containers/Containerfile \
--build-arg INSTALL_MODE=editable \
--build-arg DISTRO_NAME=ci-tests \
--build-arg BASE_IMAGE="$BASE_IMAGE" \
--build-arg RUN_CONFIG_PATH=/workspace/llama_stack/distributions/ci-tests/run.yaml \
--build-arg RUN_CONFIG_PATH=/workspace/src/llama_stack/distributions/ci-tests/run.yaml \
-t llama-stack:ci-tests-ubi9
- name: Inspect UBI9 image

View file

@ -7,22 +7,22 @@ on:
branches:
- main
paths:
- 'llama_stack/cli/stack/list_deps.py'
- 'llama_stack/cli/stack/_list_deps.py'
- 'llama_stack/core/build.*'
- 'llama_stack/core/*.sh'
- 'src/llama_stack/cli/stack/list_deps.py'
- 'src/llama_stack/cli/stack/_list_deps.py'
- 'src/llama_stack/core/build.*'
- 'src/llama_stack/core/*.sh'
- '.github/workflows/providers-list-deps.yml'
- 'llama_stack/templates/**'
- 'src/llama_stack/templates/**'
- 'pyproject.toml'
pull_request:
paths:
- 'llama_stack/cli/stack/list_deps.py'
- 'llama_stack/cli/stack/_list_deps.py'
- 'llama_stack/core/build.*'
- 'llama_stack/core/*.sh'
- 'src/llama_stack/cli/stack/list_deps.py'
- 'src/llama_stack/cli/stack/_list_deps.py'
- 'src/llama_stack/core/build.*'
- 'src/llama_stack/core/*.sh'
- '.github/workflows/providers-list-deps.yml'
- 'llama_stack/templates/**'
- 'src/llama_stack/templates/**'
- 'pyproject.toml'
concurrency:
@ -41,7 +41,7 @@ jobs:
- name: Generate Distribution List
id: set-matrix
run: |
distros=$(ls llama_stack/distributions/*/*build.yaml | awk -F'/' '{print $(NF-1)}' | jq -R -s -c 'split("\n")[:-1]')
distros=$(ls src/llama_stack/distributions/*/*build.yaml | awk -F'/' '{print $(NF-1)}' | jq -R -s -c 'split("\n")[:-1]')
echo "distros=$distros" >> "$GITHUB_OUTPUT"
list-deps:
@ -102,4 +102,4 @@ jobs:
USE_COPY_NOT_MOUNT: "true"
LLAMA_STACK_DIR: "."
run: |
uv run llama stack list-deps llama_stack/distributions/ci-tests/build.yaml
uv run llama stack list-deps src/llama_stack/distributions/ci-tests/build.yaml

View file

@ -10,7 +10,7 @@ on:
branches:
- main
paths-ignore:
- 'llama_stack/ui/**'
- 'src/llama_stack/ui/**'
jobs:
build:

View file

@ -8,7 +8,7 @@ on:
pull_request:
branches: [ main ]
paths:
- 'llama_stack/**'
- 'src/llama_stack/**'
- 'tests/integration/**'
- 'uv.lock'
- 'pyproject.toml'

View file

@ -8,8 +8,8 @@ on:
pull_request:
branches: [ main ]
paths:
- 'llama_stack/**'
- '!llama_stack/ui/**'
- 'src/llama_stack/**'
- '!src/llama_stack/ui/**'
- 'tests/integration/**'
- 'uv.lock'
- 'pyproject.toml'

View file

@ -8,7 +8,7 @@ on:
pull_request:
branches: [ main ]
paths:
- 'llama_stack/ui/**'
- 'src/llama_stack/ui/**'
- '.github/workflows/ui-unit-tests.yml' # This workflow
workflow_dispatch:
@ -33,22 +33,22 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'llama_stack/ui/package-lock.json'
cache-dependency-path: 'src/llama_stack/ui/package-lock.json'
- name: Install dependencies
working-directory: llama_stack/ui
working-directory: src/llama_stack/ui
run: npm ci
- name: Run linting
working-directory: llama_stack/ui
working-directory: src/llama_stack/ui
run: npm run lint
- name: Run format check
working-directory: llama_stack/ui
working-directory: src/llama_stack/ui
run: npm run format:check
- name: Run unit tests
working-directory: llama_stack/ui
working-directory: src/llama_stack/ui
env:
CI: true

View file

@ -8,8 +8,8 @@ on:
pull_request:
branches: [ main ]
paths:
- 'llama_stack/**'
- '!llama_stack/ui/**'
- 'src/llama_stack/**'
- '!src/llama_stack/ui/**'
- 'tests/unit/**'
- 'uv.lock'
- 'pyproject.toml'