Skip to content

Commit 2413447

Browse files
authored
ci: add new action to install ollama, cache the model (#2054)
# What does this PR do? This PR introduces a reusable GitHub Actions workflow for pulling and running an Ollama model, with caching to avoid repeated downloads. [//]: # (If resolving an issue, uncomment and update the line below) Closes: #1949 ## Test Plan 1. Trigger a workflow that uses the Ollama setup. Confirm that: - The model is pulled successfully. - It is placed in the correct directory, official at the moment (not ~ollama/.ollama/models as per comment so need to confirm this). 2. Re-run the same workflow to validate that: - The model is restored from the cache. - Execution succeeds with the cached model. [//]: # (## Documentation)
1 parent 3022f7b commit 2413447

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Setup Ollama
2+
description: Start Ollama and cache model
3+
inputs:
4+
models:
5+
description: Comma-separated list of models to pull
6+
default: "llama3.2:3b-instruct-fp16,all-minilm:latest"
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Install and start Ollama
11+
shell: bash
12+
run: |
13+
# the ollama installer also starts the ollama service
14+
curl -fsSL https://ollama.com/install.sh | sh
15+
16+
# Do NOT cache models - pulling the cache is actually slower than just pulling the model.
17+
# It takes ~45 seconds to pull the models from the cache and unpack it, but only 30 seconds to
18+
# pull them directly.
19+
# Maybe this is because the cache is being pulled at the same time by all the matrix jobs?
20+
- name: Pull requested models
21+
if: inputs.models != ''
22+
shell: bash
23+
run: |
24+
for model in $(echo "${{ inputs.models }}" | tr ',' ' '); do
25+
ollama pull "$model"
26+
done

.github/workflows/integration-tests.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,8 @@ jobs:
3838
python-version: "3.10"
3939
activate-environment: true
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-
# Do NOT cache models - pulling the cache is actually slower than just pulling the model.
47-
# It takes ~45 seconds to pull the models from the cache and unpack it, but only 30 seconds to
48-
# pull them directly.
49-
# Maybe this is because the cache is being pulled at the same time by all the matrix jobs?
50-
- name: Pull Ollama models (instruct and embed)
51-
run: |
52-
ollama pull llama3.2:3b-instruct-fp16
53-
ollama pull all-minilm:latest
41+
- name: Setup ollama
42+
uses: ./.github/actions/setup-ollama
5443

5544
- name: Set Up Environment and Install Dependencies
5645
run: |

0 commit comments

Comments
 (0)