-
Notifications
You must be signed in to change notification settings - Fork 238
93 lines (82 loc) · 2.94 KB
/
test-notebooks.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
name: Test Notebooks
on:
pull_request_target: # Allows manual triggering from PR UI
push:
branches:
- main
paths-ignore:
- 'docs/**'
jobs:
test-notebooks:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U jupyter
- name: Create .env file
run: |
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "AGENTOPS_API_KEY=${{ secrets.AGENTOPS_API_KEY }}" >> .env
echo "CO_API_KEY=${{ secrets.CO_API_KEY }}" >> .env
echo "GROQ_API_KEY=${{ secrets.GROQ_API_KEY }}" >> .env
echo "MULTION_API_KEY=${{ secrets.MULTION_API_KEY }}" >> .env
echo "SERPER_API_KEY=${{ secrets.SERPER_API_KEY }}" >> .env
- name: Run notebooks and check for errors
run: |
mkdir -p logs
exit_code=0
exclude_notebooks=(
"./examples/crew/job_posting.ipynb"
)
for notebook in $(find . -name '*.ipynb'); do
skip=false
for excluded in "${exclude_notebooks[@]}"; do
if [[ "$notebook" == "$excluded" ]]; then
skip=true
echo "Skipping excluded notebook: $notebook"
break
fi
done
$skip && continue
notebook_name=$(basename "$notebook" .ipynb)
notebook_path=$(realpath "$notebook")
notebook_dir=$(dirname "$notebook_path")
# Run the notebook
jupyter execute "$notebook_path" || true
# Check if agentops.log was created
if [ -f "${notebook_dir}/agentops.log" ]; then
dest_log="logs/agentops-${notebook_name}.log"
mv "${notebook_dir}/agentops.log" "$dest_log"
# Check agentops log for errors or warnings
if grep -E "ERROR|WARNING" "$dest_log"; then
echo "Errors or warnings found in $dest_log for Python ${{ matrix.python-version }}"
exit_code=1
else
echo "No errors or warnings found in $dest_log for Python ${{ matrix.python-version }}"
fi
else
echo "No agentops.log generated for $notebook_name"
fi
done
# Check if any logs were found
if [ $(find logs -name 'agentops-*.log' | wc -l) -eq 0 ]; then
echo "No agentops.log files were generated for any notebook"
fi
exit $exit_code
- name: Upload logs as artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: notebook-logs-${{ matrix.python-version }}
path: logs/agentops-*.log
if-no-files-found: warn