-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating notebook testing workflow (#343)
* Renaming job action and updating notebook * Testing new notebook * Standardizing notebooks * More updating more testing * More standardizing * Updating more notebooks * Testing all ipynb directly under examples * Standardizing notebooks * Updating notebooks * adding branch to action * typo * Updating Action to read agentops.log for each notebook. Fixing recording-events.ipynb * Fixing Action to save agentops.log * Fixing Action * iterating workflow * Should continue executing notebooks when one fails * Workflow now for all ipynb. Fixing lots of notebooks * Fixing notebooks * Adding multion key * workflow finishing touches * adding excluded notebooks * Fixed job_posting example * Adding markdown_validator notebook
- Loading branch information
Showing
22 changed files
with
2,334 additions
and
1,057 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,91 @@ | ||
name: Run Notebook and Check Logs | ||
|
||
name: Test Notebooks | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
run-notebook-and-check-logs: | ||
test-notebooks: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.8'] | ||
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 | ||
- name: Run notebook | ||
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: | | ||
jupyter execute examples/openai-gpt.ipynb | ||
mkdir -p logs | ||
exit_code=0 | ||
- name: Check for errors and warnings | ||
run: | | ||
if [ -f agentops.log ]; then | ||
if grep -E "ERROR|WARNING" agentops.log; then | ||
echo "Errors or warnings found in agentops.log for Python ${{ matrix.python-version }}" | ||
exit 1 | ||
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 errors or warnings found in agentops.log for Python ${{ matrix.python-version }}" | ||
echo "No agentops.log generated for $notebook_name" | ||
fi | ||
else | ||
echo "agentops.log file not found. Assuming successful execution without logging." | ||
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 | ||
- name: Upload log as artifact (if exists) | ||
exit $exit_code | ||
- name: Upload logs as artifacts | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: agentops-log-${{ matrix.python-version }} | ||
path: agentops.log | ||
if-no-files-found: ignore | ||
name: notebook-logs-${{ matrix.python-version }} | ||
path: logs/agentops-*.log | ||
if-no-files-found: warn |
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 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
Oops, something went wrong.