From 7ac04a49822de44fefcaf76431d3ec813915cb2c Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Wed, 27 Apr 2016 18:09:36 -0700 Subject: [PATCH 01/13] Fix Travis and tox configs --- .travis.yml | 19 +++++++++++++++++++ tox.ini | 1 + 2 files changed, 20 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6396b1d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +dist: trusty +sudo: required +cache: + apt: true +language: python +addons: + apt: + packages: + - python-dev +python: + - "2.7" + - "3.5" +install: pip install tox-travis +script: tox + +notifications: + slack: + secure: h/Mxm8K+avH/2W0818zCHmLloRPMFN4NJL01+VShvAkH80/acfjeq/+mMdWXXPL/oOB6kSHDk+GDhwR6+s03ZcPMn5INTFvFYqUc6UWmT+NXtOPxGTN0xda6MdYUkWQUKaMyjFrweZQOMOASFBIzPOq4XeVbM5aB8s4EJhnfAcYZhp/idwKbToVihN4KZgxlvZIFc8iEp1o9uSl5qrsaeYYYXRkb6mauacAwOo4/Chu+cOnoLUOnvhBFE3rV3doDNrbnoalO8XiExtgx5CIAYWrlMni7r2Q+LlzgwdyTH19ZtybPxJTZIIWSBQ2UtcoYdIEDcc36GcUwz1VUGg32mLJJnY2xw80CWR4ixFPpLwwP5Y99WTn8v094B4nmFTWOwNWXp3EkqtTN9XcJoRBqXB5ArucIPqrx57dOCljSKx22gL6WaF2p3stSAxIGFektGyGnisaELrFZG1C63aHoUPicj3gUlijmAoUmYaDRf6P1wnpXqBpKDAWWhAMSatvx1ekmEJgR7OQklQnnfjx9kENDUygNUWS4IQwN2qYieuzHFL3of7/30mTM43+Vt/vWN8GI7j01BXu6FNGGloHxjH1pt3bLP/+uj5BJsT2HWF+Z8XR4VE6cyVuKsQAFgCXwOkoDHALbcwsspONDIt/9ixkesgh1oFt4CzU3UuU5wYs= + on_success: change diff --git a/tox.ini b/tox.ini index 77b0842..7330eaa 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ envlist = py27, py35 [testenv:py35] whitelist_externals=make +install_command=echo {packages} deps = nose2 numpy From 53d28f9292cd3c5a635dc6dbe32dda54ad7f67c4 Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Wed, 27 Apr 2016 18:26:24 -0700 Subject: [PATCH 02/13] Fix import path --- atari_py/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atari_py/__init__.py b/atari_py/__init__.py index 6dd7b48..f12d58d 100644 --- a/atari_py/__init__.py +++ b/atari_py/__init__.py @@ -1,4 +1,4 @@ -from ale_python_interface import * +from .ale_python_interface import * import os def _game_dir(): @@ -9,4 +9,4 @@ def get_game_path(game_name): def list_games(): files = os.listdir(_game_dir()) - return [os.path.basename(f).split(".")[0] for f in files] \ No newline at end of file + return [os.path.basename(f).split(".")[0] for f in files] From 510214295d52e41412cf0b6e39ad109034788313 Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Wed, 27 Apr 2016 18:27:01 -0700 Subject: [PATCH 03/13] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3670684..f4b68c1 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def run(self): DistutilsBuild.run(self) setup(name='atari-py', - version='0.0.14', + version='0.0.15', description='Python bindings to Atari games', url='https://github.com/openai/atari-py', author='OpenAI', From 09f1cea7982fa6313c43c0e04d0a9263fdf64934 Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Wed, 27 Apr 2016 18:52:31 -0700 Subject: [PATCH 04/13] Add smoke test --- atari_py/tests/test_smoke.py | 8 ++++++++ tox.ini | 1 + 2 files changed, 9 insertions(+) create mode 100644 atari_py/tests/test_smoke.py diff --git a/atari_py/tests/test_smoke.py b/atari_py/tests/test_smoke.py new file mode 100644 index 0000000..80fa036 --- /dev/null +++ b/atari_py/tests/test_smoke.py @@ -0,0 +1,8 @@ +import atari_py + +def test_smoke(): + pong_path = atari_py.get_game_path('pong') + ale = atari_py.ALEInterface() + ale.loadROM(pong_path) + action_set = ale.getMinimalActionSet() + ale.act(action_set[0]) diff --git a/tox.ini b/tox.ini index 7330eaa..65e5a79 100644 --- a/tox.ini +++ b/tox.ini @@ -16,6 +16,7 @@ commands = make python setup.py build pip install -e . + nose2 python setup.py clean --all make clean From d74554c0e2e611017071ccdc7720d58f71c35d6c Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Wed, 27 Apr 2016 18:56:16 -0700 Subject: [PATCH 05/13] Ensure ROM path is a byte array --- atari_py/ale_python_interface.py | 3 ++- setup.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/atari_py/ale_python_interface.py b/atari_py/ale_python_interface.py index fd2280a..02c812e 100644 --- a/atari_py/ale_python_interface.py +++ b/atari_py/ale_python_interface.py @@ -7,6 +7,7 @@ import numpy as np from numpy.ctypeslib import as_ctypes import os +import six ale_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__), 'ale_interface/build/libale_c.so')) @@ -134,7 +135,7 @@ def setFloat(self, key, value): ale_lib.setFloat(self.obj, key, value) def loadROM(self, rom_file): - ale_lib.loadROM(self.obj, rom_file) + ale_lib.loadROM(self.obj, six.b(rom_file)) def act(self, action): return ale_lib.act(self.obj, int(action)) diff --git a/setup.py b/setup.py index f4b68c1..514cc2e 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,6 @@ def run(self): packages=['atari_py'], package_data={'atari_py': package_data}, cmdclass={'build': Build}, - install_requires=['numpy'], + install_requires=['numpy', 'six'], tests_require=['nose2'] ) From e8a5dd7906a55e48110b3889cf12b69f557f13cf Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Wed, 27 Apr 2016 18:58:38 -0700 Subject: [PATCH 06/13] Extend the smoke test to include screen capture --- atari_py/tests/test_smoke.py | 8 ++++++++ tox.ini | 1 + 2 files changed, 9 insertions(+) diff --git a/atari_py/tests/test_smoke.py b/atari_py/tests/test_smoke.py index 80fa036..3fe28bc 100644 --- a/atari_py/tests/test_smoke.py +++ b/atari_py/tests/test_smoke.py @@ -1,8 +1,16 @@ import atari_py +import numpy as np def test_smoke(): pong_path = atari_py.get_game_path('pong') ale = atari_py.ALEInterface() ale.loadROM(pong_path) action_set = ale.getMinimalActionSet() + + # Test stepping ale.act(action_set[0]) + + # Test screen capture + (screen_width,screen_height) = ale.getScreenDims() + arr = np.zeros((screen_height, screen_width, 4), dtype=np.uint8) + ale.getScreenRGB(arr) diff --git a/tox.ini b/tox.ini index 65e5a79..80a7f32 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ envlist = py27, py35 [testenv:py35] whitelist_externals=make + echo install_command=echo {packages} deps = nose2 From 2dc7bcb6b68ecc0822301d44d0a56f01f281114f Mon Sep 17 00:00:00 2001 From: Bastiaan Quast Date: Thu, 28 Apr 2016 16:20:08 +0200 Subject: [PATCH 07/13] add colon before code block --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76ae5f4..d0de251 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ To install via pip, run: ```pip install atari-py``` -Alternatively, you can install using setuptools using +Alternatively, you can install using setuptools using: ```python setup.py install``` From 6a961bcdc9f93db3110e3c551f3d38844747d3f9 Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Wed, 27 Apr 2016 18:58:54 -0700 Subject: [PATCH 08/13] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 514cc2e..ea05943 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def run(self): DistutilsBuild.run(self) setup(name='atari-py', - version='0.0.15', + version='0.0.16', description='Python bindings to Atari games', url='https://github.com/openai/atari-py', author='OpenAI', From ef3e590f256d83828b88e01c0d15e50cef8c8615 Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Thu, 28 Apr 2016 11:17:47 -0700 Subject: [PATCH 09/13] Install nose2 inside the virtualenv manually --- tox.ini | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 80a7f32..fe17214 100644 --- a/tox.ini +++ b/tox.ini @@ -10,10 +10,8 @@ envlist = py27, py35 whitelist_externals=make echo install_command=echo {packages} -deps = - nose2 - numpy commands = + pip install numpy nose2 make python setup.py build pip install -e . From 298346ee3b5ce642e3f2d585e6e154602abbb6f8 Mon Sep 17 00:00:00 2001 From: Greg Brockman Date: Thu, 28 Apr 2016 14:48:38 -0700 Subject: [PATCH 10/13] Add Travis badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d0de251..97f2fb3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # atari_py +[![Build Status](https://travis-ci.org/openai/atari-py.svg?branch=master)](https://travis-ci.org/openai/atari-py) + A packaged and slightly-modified version of [https://github.com/bbitmaster/ale_python_interface](https://github.com/bbitmaster/ale_python_interface). ## Installation From 4da8e5d1d3011bb0f326365e674ea037bd25ac14 Mon Sep 17 00:00:00 2001 From: Jonas Schneider Date: Thu, 28 Apr 2016 15:06:07 -0700 Subject: [PATCH 11/13] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ea05943..83b00d4 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def run(self): DistutilsBuild.run(self) setup(name='atari-py', - version='0.0.16', + version='0.0.17', description='Python bindings to Atari games', url='https://github.com/openai/atari-py', author='OpenAI', From 92b85a4d1af54b86d0cdf27c5edd47fc711f1553 Mon Sep 17 00:00:00 2001 From: Greg Brockman Date: Sat, 7 May 2016 22:32:02 -0700 Subject: [PATCH 12/13] Build on more cores --- setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 83b00d4..3bf3c5b 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +import multiprocessing import os from setuptools import setup import subprocess @@ -9,13 +10,15 @@ class Build(DistutilsBuild): def run(self): + cores_to_use = max(1, multiprocessing.cpu_count() - 1) + cmd = ['make', 'build', '-C', 'atari_py/ale_interface', '-j', str(cores_to_use)] try: - subprocess.check_call(['make', 'build', '-C', 'atari_py/ale_interface']) + subprocess.check_call(cmd) except subprocess.CalledProcessError as e: sys.stderr.write("Could not build atari-py: %s. (HINT: are you sure cmake is installed? You might also be missing a library. Atari-py requires: zlib [installable as 'apt-get install zlib1g-dev' on Ubuntu].)\n" % e) raise except OSError as e: - sys.stderr.write("Unable to execute 'make build -C atari_py/ale_interface'. HINT: are you sure `make` is installed?\n") + sys.stderr.write("Unable to execute '{}'. HINT: are you sure `make` is installed?\n".format(' '.join(cmd))) raise DistutilsBuild.run(self) From d63ced3941f25d289eb49234898f58281183d4ea Mon Sep 17 00:00:00 2001 From: Greg Brockman Date: Sat, 7 May 2016 22:32:21 -0700 Subject: [PATCH 13/13] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3bf3c5b..dde650f 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def run(self): DistutilsBuild.run(self) setup(name='atari-py', - version='0.0.17', + version='0.0.18', description='Python bindings to Atari games', url='https://github.com/openai/atari-py', author='OpenAI',