-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to notebook testing automation (#342)
* Adding notebook testing automation (#340) * Fixing path in GitHub action * 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
- Loading branch information
Showing
20 changed files
with
1,248 additions
and
968 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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Test Notebooks | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
jobs: | ||
test-notebooks: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | ||
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 | ||
for notebook in $(find . -name '*.ipynb'); do | ||
notebook_name=$(basename "$notebook" .ipynb) | ||
notebook_path=$(realpath "$notebook") | ||
notebook_dir=$(dirname "$notebook_path") | ||
# Remove any existing agentops.log before running the notebook | ||
rm -f "${notebook_dir}/agentops.log" | ||
# 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 |
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.