Skip to content

Commit

Permalink
Switch to Docker for tests (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdb committed Aug 10, 2016
1 parent be1eeec commit fabb897
Show file tree
Hide file tree
Showing 8 changed files with 2,076 additions and 59 deletions.
1 change: 1 addition & 0 deletions .dockerignore
@@ -0,0 +1 @@
.tox
51 changes: 8 additions & 43 deletions .travis.yml
@@ -1,50 +1,15 @@
language: python
python:
- "2.7"
- "3.4"
dist: trusty
sudo: required sudo: required
cache: language: python
apt: true services:
pip: true - docker
addons:
apt:
sources:
- george-edison55-precise-backports # cmake 3.2.3
- deadsnakes
packages:
- cmake
- cmake-data
- python-dev
- python3.4-dev
- swig
- libav-tools
- python-numpy
- libboost-all-dev
- libsdl2-dev
- libjpeg-dev
- zlib1g-dev
- libblas-dev
- liblapack-dev
- gfortran
- python-opengl
before_install: before_install:
# Start an X server so rendering works. # Prime the cache. We currently manually keep this synced.
- Xvfb :12 -screen 0 800x600x24 +extension RANDR & - docker pull quay.io/openai/gym:test

- docker build -f test.dockerfile -t quay.io/openai/gym:test .
script:
# In a pull request, there are no secrets, and hence no MuJoCo: # In a pull request, there are no secrets, and hence no MuJoCo:
# https://docs.travis-ci.com/user/pull-requests#Security-Restrictions-when-testing-Pull-Requests. # https://docs.travis-ci.com/user/pull-requests#Security-Restrictions-when-testing-Pull-Requests.
- '[ -z ${MUJOCO_KEY_BUNDLE+x} ] || ( mkdir -p ~/.mujoco && curl https://openai-public.s3-us-west-2.amazonaws.com/mujoco/$MUJOCO_KEY_BUNDLE.tar.gz | tar xz -C ~/.mujoco )' - docker run -e MUJOCO_KEY_BUNDLE="${MUJOCO_KEY_BUNDLE:-}" quay.io/openai/gym:test tox

# Without this line, Travis has fork()s fail with an out of memory
# error. (These fork()s are for spawning the subprocess for video
# recording.) We should debug the memory usage at some stage, but
# simply setting overcommit is a good starting point.
- sudo sysctl -w vm.overcommit_memory=1
env:
- DISPLAY=:12
install: travis_wait pip install -r requirements_dev.txt
script: nose2


notifications: notifications:
slack: slack:
Expand Down
24 changes: 13 additions & 11 deletions Dockerfile
Expand Up @@ -2,13 +2,7 @@
FROM ubuntu:14.04 FROM ubuntu:14.04


RUN apt-get update \ RUN apt-get update \
&& apt-get install -y xorg-dev \ && apt-get install -y libav-tools \
libgl1-mesa-dev \
xvfb \
libxinerama1 \
libxcursor1 \
libglu1-mesa \
libav-tools \
python-numpy \ python-numpy \
python-scipy \ python-scipy \
python-pyglet \ python-pyglet \
Expand All @@ -17,16 +11,24 @@ RUN apt-get update \
libjpeg-dev \ libjpeg-dev \
curl \ curl \
cmake \ cmake \
&& apt-get clean \ swig \
&& rm -rf /var/lib/apt/lists/* \ python-opengl \
&& easy_install pip libboost-all-dev \
libsdl2-dev \
wget \
unzip \
git \
xpra \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& easy_install pip


WORKDIR /usr/local/gym WORKDIR /usr/local/gym
RUN mkdir gym && touch gym/__init__.py RUN mkdir gym && touch gym/__init__.py
COPY ./gym/version.py ./gym COPY ./gym/version.py ./gym
COPY ./requirements.txt . COPY ./requirements.txt .
COPY ./setup.py . COPY ./setup.py .
RUN pip install -r requirements.txt RUN pip install -e .[all]


# Finally, upload our actual code! # Finally, upload our actual code!
COPY . /usr/local/gym COPY . /usr/local/gym
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Expand Up @@ -4,9 +4,15 @@ install:
pip install -r requirements.txt pip install -r requirements.txt


test: test:
nose2 docker build -f test.dockerfile -t quay.io/openai/gym:test .


upload: upload:
rm -rf dist rm -rf dist
python setup.py sdist python setup.py sdist
twine upload dist/* twine upload dist/*

docker-build:
docker build -t quay.io/openai/gym .

docker-run:
docker run -ti quay.io/openai/gym bash
24 changes: 22 additions & 2 deletions bin/docker_entrypoint
Expand Up @@ -4,9 +4,29 @@


set -e set -e


# Set up display; otherwise rendering will cause segfaults path=$(cd $(dirname "$0") && pwd)

[ -z ${MUJOCO_KEY_BUNDLE+x} ] || ( mkdir -p ~/.mujoco && curl https://openai-public.s3-us-west-2.amazonaws.com/mujoco/$MUJOCO_KEY_BUNDLE.tar.gz | tar xz -C ~/.mujoco )

# Set up display; otherwise rendering will fail
rm -f /tmp/.X12-lock rm -f /tmp/.X12-lock
Xvfb :12 -screen 0 800x600x24 +extension RANDR 2>/dev/null & "$path/../vendor/Xdummy" :12 &
export DISPLAY=:12 export DISPLAY=:12


# Wait for the file to come up
display=12
file="/tmp/.X11-unix/X$display"
for i in $(seq 1 10); do
if [ -e "$file" ]; then
break
fi

echo "Waiting for $file to be created (try $i/10)"
sleep "$i"
done
if ! [ -e "$file" ]; then
echo "Timing out: $file was not created"
exit 1
fi

exec "$@" exec "$@"
42 changes: 42 additions & 0 deletions test.dockerfile
@@ -0,0 +1,42 @@
# A Dockerfile that sets up a full Gym install
FROM ubuntu:14.04

RUN apt-get update \
&& apt-get install -y libav-tools \
python-numpy \
python-scipy \
python-pyglet \
python-setuptools \
libpq-dev \
libjpeg-dev \
curl \
cmake \
swig \
python-opengl \
libboost-all-dev \
libsdl2-dev \
wget \
unzip \
git \
xpra \
python3-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& easy_install pip

WORKDIR /usr/local/gym
RUN mkdir gym && touch gym/__init__.py
COPY ./gym/version.py ./gym
COPY ./requirements.txt .
COPY ./setup.py .
COPY ./tox.ini .

RUN pip install tox
# Install the relevant dependencies. Keep printing so Travis knows we're alive.
RUN ["bash", "-c", "( while true; do echo '.'; sleep 60; done ) & tox --notest"]

# Finally, upload our actual code!
COPY . /usr/local/gym

ENTRYPOINT ["/usr/local/gym/bin/docker_entrypoint"]
CMD ["tox"]
30 changes: 28 additions & 2 deletions tox.ini
Expand Up @@ -12,8 +12,21 @@ passenv=DISPLAY TRAVIS*
deps = deps =
nose2 nose2
mock mock
atari_py>=0.0.17
Pillow
PyOpenGL
pachi-py>=0.0.19
box2d-py
PyOpenGL
doom_py>=0.0.11
mujoco_py>=0.4.3
keras
theano
numpy>=1.10.4
requests>=2.0
six
pyglet>=1.2.0
commands = commands =
pip install -e .[all]
nose2 {posargs} nose2 {posargs}


[testenv:py27] [testenv:py27]
Expand All @@ -22,6 +35,19 @@ passenv=DISPLAY TRAVIS*
deps = deps =
nose2 nose2
mock mock
atari_py>=0.0.17
Pillow
PyOpenGL
pachi-py>=0.0.19
box2d-py
PyOpenGL
doom_py>=0.0.11
mujoco_py>=0.4.3
keras
theano
numpy>=1.10.4
requests>=2.0
six
pyglet>=1.2.0
commands = commands =
pip install -e .[all]
nose2 {posargs} nose2 {posargs}

0 comments on commit fabb897

Please sign in to comment.