From 257a40ef4bd08d2ec2cd2d64b4c842fb36ceafa9 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 9 May 2020 23:10:49 +0200 Subject: [PATCH] Add Gitlab CI (#12) * Test gitlab-ci * Try different image * Add pytest and doc build * Fix command * Fix image used for CI * Seperate pytest builds * Fix weird seg fault in docker image due to FakeImageEnv * Fix make command * [ci skip] Add space in the badges * Fix CI failures * Re-install opencv * Use opencv-headless * Test with new docker image --- .gitlab-ci.yml | 14 ++++++++++++++ Dockerfile | 2 ++ README.md | 5 +---- docs/misc/changelog.rst | 1 + stable_baselines3/common/identity_env.py | 6 +++--- tests/test_distributions.py | 4 ++-- 6 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..e422082 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +image: stablebaselines/stable-baselines3-cpu:0.6.0a7 + +type-check: + script: + - make type + +pytest: + script: + # MKL_THREADING_LAYER=GNU to avoid MKL_THREADING_LAYER=INTEL incompatibility error + - MKL_THREADING_LAYER=GNU make pytest + +doc-build: + script: + - make doc diff --git a/Dockerfile b/Dockerfile index d573be7..be8eb57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,8 @@ COPY ./stable_baselines3/version.txt ${CODE_DIR}/stable-baselines3/stable_baseli RUN \ cd ${CODE_DIR}/stable-baselines3 3&& \ pip install -e .[extra,tests,docs] && \ + # Use headless version for docker + pip install opencv-python-headless && \ rm -rf $HOME/.cache/pip diff --git a/README.md b/README.md index f14a919..c3e9850 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,7 @@ - +[![pipeline status](https://gitlab.com/araffin/stable-baselines3/badges/master/pipeline.svg)](https://gitlab.com/araffin/stable-baselines3/-/commits/master) [![Documentation Status](https://readthedocs.org/projects/stable-baselines/badge/?version=master)](https://stable-baselines3.readthedocs.io/en/master/?badge=master) [![coverage report](https://gitlab.com/araffin/stable-baselines3/badges/master/coverage.svg)](https://gitlab.com/araffin/stable-baselines3/-/commits/master) -[![Documentation Status](https://readthedocs.org/projects/stable-baselines/badge/?version=master)](https://stable-baselines3.readthedocs.io/en/master/?badge=master) **WARNING: Stable Baselines3 is currently in a beta version, breaking changes may occur before 1.0 is released** diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index baa9919..21d5f1f 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -22,6 +22,7 @@ Bug Fixes: ^^^^^^^^^^ - Fixed a bug that prevented model trained on cpu to be loaded on gpu - Fixed version number that had a new line included +- Fixed weird seg fault in docker image due to FakeImageEnv by reducing screen size Deprecations: ^^^^^^^^^^^^^ diff --git a/stable_baselines3/common/identity_env.py b/stable_baselines3/common/identity_env.py index e1bb9c2..2f3ce28 100644 --- a/stable_baselines3/common/identity_env.py +++ b/stable_baselines3/common/identity_env.py @@ -121,9 +121,9 @@ class FakeImageEnv(Env): :param discrete: (bool) """ def __init__(self, action_dim: int = 6, - screen_height: int = 210, - screen_width: int = 160, - n_channels: int = 3, + screen_height: int = 84, + screen_width: int = 84, + n_channels: int = 1, discrete: bool = True): self.observation_space = Box(low=0, high=255, shape=(screen_height, screen_width, diff --git a/tests/test_distributions.py b/tests/test_distributions.py index 1f340bb..e9041f8 100644 --- a/tests/test_distributions.py +++ b/tests/test_distributions.py @@ -55,8 +55,8 @@ def test_sde_distribution(): dist = dist.proba_distribution(deterministic_actions, log_std, state) actions = dist.get_actions() - assert th.allclose(actions.mean(), dist.distribution.mean.mean(), rtol=1e-3) - assert th.allclose(actions.std(), dist.distribution.scale.mean(), rtol=1e-3) + assert th.allclose(actions.mean(), dist.distribution.mean.mean(), rtol=2e-3) + assert th.allclose(actions.std(), dist.distribution.scale.mean(), rtol=2e-3) # TODO: analytical form for squashed Gaussian?