Skip to content

Commit 5d65c01

Browse files
authored
Merge branch 'meta-llama:main' into main
2 parents 11810c9 + 5639ad7 commit 5d65c01

File tree

757 files changed

+56276
-75755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

757 files changed

+56276
-75755
lines changed

.coveragerc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[run]
2+
omit =
3+
*/tests/*
4+
*/llama_stack/providers/*
5+
*/llama_stack/templates/*
6+
.venv/*

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# These owners will be the default owners for everything in
44
# the repo. Unless a later match takes precedence,
5-
* @ashwinb @yanxi0830 @hardikjshah @dltn @raghotham @dineshyv @vladimirivic @sixianyi0721 @ehhuang @terrytangyuan @SLR722 @leseb
5+
* @ashwinb @yanxi0830 @hardikjshah @raghotham @ehhuang @terrytangyuan @leseb @bbrowning @reluctantfuturist

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# What does this PR do?
2-
[Provide a short summary of what this PR does and why. Link to relevant issues if applicable.]
2+
<!-- Provide a short summary of what this PR does and why. Link to relevant issues if applicable. -->
33

4-
[//]: # (If resolving an issue, uncomment and update the line below)
5-
[//]: # (Closes #[issue-number])
4+
<!-- If resolving an issue, uncomment and update the line below -->
5+
<!-- Closes #[issue-number] -->
66

77
## Test Plan
8-
[Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.*]
9-
10-
[//]: # (## Documentation)
8+
<!-- Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.* -->

.github/TRIAGERS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This file documents Triage members in the Llama Stack community
2-
@franciscojavierarceo @leseb
2+
@bbrowning @booxter @franciscojavierarceo @leseb
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Setup Ollama
2+
description: Start Ollama
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Start Ollama
7+
shell: bash
8+
run: |
9+
docker run -d --name ollama -p 11434:11434 docker.io/leseb/ollama-with-models
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Setup runner
2+
description: Prepare a runner for the tests (install uv, python, project dependencies, etc.)
3+
inputs:
4+
python-version:
5+
description: The Python version to use
6+
required: false
7+
default: "3.10"
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Install uv
12+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
13+
with:
14+
python-version: ${{ inputs.python-version }}
15+
activate-environment: true
16+
version: 0.7.6
17+
18+
- name: Install dependencies
19+
shell: bash
20+
run: |
21+
uv sync --all-groups
22+
uv pip install ollama faiss-cpu
23+
# always test against the latest version of the client
24+
# TODO: this is not necessarily a good idea. we need to test against both published and latest
25+
# to find out backwards compatibility issues.
26+
uv pip install git+https://github.com/meta-llama/llama-stack-client-python.git@main
27+
uv pip install -e .
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Installer CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'install.sh'
7+
push:
8+
paths:
9+
- 'install.sh'
10+
schedule:
11+
- cron: '0 2 * * *' # every day at 02:00 UTC
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
18+
- name: Run ShellCheck on install.sh
19+
run: shellcheck install.sh
20+
smoke-test:
21+
needs: lint
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
25+
- name: Run installer end-to-end
26+
run: ./install.sh
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Integration Auth Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
paths:
9+
- 'distributions/**'
10+
- 'llama_stack/**'
11+
- 'tests/integration/**'
12+
- 'uv.lock'
13+
- 'pyproject.toml'
14+
- 'requirements.txt'
15+
- '.github/workflows/integration-auth-tests.yml' # This workflow
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
test-matrix:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
auth-provider: [oauth2_token]
27+
fail-fast: false # we want to run all tests regardless of failure
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32+
33+
- name: Install dependencies
34+
uses: ./.github/actions/setup-runner
35+
36+
- name: Build Llama Stack
37+
run: |
38+
llama stack build --template ollama --image-type venv
39+
40+
- name: Install minikube
41+
if: ${{ matrix.auth-provider == 'kubernetes' }}
42+
uses: medyagh/setup-minikube@cea33675329b799adccc9526aa5daccc26cd5052 # v0.0.19
43+
44+
- name: Start minikube
45+
if: ${{ matrix.auth-provider == 'oauth2_token' }}
46+
run: |
47+
minikube start
48+
kubectl get pods -A
49+
50+
- name: Configure Kube Auth
51+
if: ${{ matrix.auth-provider == 'oauth2_token' }}
52+
run: |
53+
kubectl create namespace llama-stack
54+
kubectl create serviceaccount llama-stack-auth -n llama-stack
55+
kubectl create rolebinding llama-stack-auth-rolebinding --clusterrole=admin --serviceaccount=llama-stack:llama-stack-auth -n llama-stack
56+
kubectl create token llama-stack-auth -n llama-stack > llama-stack-auth-token
57+
cat <<EOF | kubectl apply -f -
58+
apiVersion: rbac.authorization.k8s.io/v1
59+
kind: ClusterRole
60+
metadata:
61+
name: allow-anonymous-openid
62+
rules:
63+
- nonResourceURLs: ["/openid/v1/jwks"]
64+
verbs: ["get"]
65+
---
66+
apiVersion: rbac.authorization.k8s.io/v1
67+
kind: ClusterRoleBinding
68+
metadata:
69+
name: allow-anonymous-openid
70+
roleRef:
71+
apiGroup: rbac.authorization.k8s.io
72+
kind: ClusterRole
73+
name: allow-anonymous-openid
74+
subjects:
75+
- kind: User
76+
name: system:anonymous
77+
apiGroup: rbac.authorization.k8s.io
78+
EOF
79+
80+
- name: Set Kubernetes Config
81+
if: ${{ matrix.auth-provider == 'oauth2_token' }}
82+
run: |
83+
echo "KUBERNETES_API_SERVER_URL=$(kubectl get --raw /.well-known/openid-configuration| jq -r .jwks_uri)" >> $GITHUB_ENV
84+
echo "KUBERNETES_CA_CERT_PATH=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.certificate-authority}')" >> $GITHUB_ENV
85+
echo "KUBERNETES_ISSUER=$(kubectl get --raw /.well-known/openid-configuration| jq -r .issuer)" >> $GITHUB_ENV
86+
echo "KUBERNETES_AUDIENCE=$(kubectl create token llama-stack-auth -n llama-stack --duration=1h | cut -d. -f2 | base64 -d | jq -r '.aud[0]')" >> $GITHUB_ENV
87+
88+
- name: Set Kube Auth Config and run server
89+
env:
90+
INFERENCE_MODEL: "meta-llama/Llama-3.2-3B-Instruct"
91+
if: ${{ matrix.auth-provider == 'oauth2_token' }}
92+
run: |
93+
run_dir=$(mktemp -d)
94+
cat <<'EOF' > $run_dir/run.yaml
95+
version: '2'
96+
image_name: kube
97+
apis: []
98+
providers: {}
99+
server:
100+
port: 8321
101+
EOF
102+
yq eval '.server.auth = {"provider_type": "${{ matrix.auth-provider }}"}' -i $run_dir/run.yaml
103+
yq eval '.server.auth.config = {"tls_cafile": "${{ env.KUBERNETES_CA_CERT_PATH }}", "issuer": "${{ env.KUBERNETES_ISSUER }}", "audience": "${{ env.KUBERNETES_AUDIENCE }}"}' -i $run_dir/run.yaml
104+
yq eval '.server.auth.config.jwks = {"uri": "${{ env.KUBERNETES_API_SERVER_URL }}"}' -i $run_dir/run.yaml
105+
cat $run_dir/run.yaml
106+
107+
nohup uv run llama stack run $run_dir/run.yaml --image-type venv > server.log 2>&1 &
108+
109+
- name: Wait for Llama Stack server to be ready
110+
run: |
111+
echo "Waiting for Llama Stack server..."
112+
for i in {1..30}; do
113+
if curl -s -L -H "Authorization: Bearer $(cat llama-stack-auth-token)" http://localhost:8321/v1/health | grep -q "OK"; then
114+
echo "Llama Stack server is up!"
115+
if grep -q "Enabling authentication with provider: ${{ matrix.auth-provider }}" server.log; then
116+
echo "Llama Stack server is configured to use ${{ matrix.auth-provider }} auth"
117+
exit 0
118+
else
119+
echo "Llama Stack server is not configured to use ${{ matrix.auth-provider }} auth"
120+
cat server.log
121+
exit 1
122+
fi
123+
fi
124+
sleep 1
125+
done
126+
echo "Llama Stack server failed to start"
127+
cat server.log
128+
exit 1
129+
130+
- name: Test auth
131+
run: |
132+
curl -s -L -H "Authorization: Bearer $(cat llama-stack-auth-token)" http://127.0.0.1:8321/v1/providers|jq

.github/workflows/integration-tests.yml

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
pull_request:
77
branches: [ main ]
88
paths:
9-
- 'distributions/**'
109
- 'llama_stack/**'
1110
- 'tests/integration/**'
1211
- 'uv.lock'
@@ -25,47 +24,33 @@ jobs:
2524
matrix:
2625
# Listing tests manually since some of them currently fail
2726
# TODO: generate matrix list from tests/integration when fixed
28-
test-type: [agents, inference, datasets, inspect, scoring, post_training, providers]
27+
test-type: [agents, inference, datasets, inspect, scoring, post_training, providers, tool_runtime]
2928
client-type: [library, http]
29+
python-version: ["3.10", "3.11", "3.12"]
3030
fail-fast: false # we want to run all tests regardless of failure
3131

3232
steps:
3333
- name: Checkout repository
3434
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3535

36-
- name: Install uv
37-
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
36+
- name: Install dependencies
37+
uses: ./.github/actions/setup-runner
3838
with:
39-
python-version: "3.10"
39+
python-version: ${{ matrix.python-version }}
4040

41-
- name: Install and start Ollama
42-
run: |
43-
# the ollama installer also starts the ollama service
44-
curl -fsSL https://ollama.com/install.sh | sh
45-
46-
- name: Pull Ollama image
47-
run: |
48-
# TODO: cache the model. OLLAMA_MODELS defaults to ~ollama/.ollama/models.
49-
ollama pull llama3.2:3b-instruct-fp16
41+
- name: Setup ollama
42+
uses: ./.github/actions/setup-ollama
5043

51-
- name: Set Up Environment and Install Dependencies
44+
- name: Build Llama Stack
5245
run: |
53-
uv sync --extra dev --extra test
54-
uv pip install ollama faiss-cpu
55-
# always test against the latest version of the client
56-
# TODO: this is not necessarily a good idea. we need to test against both published and latest
57-
# to find out backwards compatibility issues.
58-
uv pip install git+https://github.com/meta-llama/llama-stack-client-python.git@main
59-
uv pip install -e .
60-
llama stack build --template ollama --image-type venv
46+
uv run llama stack build --template ollama --image-type venv
6147
6248
- name: Start Llama Stack server in background
6349
if: matrix.client-type == 'http'
6450
env:
6551
INFERENCE_MODEL: "meta-llama/Llama-3.2-3B-Instruct"
6652
run: |
67-
source .venv/bin/activate
68-
nohup uv run llama stack run ./llama_stack/templates/ollama/run.yaml --image-type venv > server.log 2>&1 &
53+
LLAMA_STACK_LOG_FILE=server.log nohup uv run llama stack run ./llama_stack/templates/ollama/run.yaml --image-type venv --env OLLAMA_URL="http://0.0.0.0:11434" &
6954
7055
- name: Wait for Llama Stack server to be ready
7156
if: matrix.client-type == 'http'
@@ -93,16 +78,43 @@ jobs:
9378
exit 1
9479
fi
9580
81+
- name: Check Storage and Memory Available Before Tests
82+
if: ${{ always() }}
83+
run: |
84+
free -h
85+
df -h
86+
9687
- name: Run Integration Tests
9788
env:
9889
INFERENCE_MODEL: "meta-llama/Llama-3.2-3B-Instruct"
90+
OLLAMA_URL: "http://0.0.0.0:11434"
9991
run: |
10092
if [ "${{ matrix.client-type }}" == "library" ]; then
10193
stack_config="ollama"
10294
else
10395
stack_config="http://localhost:8321"
10496
fi
105-
uv run pytest -v tests/integration/${{ matrix.test-type }} --stack-config=${stack_config} \
97+
uv run pytest -s -v tests/integration/${{ matrix.test-type }} --stack-config=${stack_config} \
10698
-k "not(builtin_tool or safety_with_image or code_interpreter or test_rag)" \
10799
--text-model="meta-llama/Llama-3.2-3B-Instruct" \
108100
--embedding-model=all-MiniLM-L6-v2
101+
102+
- name: Check Storage and Memory Available After Tests
103+
if: ${{ always() }}
104+
run: |
105+
free -h
106+
df -h
107+
108+
- name: Write ollama logs to file
109+
if: ${{ always() }}
110+
run: |
111+
sudo docker logs ollama > ollama.log
112+
113+
- name: Upload all logs to artifacts
114+
if: ${{ always() }}
115+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
116+
with:
117+
name: logs-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.client-type }}-${{ matrix.test-type }}-${{ matrix.python-version }}
118+
path: |
119+
*.log
120+
retention-days: 1

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1919

2020
- name: Set up Python
21-
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
21+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2222
with:
2323
python-version: '3.11'
2424
cache: pip
@@ -27,6 +27,9 @@ jobs:
2727
.pre-commit-config.yaml
2828
2929
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
30+
env:
31+
SKIP: no-commit-to-branch
32+
RUFF_OUTPUT_FORMAT: github
3033

3134
- name: Verify if there are any diff files after pre-commit
3235
run: |

0 commit comments

Comments
 (0)