From 1e51861d6521c496efe95b5967e52a45eadd1d64 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Wed, 31 Jul 2019 22:31:55 +0200 Subject: [PATCH 01/38] Update dependencies --- docker/Dockerfile.cpu | 11 ++--------- docker/Dockerfile.gpu | 9 +-------- docs/misc/changelog.rst | 27 +++++++++++++++++++++++++++ setup.cfg | 4 +++- setup.py | 6 +++--- stable_baselines/__init__.py | 2 +- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu index 1c40cd2543..a11619d9fd 100644 --- a/docker/Dockerfile.cpu +++ b/docker/Dockerfile.cpu @@ -13,25 +13,18 @@ RUN \ pip install --upgrade pip && \ pip install codacy-coverage && \ pip install scipy && \ - pip install tqdm && \ pip install joblib && \ - pip install zmq && \ - pip install dill && \ - pip install progressbar2 && \ pip install mpi4py && \ pip install cloudpickle && \ - pip install tensorflow==1.5.0 && \ - pip install click && \ + pip install tensorflow==1.8.0 && \ pip install opencv-python && \ pip install numpy && \ pip install pandas && \ - pip install pytest==3.5.1 && \ + pip install pytest && \ pip install pytest-cov && \ pip install pytest-env && \ pip install pytest-xdist && \ pip install matplotlib && \ - pip install seaborn && \ - pip install glob2 && \ pip install gym[atari,classic_control]>=0.10.9 ENV PATH=$VENV/bin:$PATH diff --git a/docker/Dockerfile.gpu b/docker/Dockerfile.gpu index 811121ad9d..e631572989 100644 --- a/docker/Dockerfile.gpu +++ b/docker/Dockerfile.gpu @@ -13,25 +13,18 @@ RUN \ pip install --upgrade pip && \ pip install codacy-coverage && \ pip install scipy && \ - pip install tqdm && \ pip install joblib && \ - pip install zmq && \ - pip install dill && \ - pip install progressbar2 && \ pip install mpi4py && \ pip install cloudpickle && \ pip install tensorflow-gpu==1.8.0 && \ - pip install click && \ pip install opencv-python && \ pip install numpy && \ pip install pandas && \ - pip install pytest==3.5.1 && \ + pip install pytest && \ pip install pytest-cov && \ pip install pytest-env && \ pip install pytest-xdist && \ pip install matplotlib && \ - pip install seaborn && \ - pip install glob2 && \ pip install gym[atari,classic_control]>=0.10.9 ENV PATH=$VENV/bin:$PATH diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index da5fa68242..e0d93adcc4 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -6,6 +6,33 @@ Changelog For download links, please look at `Github release page `_. + +Pre-Release 2.7.1a0 (WIP) +-------------------------- + + +Breaking Changes: +^^^^^^^^^^^^^^^^^ +- updated dependencies: tensorflow v1.8.0 is now required + +New Features: +^^^^^^^^^^^^^ + +Bug Fixes: +^^^^^^^^^^ + +Deprecations: +^^^^^^^^^^^^^ + +Others: +^^^^^^^ +- docker images were updated + +Documentation: +^^^^^^^^^^^^^^ + + + Release 2.7.0 (2019-07-31) -------------------------- diff --git a/setup.cfg b/setup.cfg index 91efc81a81..f42d39d34f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,5 +4,7 @@ license_file = LICENSE [tool:pytest] # Deterministic ordering for tests; useful for pytest-xdist. -env = +env = PYTHONHASHSEED=0 +filterwarnings = + ignore:inspect.getargspec:DeprecationWarning:tensorflow diff --git a/setup.py b/setup.py index 56387e8f3d..eb036dcebb 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ install_tf, tf_gpu = False, False try: import tensorflow as tf - if tf.__version__ < LooseVersion('1.5.0'): + if tf.__version__ < LooseVersion('1.8.0'): install_tf = True # check if a gpu version is needed tf_gpu = tf.test.is_gpu_available() @@ -29,7 +29,7 @@ tf_dependency = [] if install_tf: - tf_dependency = ['tensorflow-gpu>=1.5.0'] if tf_gpu else ['tensorflow>=1.5.0'] + tf_dependency = ['tensorflow-gpu>=1.8.0'] if tf_gpu else ['tensorflow>=1.8.0'] if tf_gpu: print("A GPU was detected, tensorflow-gpu will be installed") @@ -138,7 +138,7 @@ license="MIT", long_description=long_description, long_description_content_type='text/markdown', - version="2.7.0", + version="2.7.1a0", ) # python setup.py sdist diff --git a/stable_baselines/__init__.py b/stable_baselines/__init__.py index 35f62999ae..216f1c024e 100644 --- a/stable_baselines/__init__.py +++ b/stable_baselines/__init__.py @@ -11,4 +11,4 @@ from stable_baselines.trpo_mpi import TRPO from stable_baselines.sac import SAC -__version__ = "2.7.0" +__version__ = "2.7.1a0" From 5c146e79b3815e101848e051824c80266b751d42 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Thu, 1 Aug 2019 00:13:47 +0200 Subject: [PATCH 02/38] Fix for numpy v1.17.0 --- docs/misc/changelog.rst | 1 + stable_baselines/gail/dataset/dataset.py | 2 +- tests/test_gail.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index e0d93adcc4..946da2e12a 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -20,6 +20,7 @@ New Features: Bug Fixes: ^^^^^^^^^^ +- set `allow_pickle=True` for numpy>=1.17.0 when loading expert dataset Deprecations: ^^^^^^^^^^^^^ diff --git a/stable_baselines/gail/dataset/dataset.py b/stable_baselines/gail/dataset/dataset.py index 15e92f5d46..64b55dbb3e 100644 --- a/stable_baselines/gail/dataset/dataset.py +++ b/stable_baselines/gail/dataset/dataset.py @@ -38,7 +38,7 @@ def __init__(self, expert_path=None, traj_data=None, train_fraction=0.7, batch_s if traj_data is None and expert_path is None: raise ValueError("Must specify one of 'traj_data' or 'expert_path'") if traj_data is None: - traj_data = np.load(expert_path) + traj_data = np.load(expert_path, allow_pickle=True) if verbose > 0: for key, val in traj_data.items(): diff --git a/tests/test_gail.py b/tests/test_gail.py index 2223948215..3d4a1608d8 100644 --- a/tests/test_gail.py +++ b/tests/test_gail.py @@ -72,7 +72,7 @@ def test_generate(generate_env): if key != 'episode_returns': assert val.shape[0] == n_timesteps, "inconsistent number of timesteps at '{}'".format(key) - dataset_loaded = np.load('expert.npz') + dataset_loaded = np.load('expert.npz', allow_pickle=True) assert dataset.keys() == dataset_loaded.keys() for key in dataset.keys(): assert (dataset[key] == dataset_loaded[key]).all(), "different data at '{}'".format(key) From 69d1208e692a7ca9c70c5c2368cedb6a364d1f3b Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Thu, 1 Aug 2019 10:41:13 +0200 Subject: [PATCH 03/38] Downgrade pytest version for travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 63b804c18e..7bd573ad30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ matrix: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install pytest==3.5.1 pytest-cov==2.6.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install pytest==3.5.1 pytest-cov==2.6.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From 2f27160ffb6936256f96793d4b81450dad2d4da2 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Thu, 1 Aug 2019 17:32:17 +0200 Subject: [PATCH 04/38] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bd573ad30..a8c84536ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ matrix: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install pytest==3.5.1 pytest-cov==2.6.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install pytest==3.5.1 pytest-cov==2.6.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install pytest==3.5.1 pytest-cov==2.6.0 pytest-xdist==1.23.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install pytest==3.5.1 pytest-cov==2.6.0 pytest-xdist==1.23.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From e42ed6f6ab03a09d2472acba908a87e4b59a20de Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 10:13:42 +0200 Subject: [PATCH 05/38] Rollback to previous docker image --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8c84536ab..8e677207b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,15 +9,15 @@ services: - docker install: - - docker pull araffin/stable-baselines-cpu + - docker pull araffin/stable-baselines-cpu:v2.6.0 matrix: include: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install pytest==3.5.1 pytest-cov==2.6.0 pytest-xdist==1.23.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install pytest==3.5.1 pytest-cov==2.6.0 pytest-xdist==1.23.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From d7e95915f7a77f7f0ad357009d1c71a4d63f1cc3 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 12:58:39 +0200 Subject: [PATCH 06/38] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e677207b3..f0db48b88f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ matrix: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From f5be220282de589a7653de9124cc705015cdb783 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 16:42:39 +0200 Subject: [PATCH 07/38] Trying to upgrade pytest --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f0db48b88f..2cb28c61fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ matrix: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From 377e65f5542a141c7637dd5fb3eeabdd1d7d0734 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 18:06:24 +0200 Subject: [PATCH 08/38] Try to ignore pytest warning --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index f42d39d34f..8d1a05d57f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,3 +8,4 @@ env = PYTHONHASHSEED=0 filterwarnings = ignore:inspect.getargspec:DeprecationWarning:tensorflow + ignore:PytestUnknownMarkWarning:pytest From 2073ad4839c54d138bff60e7bb73acf0474c6afa Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 21:19:02 +0200 Subject: [PATCH 09/38] Update setup.cfg --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 8d1a05d57f..c2f8ae0882 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,4 +8,4 @@ env = PYTHONHASHSEED=0 filterwarnings = ignore:inspect.getargspec:DeprecationWarning:tensorflow - ignore:PytestUnknownMarkWarning:pytest + ignore::PytestUnknownMarkWarning From a9e8ab79f678e2ee3a581ddafdc9a296341b0c66 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 21:25:19 +0200 Subject: [PATCH 10/38] Use full name to ignore pytest warning --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index c2f8ae0882..a2359a9066 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,4 +8,4 @@ env = PYTHONHASHSEED=0 filterwarnings = ignore:inspect.getargspec:DeprecationWarning:tensorflow - ignore::PytestUnknownMarkWarning + ignore::_pytest.warning_types.UnknownMarkWarning From 22bdc57f000efb3747b79b9e20be600e75283df6 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 21:52:07 +0200 Subject: [PATCH 11/38] Correct import --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index a2359a9066..a3cacb2414 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,4 +8,4 @@ env = PYTHONHASHSEED=0 filterwarnings = ignore:inspect.getargspec:DeprecationWarning:tensorflow - ignore::_pytest.warning_types.UnknownMarkWarning + ignore::pytest.PytestUnknownMarkWarning From be0ea3c5ee94b88f66147e726814c0853b9b4f2b Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 23:13:31 +0200 Subject: [PATCH 12/38] Remove gym and tf warnings --- setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.cfg b/setup.cfg index a3cacb2414..24f4b3c3bd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,3 +9,5 @@ env = filterwarnings = ignore:inspect.getargspec:DeprecationWarning:tensorflow ignore::pytest.PytestUnknownMarkWarning + ignore:builtin type EagerTensor has no __module__ attribute:DeprecationWarning + ignore:Parameters to load are deprecated.:DeprecationWarning From 6cce6b087b1149a507f5c17cde957183b151be3a Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Fri, 2 Aug 2019 23:14:25 +0200 Subject: [PATCH 13/38] Add TD3 to tensorboard tests --- tests/test_tensorboard.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_tensorboard.py b/tests/test_tensorboard.py index 97aebb415d..a4b675268a 100644 --- a/tests/test_tensorboard.py +++ b/tests/test_tensorboard.py @@ -3,7 +3,7 @@ import pytest -from stable_baselines import A2C, ACER, ACKTR, DQN, DDPG, PPO1, PPO2, SAC, TRPO +from stable_baselines import A2C, ACER, ACKTR, DQN, DDPG, PPO1, PPO2, SAC, TD3, TRPO TENSORBOARD_DIR = '/tmp/tb_dir/' @@ -19,6 +19,7 @@ 'ppo1': (PPO1, 'CartPole-v1'), 'ppo2': (PPO2, 'CartPole-v1'), 'sac': (SAC, 'Pendulum-v0'), + 'td3': (TD3, 'Pendulum-v0'), 'trpo': (TRPO, 'CartPole-v1'), } @@ -47,5 +48,3 @@ def test_multiple_runs(model_name): assert os.path.isdir(TENSORBOARD_DIR + logname + "_1") # Check that the log dir name increments correctly assert os.path.isdir(TENSORBOARD_DIR + logname + "_2") - - From 12a10e8270c8a1a59db03a7dabec31d2b1b9d9d7 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 3 Aug 2019 00:21:49 +0200 Subject: [PATCH 14/38] Ignore additional gym warning --- setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.cfg b/setup.cfg index 24f4b3c3bd..9bc0d82c2b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,4 +10,6 @@ filterwarnings = ignore:inspect.getargspec:DeprecationWarning:tensorflow ignore::pytest.PytestUnknownMarkWarning ignore:builtin type EagerTensor has no __module__ attribute:DeprecationWarning + # Gym warnings ignore:Parameters to load are deprecated.:DeprecationWarning + ignore:the imp module is deprecated in favour of importlib:PendingDeprecationWarning From 67a9f3403b2e5ac0f61defc205ec95978a3cb39b Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 3 Aug 2019 10:40:28 +0200 Subject: [PATCH 15/38] Get rid of additional tf warning --- setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.cfg b/setup.cfg index 9bc0d82c2b..1540c27cb2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,9 @@ env = filterwarnings = ignore:inspect.getargspec:DeprecationWarning:tensorflow ignore::pytest.PytestUnknownMarkWarning + # Tensorflow internal warnings ignore:builtin type EagerTensor has no __module__ attribute:DeprecationWarning + ignore:The binary mode of fromstring is deprecated:DeprecationWarning # Gym warnings ignore:Parameters to load are deprecated.:DeprecationWarning ignore:the imp module is deprecated in favour of importlib:PendingDeprecationWarning From 001ee314aa81ad32c15dc568eed36350e055579d Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 3 Aug 2019 12:02:25 +0200 Subject: [PATCH 16/38] Re-enable new docker image --- .travis.yml | 6 +++--- setup.cfg | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2cb28c61fa..8fb2de6077 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,15 +9,15 @@ services: - docker install: - - docker pull araffin/stable-baselines-cpu:v2.6.0 + - docker pull araffin/stable-baselines-cpu:v2.7.0 matrix: include: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.0 bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.0 bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: diff --git a/setup.cfg b/setup.cfg index 1540c27cb2..5433c8347b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,6 +12,7 @@ filterwarnings = # Tensorflow internal warnings ignore:builtin type EagerTensor has no __module__ attribute:DeprecationWarning ignore:The binary mode of fromstring is deprecated:DeprecationWarning + ignore::FutureWarning:tensorflow # Gym warnings ignore:Parameters to load are deprecated.:DeprecationWarning ignore:the imp module is deprecated in favour of importlib:PendingDeprecationWarning From 74beefc4aad16b2e009881f2a1570190e665745a Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 3 Aug 2019 12:36:55 +0200 Subject: [PATCH 17/38] Test with different tf version --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8fb2de6077..ae086ce52f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,15 +9,15 @@ services: - docker install: - - docker pull araffin/stable-baselines-cpu:v2.7.0 + - docker pull araffin/stable-baselines-cpu:v2.6.0 matrix: include: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.0 bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.0 bash -c "cd /root/code/stable-baselines/ && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install tensorflow==1.8.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install tensorflow==1.8.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From a2da183b5fab80d8d07bdbe54d832bcbf8276ded Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 3 Aug 2019 13:39:59 +0200 Subject: [PATCH 18/38] Upgrade pytest --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae086ce52f..057fe8f611 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ matrix: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install tensorflow==1.8.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install tensorflow==1.8.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pip install tensorflow==1.8.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pip install tensorflow==1.8.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From ed157e26136f8d62830a1715fd2d532b7ed25206 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 3 Aug 2019 15:25:28 +0200 Subject: [PATCH 19/38] Upgrade tf to 1.13.2 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 057fe8f611..f7c4edd214 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ matrix: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pip install tensorflow==1.8.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pip install tensorflow==1.8.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pip install tensorflow==1.13.2 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pip install tensorflow==1.13.2 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From eece3d0e3eb3a64b4ec2989b6c03d03a9e29cf07 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 3 Aug 2019 16:19:01 +0200 Subject: [PATCH 20/38] Try downgrading tf --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f7c4edd214..ec53e13a96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,15 +9,15 @@ services: - docker install: - - docker pull araffin/stable-baselines-cpu:v2.6.0 + - docker pull araffin/stable-baselines-cpu:v2.7.0 matrix: include: - name: "Unit Tests" script: # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pip install tensorflow==1.13.2 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.6.0 bash -c "cd /root/code/stable-baselines/ && pip install --upgrade pytest pytest-cov pytest-xdist && pip install tensorflow==1.13.2 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.0 bash -c "cd /root/code/stable-baselines/ && pip install tensorflow==1.5.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.0 bash -c "cd /root/code/stable-baselines/ && pip install tensorflow==1.5.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' - name: "Sphinx Documentation" script: From 3f3ce12771a88391d42e7f9d790591d2ee464f33 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Mon, 5 Aug 2019 13:43:37 +0100 Subject: [PATCH 21/38] Move Travis CI test to separate bash file --- .travis.yml | 8 ++++---- run_tests_travis.sh | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100755 run_tests_travis.sh diff --git a/.travis.yml b/.travis.yml index ec53e13a96..08038bd8c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,13 +11,13 @@ services: install: - docker pull araffin/stable-baselines-cpu:v2.7.0 +script: + - ./run_tests_travis.sh + matrix: include: - name: "Unit Tests" - script: - # For pull requests from fork, Codacy token is not available, leading to build failure - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.0 bash -c "cd /root/code/stable-baselines/ && pip install tensorflow==1.5.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/"; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker run -it --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.0 bash -c "cd /root/code/stable-baselines/ && pip install tensorflow==1.5.0 gym==0.14.0 && pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN"; fi' + - name: "Sphinx Documentation" script: diff --git a/run_tests_travis.sh b/run_tests_travis.sh new file mode 100755 index 0000000000..743bc3fcc5 --- /dev/null +++ b/run_tests_travis.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +DOCKER_CMD="docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind" +DOCKER_IMAGE="araffin/stable-baselines-cpu:v2.7.0" +BASH_CMD="cd /root/code/stable-baselines/ && pip install tensorflow==1.5.0 gym==0.14.0" + +# For pull requests from fork, Codacy token is not available, leading to build failure +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + ${DOCKER_CMD} ${DOCKER_IMAGE} \ + bash -c "${BASH_CMD} && \ + pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/" +else + ${DOCKER_CMD} --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN ${DOCKER_IMAGE} \ + bash -c "${BASH_CMD} && \ + pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && \ + python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN" +fi From 31cd3a81fe00e78d0be552ba57c60ac6bef00f23 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Mon, 5 Aug 2019 13:49:42 +0100 Subject: [PATCH 22/38] Try splitting up test suite --- .travis.yml | 11 +++++++++-- run_tests_travis.sh | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08038bd8c1..9d6978127b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,12 +12,19 @@ install: - docker pull araffin/stable-baselines-cpu:v2.7.0 script: - - ./run_tests_travis.sh + - ./run_tests_travis.sh ${TEST_GLOB} matrix: include: - - name: "Unit Tests" + # Big test suite. Run in parallel to decrease wall-clock time, and to avoid OOM error from leaks + - name: "Unit Tests a-d" + env: TEST_GLOB=[a-d]* + - name: "Unit Tests e-n" + env: TEST_GLOB=[e-n]* + + - name: "Unit Tests m-z" + env: TEST_GLOB=[m-z]* - name: "Sphinx Documentation" script: diff --git a/run_tests_travis.sh b/run_tests_travis.sh index 743bc3fcc5..dac50237b5 100755 --- a/run_tests_travis.sh +++ b/run_tests_travis.sh @@ -4,14 +4,21 @@ DOCKER_CMD="docker run -it --rm --network host --ipc=host --mount src=$(pwd),tar DOCKER_IMAGE="araffin/stable-baselines-cpu:v2.7.0" BASH_CMD="cd /root/code/stable-baselines/ && pip install tensorflow==1.5.0 gym==0.14.0" +if [[ $# -ne 1 ]]; then + echo "usage: $0 " + exit 1 +fi + +TEST_GLOB=$1 + # For pull requests from fork, Codacy token is not available, leading to build failure if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then ${DOCKER_CMD} ${DOCKER_IMAGE} \ bash -c "${BASH_CMD} && \ - pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/" + pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/test_${TEST_GLOB}" else ${DOCKER_CMD} --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN ${DOCKER_IMAGE} \ bash -c "${BASH_CMD} && \ - pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/ && \ + pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/test_${TEST_GLOB} && \ python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN" fi From 9ac11c3e47b33903897c79a4b539c75301c83c0e Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Mon, 5 Aug 2019 14:03:24 +0100 Subject: [PATCH 23/38] Diagnostic: echo test glob --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d6978127b..e5a721db92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,19 +12,20 @@ install: - docker pull araffin/stable-baselines-cpu:v2.7.0 script: + - echo ./run_tests_travis.sh ${TEST_GLOB} - ./run_tests_travis.sh ${TEST_GLOB} matrix: include: # Big test suite. Run in parallel to decrease wall-clock time, and to avoid OOM error from leaks - name: "Unit Tests a-d" - env: TEST_GLOB=[a-d]* + env: TEST_GLOB="[a-d]*" - name: "Unit Tests e-n" - env: TEST_GLOB=[e-n]* + env: TEST_GLOB="[e-n]*" - name: "Unit Tests m-z" - env: TEST_GLOB=[m-z]* + env: TEST_GLOB="[m-z]*" - name: "Sphinx Documentation" script: From 9df403ed298488ad3c8fbf02ed16ba1deac89543 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Mon, 5 Aug 2019 15:08:42 +0100 Subject: [PATCH 24/38] Avoid unintended wildcard --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e5a721db92..0dce792c0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,8 @@ install: - docker pull araffin/stable-baselines-cpu:v2.7.0 script: - - echo ./run_tests_travis.sh ${TEST_GLOB} - - ./run_tests_travis.sh ${TEST_GLOB} + - echo ./run_tests_travis.sh "${TEST_GLOB}" + - ./run_tests_travis.sh "${TEST_GLOB}" matrix: include: From b9d451785a3fc01c920a93db598b02044dff0ea1 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Mon, 5 Aug 2019 15:18:07 +0100 Subject: [PATCH 25/38] Upgrade TF to 1.13.2, move scripts to subdirectory --- .travis.yml | 3 +-- CONTRIBUTING.md | 2 +- docs/guide/install.rst | 4 ++-- run_docker_cpu.sh => scripts/run_docker_cpu.sh | 0 run_docker_gpu.sh => scripts/run_docker_gpu.sh | 0 run_tests.sh => scripts/run_tests.sh | 0 run_tests_travis.sh => scripts/run_tests_travis.sh | 2 +- 7 files changed, 5 insertions(+), 6 deletions(-) rename run_docker_cpu.sh => scripts/run_docker_cpu.sh (100%) rename run_docker_gpu.sh => scripts/run_docker_gpu.sh (100%) rename run_tests.sh => scripts/run_tests.sh (100%) rename run_tests_travis.sh => scripts/run_tests_travis.sh (97%) diff --git a/.travis.yml b/.travis.yml index 0dce792c0d..0426122060 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,7 @@ install: - docker pull araffin/stable-baselines-cpu:v2.7.0 script: - - echo ./run_tests_travis.sh "${TEST_GLOB}" - - ./run_tests_travis.sh "${TEST_GLOB}" + - ./scripts/run_tests_travis.sh "${TEST_GLOB}" matrix: include: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 77784fd5c3..a038045626 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,7 +91,7 @@ Also, when a bug fix is proposed, tests should be added to avoid regression. To run tests: ``` -./run_tests.sh +./scripts/run_tests.sh ``` ## Changelog and Documentation diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 66f36542c1..a5bcf7b128 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -141,7 +141,7 @@ Or, with the shell file: .. code-block:: bash - ./run_docker_gpu.sh pytest tests/ + ./scripts/run_docker_gpu.sh pytest tests/ Run the docker CPU image @@ -153,7 +153,7 @@ Or, with the shell file: .. code-block:: bash - ./run_docker_cpu.sh pytest tests/ + ./scripts/run_docker_cpu.sh pytest tests/ Explanation of the docker command: diff --git a/run_docker_cpu.sh b/scripts/run_docker_cpu.sh similarity index 100% rename from run_docker_cpu.sh rename to scripts/run_docker_cpu.sh diff --git a/run_docker_gpu.sh b/scripts/run_docker_gpu.sh similarity index 100% rename from run_docker_gpu.sh rename to scripts/run_docker_gpu.sh diff --git a/run_tests.sh b/scripts/run_tests.sh similarity index 100% rename from run_tests.sh rename to scripts/run_tests.sh diff --git a/run_tests_travis.sh b/scripts/run_tests_travis.sh similarity index 97% rename from run_tests_travis.sh rename to scripts/run_tests_travis.sh index dac50237b5..90f66206b7 100755 --- a/run_tests_travis.sh +++ b/scripts/run_tests_travis.sh @@ -2,7 +2,7 @@ DOCKER_CMD="docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind" DOCKER_IMAGE="araffin/stable-baselines-cpu:v2.7.0" -BASH_CMD="cd /root/code/stable-baselines/ && pip install tensorflow==1.5.0 gym==0.14.0" +BASH_CMD="cd /root/code/stable-baselines/ && pip install tensorflow==1.13.2 gym==0.14.0" if [[ $# -ne 1 ]]; then echo "usage: $0 " From 56bcb76c851498dca0a0378c851397a6ec611e52 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Mon, 5 Aug 2019 15:51:56 +0100 Subject: [PATCH 26/38] Split up tests to keep them <20m long --- .travis.yml | 7 +++++-- scripts/run_tests_travis.sh | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0426122060..7bd42823d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,11 @@ matrix: - name: "Unit Tests a-d" env: TEST_GLOB="[a-d]*" - - name: "Unit Tests e-n" - env: TEST_GLOB="[e-n]*" + - name: "Unit Tests e-i" + env: TEST_GLOB="[e-i]*" + + - name: "Unit Tests j-l" + env: TEST_GLOB="[j-l]*" - name: "Unit Tests m-z" env: TEST_GLOB="[m-z]*" diff --git a/scripts/run_tests_travis.sh b/scripts/run_tests_travis.sh index 90f66206b7..539fadad0f 100755 --- a/scripts/run_tests_travis.sh +++ b/scripts/run_tests_travis.sh @@ -11,6 +11,8 @@ fi TEST_GLOB=$1 +set -e # exit immediately on any error + # For pull requests from fork, Codacy token is not available, leading to build failure if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then ${DOCKER_CMD} ${DOCKER_IMAGE} \ @@ -22,3 +24,4 @@ else pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/test_${TEST_GLOB} && \ python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN" fi + From 2ea11181d3c3b050666373d876a7a12281daba41 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Mon, 5 Aug 2019 18:04:21 +0100 Subject: [PATCH 27/38] Try thread-safe SubprocVecEnv --- stable_baselines/common/vec_env/subproc_vec_env.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stable_baselines/common/vec_env/subproc_vec_env.py b/stable_baselines/common/vec_env/subproc_vec_env.py index 330da5b56d..329bc4cf7f 100644 --- a/stable_baselines/common/vec_env/subproc_vec_env.py +++ b/stable_baselines/common/vec_env/subproc_vec_env.py @@ -77,8 +77,8 @@ def __init__(self, env_fns, start_method=None): # Fork is not a thread safe method (see issue #217) # but is more user friendly (does not require to wrap the code in # a `if __name__ == "__main__":`) - fork_available = 'fork' in multiprocessing.get_all_start_methods() - start_method = 'fork' if fork_available else 'spawn' + forkserver_available = 'forkserver' in multiprocessing.get_all_start_methods() + start_method = 'forkserver' if forkserver_available else 'spawn' ctx = multiprocessing.get_context(start_method) self.remotes, self.work_remotes = zip(*[ctx.Pipe() for _ in range(n_envs)]) From 8a224330185980611f43e39cb6e7978f562a7f9e Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Tue, 6 Aug 2019 10:31:22 +0100 Subject: [PATCH 28/38] Disable non-thread safe start methods in tests; document default change --- docs/misc/changelog.rst | 5 +++++ stable_baselines/common/vec_env/subproc_vec_env.py | 10 +++++----- tests/test_vec_envs.py | 6 +++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index cbd0bb71f3..7f4c5e4b21 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -16,6 +16,11 @@ Breaking Changes: OpenMPI-dependent algorithms. See :ref:`installation notes ` and `Issue #430 `. +- SubprocVecEnv now defaults to a thread-safe start method, `forkserver` when + available and otherwise `spawn`. This may require application code be + wrapped in `if __name__ == '__main__'`. You can restore previous behavior + by explicitly setting `start_method = 'fork'`. See + `PR #428 `_. New Features: ^^^^^^^^^^^^^ diff --git a/stable_baselines/common/vec_env/subproc_vec_env.py b/stable_baselines/common/vec_env/subproc_vec_env.py index 7beb8e8ba6..daf1300f4b 100644 --- a/stable_baselines/common/vec_env/subproc_vec_env.py +++ b/stable_baselines/common/vec_env/subproc_vec_env.py @@ -55,11 +55,11 @@ class SubprocVecEnv(VecEnv): .. warning:: Only 'forkserver' and 'spawn' start methods are thread-safe, - which is important when TensorFlow - sessions or other non thread-safe libraries are used in the parent (see issue #217). - However, compared to 'fork' they incur a small start-up cost and have restrictions on - global variables. With those methods, - users must wrap the code in an ``if __name__ == "__main__":`` + which is important when TensorFlow sessions or other non thread-safe + libraries are used in the parent (see issue #217). However, compared to + 'fork' they incur a small start-up cost and have restrictions on + global variables. With those methods, users must wrap the code in an + ``if __name__ == "__main__":`` block. For more information, see the multiprocessing documentation. :param env_fns: ([Gym Environment]) Environments to run in subprocesses diff --git a/tests/test_vec_envs.py b/tests/test_vec_envs.py index 32d755b325..32be0309ba 100644 --- a/tests/test_vec_envs.py +++ b/tests/test_vec_envs.py @@ -265,7 +265,11 @@ def obs_assert(obs): def test_subproc_start_method(): - start_methods = [None] + multiprocessing.get_all_start_methods() + start_methods = [None] + # Only test thread-safe methods. Others may deadlock tests! (gh/428) + safe_methods = {'forkserver', 'spawn'} + available_methods = multiprocessing.get_all_start_methods() + start_methods += list(safe_methods.intersection(available_methods)) space = gym.spaces.Discrete(2) def obs_assert(obs): From 1d9322ae44c35d9b53e2bdf21b84b7b46bd33b60 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Tue, 6 Aug 2019 11:11:37 +0100 Subject: [PATCH 29/38] Rebalance tests --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bd42823d4..3a3736ec37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,14 +20,14 @@ matrix: - name: "Unit Tests a-d" env: TEST_GLOB="[a-d]*" - - name: "Unit Tests e-i" - env: TEST_GLOB="[e-i]*" + - name: "Unit Tests e-h" + env: TEST_GLOB="[e-h]*" - - name: "Unit Tests j-l" - env: TEST_GLOB="[j-l]*" + - name: "Unit Tests i-p" + env: TEST_GLOB="[i-p]*" - - name: "Unit Tests m-z" - env: TEST_GLOB="[m-z]*" + - name: "Unit Tests q-z" + env: TEST_GLOB="[q-z]*" - name: "Sphinx Documentation" script: From 9d1f1a175acea05047368db893c72559436afc6f Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Tue, 6 Aug 2019 13:46:36 +0100 Subject: [PATCH 30/38] Rebalance some more --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a3736ec37..32ea953dea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,17 +17,17 @@ script: matrix: include: # Big test suite. Run in parallel to decrease wall-clock time, and to avoid OOM error from leaks - - name: "Unit Tests a-d" - env: TEST_GLOB="[a-d]*" + - name: "Unit Tests a-g" + env: TEST_GLOB="[a-g]*" - - name: "Unit Tests e-h" - env: TEST_GLOB="[e-h]*" + - name: "Unit Tests h-m" + env: TEST_GLOB="[h-m]*" - - name: "Unit Tests i-p" - env: TEST_GLOB="[i-p]*" + - name: "Unit Tests m-t" + env: TEST_GLOB="[m-t]*" - - name: "Unit Tests q-z" - env: TEST_GLOB="[q-z]*" + - name: "Unit Tests t-z" + env: TEST_GLOB="[t-z]*" - name: "Sphinx Documentation" script: From c9bcd1b9f6f5124be96004cb2d190db3f6919fe0 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Tue, 6 Aug 2019 17:26:23 +0100 Subject: [PATCH 31/38] Rebalance, hopefully for the last time --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 32ea953dea..4f721b012e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,17 +17,17 @@ script: matrix: include: # Big test suite. Run in parallel to decrease wall-clock time, and to avoid OOM error from leaks - - name: "Unit Tests a-g" - env: TEST_GLOB="[a-g]*" + - name: "Unit Tests a-h" + env: TEST_GLOB="[a-h]*" - - name: "Unit Tests h-m" - env: TEST_GLOB="[h-m]*" + - name: "Unit Tests i-l" + env: TEST_GLOB="[i-l]*" - - name: "Unit Tests m-t" - env: TEST_GLOB="[m-t]*" + - name: "Unit Tests m-sa" + env: TEST_GLOB="[m-sa]*" - - name: "Unit Tests t-z" - env: TEST_GLOB="[t-z]*" + - name: "Unit Tests sb-z" + env: TEST_GLOB="[sb-z]*" - name: "Sphinx Documentation" script: From 150dc728042e1588a86ebffa68945bca07950611 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Tue, 6 Aug 2019 17:50:53 +0100 Subject: [PATCH 32/38] Fix globs --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f721b012e..d75319855a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,10 +24,10 @@ matrix: env: TEST_GLOB="[i-l]*" - name: "Unit Tests m-sa" - env: TEST_GLOB="[m-sa]*" + env: TEST_GLOB="{[m-r]*,sa*}" - name: "Unit Tests sb-z" - env: TEST_GLOB="[sb-z]*" + env: TEST_GLOB="{s[b-z]*,[t-z]*}" - name: "Sphinx Documentation" script: From 21bb414d7e7fa56e3741db80a71435d887bcec05 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Wed, 7 Aug 2019 10:52:10 +0200 Subject: [PATCH 33/38] Update docker cpu image: add coverage reporter for travis --- docker/Dockerfile.cpu | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu index a11619d9fd..077c55f17c 100644 --- a/docker/Dockerfile.cpu +++ b/docker/Dockerfile.cpu @@ -29,4 +29,11 @@ RUN \ ENV PATH=$VENV/bin:$PATH +RUN apt-get -y update && apt-get -y install curl jq + +# Codacy code coverage report: used for partial code coverage reporting +RUN cd $CODE_DIR &&\ + curl -Ls -o codacy-coverage-reporter "$(curl -Ls https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({name, browser_download_url} | select(.name | contains("codacy-coverage-reporter-linux"))) | .[0].browser_download_url')" &&\ + chmod +x codacy-coverage-reporter + CMD /bin/bash From d072313fd330c4e9fd8917f58aee85e7743e0f07 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 7 Aug 2019 10:52:20 +0100 Subject: [PATCH 34/38] Codacy partial upload --- .travis.yml | 12 +++++++++--- scripts/run_docker_cpu.sh | 2 +- scripts/run_docker_gpu.sh | 2 +- scripts/run_tests_travis.sh | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index d75319855a..67f966c223 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,15 +9,16 @@ services: - docker install: - - docker pull araffin/stable-baselines-cpu:v2.7.0 + - docker pull araffin/stable-baselines-cpu:v2.7.1 script: - ./scripts/run_tests_travis.sh "${TEST_GLOB}" -matrix: +jobs: include: # Big test suite. Run in parallel to decrease wall-clock time, and to avoid OOM error from leaks - - name: "Unit Tests a-h" + - stage: Test + name: "Unit Tests a-h" env: TEST_GLOB="[a-h]*" - name: "Unit Tests i-l" @@ -32,3 +33,8 @@ matrix: - name: "Sphinx Documentation" script: - 'docker run -it --rm --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install .[docs] && pushd docs/ && make clean && make html"' + + - stage: Codacy Trigger + script: + # When all test coverage reports have been uploaded, instruct Codacy to start analysis. + - 'docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind bash -c "/root/code/codacy-coverage-reporter final"' diff --git a/scripts/run_docker_cpu.sh b/scripts/run_docker_cpu.sh index 579f608ece..4a5c9f429c 100755 --- a/scripts/run_docker_cpu.sh +++ b/scripts/run_docker_cpu.sh @@ -8,5 +8,5 @@ echo $cmd_line docker run -it --rm --network host --ipc=host \ - --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu\ + --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu:v2.7.1 \ bash -c "cd /root/code/stable-baselines/ && $cmd_line" diff --git a/scripts/run_docker_gpu.sh b/scripts/run_docker_gpu.sh index 48a6eaa76c..734301cf00 100755 --- a/scripts/run_docker_gpu.sh +++ b/scripts/run_docker_gpu.sh @@ -8,5 +8,5 @@ echo $cmd_line docker run -it --runtime=nvidia --rm --network host --ipc=host \ - --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines\ + --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines:v2.7.1 \ bash -c "cd /root/code/stable-baselines/ && $cmd_line" diff --git a/scripts/run_tests_travis.sh b/scripts/run_tests_travis.sh index 539fadad0f..a97543703f 100755 --- a/scripts/run_tests_travis.sh +++ b/scripts/run_tests_travis.sh @@ -19,9 +19,9 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash -c "${BASH_CMD} && \ pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/test_${TEST_GLOB}" else - ${DOCKER_CMD} --env CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN ${DOCKER_IMAGE} \ + ${DOCKER_CMD} --env CODACY_PROJECT_TOKEN=${CODACY_PROJECT_TOKEN} ${DOCKER_IMAGE} \ bash -c "${BASH_CMD} && \ pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/test_${TEST_GLOB} && \ - python-codacy-coverage -r coverage.xml --token=$CODACY_PROJECT_TOKEN" + /root/code/codacy-coverage-reporter report -l python -r coverage.xml --partial" fi From 1cc301876af23abb7f38e24c1c0ce9fbb45be068 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 7 Aug 2019 10:58:13 +0100 Subject: [PATCH 35/38] Bump Docker image version --- .travis.yml | 8 +++++--- scripts/run_tests_travis.sh | 11 ++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 67f966c223..de9d28f86b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: python python: - "3.5" +env: DOCKER_IMAGE=araffin/stable-baselines-cpu:v2.7.1 + notifications: email: false @@ -9,7 +11,7 @@ services: - docker install: - - docker pull araffin/stable-baselines-cpu:v2.7.1 + - docker pull ${DOCKER_IMAGE} script: - ./scripts/run_tests_travis.sh "${TEST_GLOB}" @@ -32,9 +34,9 @@ jobs: - name: "Sphinx Documentation" script: - - 'docker run -it --rm --mount src=$(pwd),target=/root/code/stable-baselines,type=bind araffin/stable-baselines-cpu bash -c "cd /root/code/stable-baselines/ && pip install .[docs] && pushd docs/ && make clean && make html"' + - 'docker run -it --rm --mount src=$(pwd),target=/root/code/stable-baselines,type=bind ${DOCKER_IMAGE} bash -c "cd /root/code/stable-baselines/ && pip install .[docs] && pushd docs/ && make clean && make html"' - stage: Codacy Trigger script: # When all test coverage reports have been uploaded, instruct Codacy to start analysis. - - 'docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind bash -c "/root/code/codacy-coverage-reporter final"' + - 'docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind ${DOCKER_IMAGE} bash -c "/root/code/codacy-coverage-reporter final"' diff --git a/scripts/run_tests_travis.sh b/scripts/run_tests_travis.sh index a97543703f..787a41f4bb 100755 --- a/scripts/run_tests_travis.sh +++ b/scripts/run_tests_travis.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash DOCKER_CMD="docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind" -DOCKER_IMAGE="araffin/stable-baselines-cpu:v2.7.0" BASH_CMD="cd /root/code/stable-baselines/ && pip install tensorflow==1.13.2 gym==0.14.0" if [[ $# -ne 1 ]]; then @@ -9,6 +8,11 @@ if [[ $# -ne 1 ]]; then exit 1 fi +if [[ ${DOCKER_IMAGE} = "" ]]; then + echo "Need DOCKER_IMAGE environment variable to be set." + exit 1 +fi + TEST_GLOB=$1 set -e # exit immediately on any error @@ -19,6 +23,11 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash -c "${BASH_CMD} && \ pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/test_${TEST_GLOB}" else + if [[ ${CODACY_PROJECT_TOKEN} = "" ]]; then + echo "Need CODACY_PROJECT_TOKEN environment variable to be set." + exit 1 + fi + ${DOCKER_CMD} --env CODACY_PROJECT_TOKEN=${CODACY_PROJECT_TOKEN} ${DOCKER_IMAGE} \ bash -c "${BASH_CMD} && \ pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/test_${TEST_GLOB} && \ From 2b18787b786966be87af79aedb92447f8b046cdd Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 7 Aug 2019 11:01:45 +0100 Subject: [PATCH 36/38] Make Travis read environment variable --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index de9d28f86b..e573487cf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,9 @@ language: python python: - "3.5" -env: DOCKER_IMAGE=araffin/stable-baselines-cpu:v2.7.1 +env: + global: + - DOCKER_IMAGE=araffin/stable-baselines-cpu:v2.7.1 notifications: email: false From 1b5e73871b7d68ff91a39abf88c8695ed7aa4120 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 7 Aug 2019 11:38:54 +0100 Subject: [PATCH 37/38] Pass project token in --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e573487cf4..94fb1c27d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,4 +41,4 @@ jobs: - stage: Codacy Trigger script: # When all test coverage reports have been uploaded, instruct Codacy to start analysis. - - 'docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind ${DOCKER_IMAGE} bash -c "/root/code/codacy-coverage-reporter final"' + - 'docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind --env CODACY_PROJECT_TOKEN=${CODACY_PROJECT_TOKEN} ${DOCKER_IMAGE} bash -c "/root/code/codacy-coverage-reporter final"' From 06d1de8b75783c44ca2b244ed5dab9cfdd97265d Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Wed, 7 Aug 2019 14:43:10 +0200 Subject: [PATCH 38/38] Remove pip install and fix coverage final report --- .travis.yml | 2 +- scripts/run_tests_travis.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 94fb1c27d9..23efad4c39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,4 +41,4 @@ jobs: - stage: Codacy Trigger script: # When all test coverage reports have been uploaded, instruct Codacy to start analysis. - - 'docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind --env CODACY_PROJECT_TOKEN=${CODACY_PROJECT_TOKEN} ${DOCKER_IMAGE} bash -c "/root/code/codacy-coverage-reporter final"' + - 'docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind --env CODACY_PROJECT_TOKEN=${CODACY_PROJECT_TOKEN} ${DOCKER_IMAGE} bash -c "cd /root/code/stable-baselines/ && /root/code/codacy-coverage-reporter final"' diff --git a/scripts/run_tests_travis.sh b/scripts/run_tests_travis.sh index 787a41f4bb..c753e16ce9 100755 --- a/scripts/run_tests_travis.sh +++ b/scripts/run_tests_travis.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash DOCKER_CMD="docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines,type=bind" -BASH_CMD="cd /root/code/stable-baselines/ && pip install tensorflow==1.13.2 gym==0.14.0" +BASH_CMD="cd /root/code/stable-baselines/" if [[ $# -ne 1 ]]; then echo "usage: $0 " @@ -33,4 +33,3 @@ else pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/test_${TEST_GLOB} && \ /root/code/codacy-coverage-reporter report -l python -r coverage.xml --partial" fi -