-
Notifications
You must be signed in to change notification settings - Fork 461
146 lines (123 loc) · 4.31 KB
/
test_ollama.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: AIOS Application
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main # Specify main branch
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Git Clone Action
# You may pin to the exact commit or the version.
# uses: sudosubin/git-clone-action@8a93ce24d47782e30077508cccacf8a05a891bae
uses: sudosubin/[email protected]
with:
# Repository owner and name. Ex: sudosubin/git-clone-action
repository: agiresearch/Cerebrum
path: Cerebrum
- name: Install cerebrum special edition
run: |
python -m pip install -e Cerebrum/
- name: Download and install Ollama
run: |
curl -fsSL https://ollama.com/install.sh | sh
- name: Pull Ollama models
run: |
ollama pull llama3:8b
- name: Run Ollama serve
run: |
ollama serve 2>&1 | tee ollama-llm.log &
# Wait for ollama to start
for i in {1..30}; do
if curl -s http://localhost:11434/api/version > /dev/null; then
echo "Ollama is running"
break
fi
echo "Waiting for ollama to start... ($i/30)"
sleep 1
done
# Verify ollama is running
curl -s http://localhost:11434/api/version || (echo "Failed to start ollama" && exit 1)
- name: Run AIOS kernel in background
run: |
bash runtime/launch_kernel.sh &>logs &
KERNEL_PID=$!
# Set maximum wait time (20 seconds)
max_wait=20
start_time=$SECONDS
# Dynamically check if the process is running until it succeeds or times out
while true; do
if ! ps -p $KERNEL_PID > /dev/null; then
echo "Kernel process died. Checking logs:"
cat logs
exit 1
fi
if nc -z localhost 8000; then
if curl -s http://localhost:8000/health > /dev/null; then
echo "Kernel successfully started and healthy"
break
fi
fi
# Check if timed out
elapsed=$((SECONDS - start_time))
if [ $elapsed -ge $max_wait ]; then
echo "Timeout after ${max_wait} seconds. Kernel failed to start properly."
cat logs
exit 1
fi
echo "Waiting for kernel to start... (${elapsed}s elapsed)"
sleep 1
done
- name: Run the run-agent code
run: |
# Run agent and capture exit code
run-agent \
--llm_name llama3:8b \
--llm_backend ollama \
--agent_name_or_path demo_author/demo_agent \
--task "Tell me what is core idea of AIOS" \
--aios_kernel_url http://localhost:8000 \
2>&1 | tee agent.log
# Check for specific error patterns in the log
if grep -q "Failed to initialize client: 500 Server Error" agent.log; then
echo "Error: LLM initialization failed. Please check your API key configuration."
exit 1
fi
# Check if the agent actually completed successfully
if ! grep -q "Final Result:" agent.log; then
echo "Error: Agent did not complete successfully"
exit 1
fi
- name: Upload a Build Artifact
if: always() # Upload logs even if job fails
uses: actions/[email protected]
with:
name: logs
path: |
logs
agent.log
- name: Collect debug information
if: failure()
run: |
echo "=== Kernel Logs ==="
cat logs
echo "=== Environment Variables ==="
env | grep -i api_key || true
echo "=== Process Status ==="
ps aux | grep kernel