Skip to content

Commit

Permalink
Switch documentation examples to notebooks and misc improvements (#459)
Browse files Browse the repository at this point in the history
* Add more top-level poke-env imports

* Misc ps client docstring changes

* PSClient avatar is now a string

* Rename lint and tests workflows

* Delete gen 7 examples

* Add cross evaluate random players notebook example and merge with max damage player

* Add check examples run workflow

* Integrate ou max player content into quickstart

* Convert using custom teambuilder example to notebook and add second example
  • Loading branch information
hsahovic committed Mar 3, 2024
1 parent 90a806f commit bfb4d27
Show file tree
Hide file tree
Showing 25 changed files with 2,619 additions and 2,120 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/check-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Check examples run
on:
push:
branches:
- "master"
pull_request:
branches:
- "master"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout repository code
uses: actions/checkout@v4

# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Python Kernel
run: |
pip install ipykernel
python -m ipykernel install --user --name python3
- name: Install dev dependencies
run: pip install -r requirements-dev.txt

- name: Install dependencies
run: pip install -r requirements.txt

- name: Build package
run: |
pip install build
python -m build
- name: Install built package
run: pip install --force-reinstall dist/*.whl

- name: Remove source
run: rm -rf ./src

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Checkout PS
uses: actions/checkout@v4
with:
repository: smogon/pokemon-showdown
path: pokemon-showdown
submodules: recursive

- name: Get last showdown commit hash
id: showdown-hash
run: |
cd pokemon-showdown/
export hash=`git log -1 --pretty=format:%H`
echo "hash=$hash" >> $GITHUB_OUTPUT
- name: Restore server cache
uses: actions/cache@v3
with:
path: pokemon-showdown/node_modules
key: showdown-python${{ matrix.version }}-${{ steps.showdown-hash.outputs.hash }}
restore-keys: showdown-python${{ matrix.version }}-

- name: Install PS dependencies & setup config
run: |
cd pokemon-showdown
npm install
cp config/config-example.js config/config.js
sed -i 's/backdoor = true/backdoor = false/g' config/config.js
sed -i 's/simulatorprocesses = 1/simulatorprocesses = 2/g' config/config.js
sed -i 's/.workers = 1 = 1/.workers = 2/g' config/config.js
- name: Start PS
run: cd pokemon-showdown;node pokemon-showdown start --no-security --max-old-space-size=3000 &

- name: Wait for server to be up
run: |
until $(curl --output /dev/null --silent --head --fail http://localhost:8000); do
sleep .01
done
sleep 1
- name: Run example notebooks
run: |
for notebook in $(find examples -name '*.ipynb'); do
jupyter nbconvert --to notebook --execute "$notebook" --output temp.ipynb
if [ $? -ne 0 ]; then
echo "Execution of $notebook failed"
exit 1
fi
rm examples/temp.ipynb
done
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: lint
name: Lint
on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: Run tests
on:
push:
branches:
Expand Down
103 changes: 0 additions & 103 deletions docs/source/examples/cross_evaluate_random_players.ipynb

This file was deleted.

10 changes: 4 additions & 6 deletions docs/source/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ This page lists detailled examples demonstrating how to use this package. They a
.. toctree::
:maxdepth: 4

cross_evaluate_random_players
max_damage_player
rl_with_open_ai_gym_wrapper
ou_max_player
using_custom_teambuilder
connecting_to_showdown_and_challenging_humans
quickstart
using_a_custom_teambuilder
connecting_to_showdown_and_challenging_humans
rl_with_open_ai_gym_wrapper
138 changes: 0 additions & 138 deletions docs/source/examples/max_damage_player.rst

This file was deleted.

0 comments on commit bfb4d27

Please sign in to comment.