Merge pull request #384 from dongyuanjushi/update-mode-fig #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: Run AIOS kernel in background | |
env: | |
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY || 'AIzaSyCx0VNhObFu0ta95xDfBx4IKJuyiPTXqbQ' }} | |
run: | | |
# Check if using default test key and validate API key format | |
if [ "$GEMINI_API_KEY" = "AIzaSyCx0VNhObFu0ta95xDfBx4IKJuyiPTXqbQ" ]; then | |
echo "Notice: Using test API key - For testing purposes only" | |
elif [[ ! $GEMINI_API_KEY =~ ^AIza[0-9A-Za-z_-]{35}$ ]]; then | |
echo "Error: Invalid GEMINI_API_KEY format" | |
exit 1 | |
fi | |
bash runtime/launch_kernel.sh &>logs & | |
KERNEL_PID=$! | |
# Set maximum wait time (10 seconds) | |
max_wait=10 | |
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 | |
env: | |
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY || 'AIzaSyCx0VNhObFu0ta95xDfBx4IKJuyiPTXqbQ' }} | |
run: | | |
# Check if using default test key | |
if [ "$GEMINI_API_KEY" = "AIzaSyCx0VNhObFu0ta95xDfBx4IKJuyiPTXqbQ" ]; then | |
echo "Notice: Using test API key - For testing purposes only" | |
fi | |
# Run agent and capture exit code | |
run-agent \ | |
--llm_name gemini-1.5-flash \ | |
--llm_backend google \ | |
--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 |