From 1e016f1ee8581a0a0ed67bdf3bbada98f3d706d8 Mon Sep 17 00:00:00 2001 From: Luca Grillotti Date: Wed, 17 May 2023 15:15:03 +0200 Subject: [PATCH] fix: dependencies in notebook examples (#149) fix: dependencies in notebook examples --- .readthedocs.yaml | 4 +- environment.yaml | 1 - examples/cmame.ipynb | 8 +- examples/cmamega.ipynb | 8 +- examples/dads.ipynb | 8 +- examples/diayn.ipynb | 8 +- examples/distributed_mapelites.ipynb | 140 ++++++--------------------- examples/mapelites.ipynb | 8 +- examples/mees.ipynb | 8 +- examples/mome.ipynb | 8 +- examples/nsga2_spea2.ipynb | 6 ++ examples/omgmega.ipynb | 6 ++ examples/pgame.ipynb | 8 +- examples/qdpg.ipynb | 8 +- examples/smerl.ipynb | 10 +- requirements.txt | 2 + setup.py | 1 + 17 files changed, 117 insertions(+), 125 deletions(-) mode change 100755 => 100644 examples/mees.ipynb diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 2ef47062..7eec359d 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -18,7 +18,7 @@ mkdocs: # Optionally declare the Python requirements required to build your docs python: install: - - requirements: requirements.txt - - requirements: docs/requirements.txt - method: pip path: . + - requirements: requirements.txt + - requirements: docs/requirements.txt diff --git a/environment.yaml b/environment.yaml index 78058b9d..e46c034e 100644 --- a/environment.yaml +++ b/environment.yaml @@ -8,6 +8,5 @@ dependencies: - conda>=4.9.2 - pip: - --find-links https://storage.googleapis.com/jax-releases/jax_releases.html - - jaxlib==0.3.15 - -r requirements.txt - -r requirements-dev.txt diff --git a/examples/cmame.ipynb b/examples/cmame.ipynb index c9d6f67e..1d7337d4 100644 --- a/examples/cmame.ipynb +++ b/examples/cmame.ipynb @@ -49,7 +49,13 @@ "except:\n", " !pip install --no-deps git+https://github.com/deepmind/chex.git@v0.1.3 |tail -n 1\n", " import chex\n", - " \n", + "\n", + "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", "try:\n", " import qdax\n", "except:\n", diff --git a/examples/cmamega.ipynb b/examples/cmamega.ipynb index 509e52ea..2e00d660 100644 --- a/examples/cmamega.ipynb +++ b/examples/cmamega.ipynb @@ -43,7 +43,13 @@ "except:\n", " !pip install --no-deps git+https://github.com/deepmind/chex.git@v0.1.3 |tail -n 1\n", " import chex\n", - " \n", + "\n", + "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", "try:\n", " import qdax\n", "except:\n", diff --git a/examples/dads.ipynb b/examples/dads.ipynb index f64f4685..deba8835 100644 --- a/examples/dads.ipynb +++ b/examples/dads.ipynb @@ -45,10 +45,16 @@ "try:\n", " import brax\n", "except:\n", - " !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n", + " !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n", " import brax\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import haiku\n", "except:\n", " !pip install git+https://github.com/deepmind/dm-haiku.git@v0.0.5 |tail -n 1\n", diff --git a/examples/diayn.ipynb b/examples/diayn.ipynb index 10cfda49..c725da4b 100644 --- a/examples/diayn.ipynb +++ b/examples/diayn.ipynb @@ -45,10 +45,16 @@ "try:\n", " import brax\n", "except:\n", - " !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n", + " !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n", " import brax\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import haiku\n", "except:\n", " !pip install git+https://github.com/deepmind/dm-haiku.git@v0.0.5 |tail -n 1\n", diff --git a/examples/distributed_mapelites.ipynb b/examples/distributed_mapelites.ipynb index b8a08b52..434725a3 100644 --- a/examples/distributed_mapelites.ipynb +++ b/examples/distributed_mapelites.ipynb @@ -2,22 +2,14 @@ "cells": [ { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/adaptive-intelligent-robotics/QDax/blob/main/examples/distributed_mapelites.ipynb)" ] }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "# Optimizing with MAP-Elites in Jax (multi-devices example)\n", "\n", @@ -34,11 +26,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "#@title Installs and Imports\n", @@ -61,10 +49,16 @@ "try:\n", " import brax\n", "except:\n", - " !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n", + " !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n", " import brax\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import qdax\n", "except:\n", " !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@main |tail -n 1\n", @@ -93,22 +87,14 @@ }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "## Setup and get devices" ] }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "Setup the default platform where the MAP-Elites will be stored and MAP-Elite updates will happen. " ] @@ -116,11 +102,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "default_device = 'cpu'\n", @@ -130,11 +112,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "# Get devices (change gpu by tpu if needed)\n", @@ -146,11 +124,7 @@ }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "## Setup run parameters" ] @@ -158,11 +132,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "#@title QD Training Definitions Fields\n", @@ -185,11 +155,7 @@ }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "## Init environment, policy, population params, init states of the env\n", "\n", @@ -199,11 +165,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "%%time\n", @@ -237,11 +199,7 @@ }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "## Define the way the policy interacts with the env\n", "\n", @@ -251,11 +209,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "# Define the fonction to play a step with the policy in the environment\n", @@ -289,11 +243,7 @@ }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "## Define the scoring function and the way metrics are computed\n", "\n", @@ -303,11 +253,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "# Prepare the scoring function\n", @@ -332,11 +278,7 @@ }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "## Define the emitter\n", "\n", @@ -346,11 +288,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "# Define emitter\n", @@ -367,11 +305,7 @@ }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "## Instantiate and initialise the MAP Elites algorithm" ] @@ -379,11 +313,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "%%time\n", @@ -423,11 +353,7 @@ }, { "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, + "metadata": {}, "source": [ "## Launch MAP-Elites iterations" ] @@ -435,11 +361,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "log_period = 10\n", @@ -493,11 +415,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "pycharm": { - "name": "#%%\n" - } - }, + "metadata": {}, "outputs": [], "source": [ "# Get the repertoire from the first device\n", diff --git a/examples/mapelites.ipynb b/examples/mapelites.ipynb index c456cf5b..18728e73 100644 --- a/examples/mapelites.ipynb +++ b/examples/mapelites.ipynb @@ -49,10 +49,16 @@ "try:\n", " import brax\n", "except:\n", - " !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n", + " !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n", " import brax\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import qdax\n", "except:\n", " !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@main |tail -n 1\n", diff --git a/examples/mees.ipynb b/examples/mees.ipynb old mode 100755 new mode 100644 index 8f1dc444..ab5fad93 --- a/examples/mees.ipynb +++ b/examples/mees.ipynb @@ -54,10 +54,16 @@ "try:\n", " import brax\n", "except:\n", - " !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n", + " !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n", " import brax\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import qdax\n", "except:\n", " !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@feat/add-algo-mees |tail -n 1\n", diff --git a/examples/mome.ipynb b/examples/mome.ipynb index 6a6f7d39..a4ca36a6 100644 --- a/examples/mome.ipynb +++ b/examples/mome.ipynb @@ -49,7 +49,13 @@ "except:\n", " !pip install --no-deps git+https://github.com/deepmind/chex.git@v0.1.3 |tail -n 1\n", " import chex\n", - " \n", + "\n", + "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", "try:\n", " import qdax\n", "except:\n", diff --git a/examples/nsga2_spea2.ipynb b/examples/nsga2_spea2.ipynb index 5cbe02a2..51c5f5bd 100644 --- a/examples/nsga2_spea2.ipynb +++ b/examples/nsga2_spea2.ipynb @@ -52,6 +52,12 @@ " import chex\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import qdax\n", "except:\n", " !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@main |tail -n 1\n", diff --git a/examples/omgmega.ipynb b/examples/omgmega.ipynb index d75a0077..0a28876a 100644 --- a/examples/omgmega.ipynb +++ b/examples/omgmega.ipynb @@ -47,6 +47,12 @@ " import chex\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import qdax\n", "except:\n", " !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@main |tail -n 1\n", diff --git a/examples/pgame.ipynb b/examples/pgame.ipynb index 24222ddf..7a51a0bd 100644 --- a/examples/pgame.ipynb +++ b/examples/pgame.ipynb @@ -48,10 +48,16 @@ "try:\n", " import brax\n", "except:\n", - " !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n", + " !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n", " import brax\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import qdax\n", "except:\n", " !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@main |tail -n 1\n", diff --git a/examples/qdpg.ipynb b/examples/qdpg.ipynb index 5642fd3b..d778ad1d 100644 --- a/examples/qdpg.ipynb +++ b/examples/qdpg.ipynb @@ -48,10 +48,16 @@ "try:\n", " import brax\n", "except:\n", - " !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n", + " !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n", " import brax\n", "\n", "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", + "\n", + "try:\n", " import qdax\n", "except:\n", " !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@main |tail -n 1\n", diff --git a/examples/smerl.ipynb b/examples/smerl.ipynb index 8042c8cf..47ff96e9 100644 --- a/examples/smerl.ipynb +++ b/examples/smerl.ipynb @@ -45,8 +45,14 @@ "try:\n", " import brax\n", "except:\n", - " !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n", - " import \n", + " !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n", + " import brax\n", + "\n", + "try:\n", + " import jumanji\n", + "except:\n", + " !pip install \"jumanji==0.2.2\"\n", + " import jumanji\n", " \n", "try:\n", " import haiku\n", diff --git a/requirements.txt b/requirements.txt index b97297fa..16c91bc3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,9 +6,11 @@ flax==0.6.0 gym==0.23.1 ipython jax==0.3.17 +jaxlib==0.3.15 jumanji==0.1.3 jupyter numpy==1.22.3 +optax==0.1.4 protobuf==3.19.4 scikit-learn==1.0.2 scipy==1.8.0 diff --git a/setup.py b/setup.py index 2e50e0ea..a71f3174 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ "brax>=0.0.15", "gym>=0.23.1", "numpy>=1.22.3", + "optax>=0.1, <0.1.5", "scikit-learn>=1.0.2", "scipy>=1.8.0", ],