Skip to content

Commit

Permalink
fix box2d rendering issues in google colab (or at least fail silently)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianHolsheimer committed May 3, 2022
1 parent 3d124bb commit ccd0eae
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 1 deletion.
11 changes: 11 additions & 0 deletions doc/_notebooks/cartpole/a2c.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
11 changes: 11 additions & 0 deletions doc/_notebooks/cartpole/dqn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
11 changes: 11 additions & 0 deletions doc/_notebooks/cartpole/iqn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
11 changes: 11 additions & 0 deletions doc/_notebooks/cartpole/model_based.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
11 changes: 11 additions & 0 deletions doc/_notebooks/pendulum/ddpg.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
15 changes: 15 additions & 0 deletions doc/_notebooks/pendulum/dsac.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -189,6 +200,10 @@
"version": "3.8.2"
}
},
"colab": {
"name": "dsac.ipynb",
"provenance": []
},
"nbformat": 4,
"nbformat_minor": 2
}
11 changes: 11 additions & 0 deletions doc/_notebooks/pendulum/ppo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
11 changes: 11 additions & 0 deletions doc/_notebooks/pendulum/sac.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
11 changes: 11 additions & 0 deletions doc/_notebooks/pendulum/td3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
15 changes: 15 additions & 0 deletions doc/_notebooks/pendulum/td4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"%tensorboard --logdir ./data/tensorboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -181,6 +192,10 @@
"version": "3.8.2"
}
},
"colab": {
"name": "td4.ipynb",
"provenance": []
},
"nbformat": 4,
"nbformat_minor": 2
}
16 changes: 15 additions & 1 deletion doc/create_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@
"nbformat_minor": 2
}

sdl_videodriver_cell = {
"cell_type": "code",
"execution_count": None,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to fix rendering errors.\n",
"import os\n",
"os.environ['SDL_VIDEODRIVER'] = 'dummy'",
]
}

tensorboard_cell = {
"cell_type": "code",
"execution_count": None,
Expand Down Expand Up @@ -83,7 +95,9 @@
with open(f_in) as r, open(f'{f_out}', 'w') as w:
lines = list(r)
nb['colab']['name'] = os.path.split(f_out)[1]
nb['cells'][-1]['source'] = lines # the actual code
nb['cells'][-1]['source'] = lines
if any(("CartPole-v" in line or "Pendulum-v" in line) for line in lines):
nb['cells'].insert(1, sdl_videodriver_cell)
if any("tensorboard_dir=" in line for line in lines):
nb['cells'].insert(1, tensorboard_cell)
if 'atari' in f_in:
Expand Down

0 comments on commit ccd0eae

Please sign in to comment.