Skip to content

Commit

Permalink
Cleanup, removal of unmaintained code (#836)
Browse files Browse the repository at this point in the history
* add dtype to Box

* remove board_game, debugging, safety, parameter_tuning environments

* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder

* Improve render("human"), now resizable, closable window.

* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods

* CubeCrash unit test environment

* followup fixes

* MemorizeDigits unit test envrionment

* refactored spaces a bit
fixed indentation
disabled test_env_semantics

* fix unit tests

* fixes

* CubeCrash, MemorizeDigits tested

* gym backwards compatibility patch

* gym backwards compatibility, followup fixes

* changelist, add spaces to main namespaces

* undo_logger_setup for backwards compat

* remove configuration.py
  • Loading branch information
joschu committed Jan 26, 2018
1 parent 6af4a5b commit 4c460ba
Show file tree
Hide file tree
Showing 113 changed files with 945 additions and 8,877 deletions.
27 changes: 13 additions & 14 deletions README.rst
Expand Up @@ -4,7 +4,7 @@ OpenAI Gym
**OpenAI Gym is a toolkit for developing and comparing reinforcement learning algorithms.** This is the ``gym`` open-source library, which gives you access to a standardized set of environments.

.. image:: https://travis-ci.org/openai/gym.svg?branch=master
:target: https://travis-ci.org/openai/gym
:target: https://travis-ci.org/openai/gym

`See What's New section below <#what-s-new>`_

Expand Down Expand Up @@ -126,7 +126,7 @@ fake display. The easiest way to do this is by running under

.. code:: shell
xvfb-run -s "-screen 0 1400x900x24" bash
xvfb-run -s "-screen 0 1400x900x24" bash
Installing dependencies for specific environments
-------------------------------------------------
Expand Down Expand Up @@ -173,18 +173,6 @@ The Atari environments are a variety of Atari video games. If you didn't do the
This will install ``atari-py``, which automatically compiles the `Arcade Learning Environment <http://www.arcadelearningenvironment.org/>`_. This can take quite a while (a few minutes on a decent laptop), so just be prepared.

Board games
-----------

The board game environments are a variety of board games. If you didn't do the full install, you can install dependencies via ``pip install -e '.[board_game]'`` (you'll need ``cmake`` installed) and then get started as follow:

.. code:: python
import gym
env = gym.make('Go9x9-v0')
env.reset()
env.render()
Box2d
-----------

Expand Down Expand Up @@ -261,6 +249,17 @@ We are using `pytest <http://doc.pytest.org>`_ for tests. You can run them via:
What's new
==========

- 2018-01-25: Made some aesthetic improvements and removed unmaintained parts of gym. This may seem like a downgrade in functionality, but it is actually a long-needed cleanup in preparation for some great new things that will be released in the next month.

+ Now your `Env` and `Wrapper` subclasses should define `step`, `reset`, `render`, `close`, `seed` rather than underscored method names.
+ Removed the `board_game`, `debugging`, `safety`, `parameter_tuning` environments since they're not being maintained by us at OpenAI. We encourage authors and users to create new repositories for these environments.
+ Changed `MultiDiscrete` action space to range from `[0, ..., n-1]` rather than `[a, ..., b-1]`.
+ No more `render(close=True)`, use env-specific methods to close the rendering.
+ Removed `scoreboard` directory, since site doesn't exist anymore.
+ Moved `gym/monitoring` to `gym/wrappers/monitoring`
+ Add `dtype` to `Space`.
+ Not using python's built-in module anymore, using `gym.logger`

- 2018-01-24: All continuous control environments now use mujoco_py >= 1.50.
Versions have been updated accordingly to -v2, e.g. HalfCheetah-v2. Performance
should be similar (see https://github.com/openai/gym/pull/834) but there are likely
Expand Down
11 changes: 3 additions & 8 deletions examples/agents/cem.py
@@ -1,13 +1,9 @@
from __future__ import print_function

import gym
from gym import wrappers
import logging
from gym import wrappers, logger
import numpy as np
try:
import cPickle as pickle
except ImportError:
import pickle
from six.moves import cPickle
import json, sys, os
from os import path
from _policies import BinaryActionLinearPolicy # Different file so it can be unpickled
Expand Down Expand Up @@ -48,8 +44,7 @@ def do_rollout(agent, env, num_steps, render=False):
return total_rew, t+1

if __name__ == '__main__':
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logger.set_level(logger.INFO)

parser = argparse.ArgumentParser()
parser.add_argument('--display', action='store_true')
Expand Down
25 changes: 18 additions & 7 deletions examples/agents/keyboard_agent.py
@@ -1,18 +1,19 @@
#!/usr/bin/env python
from __future__ import print_function

import sys, gym
import sys, gym, time

#
# Test yourself as a learning agent! Pass environment name as a command-line argument.
# Test yourself as a learning agent! Pass environment name as a command-line argument, for example:
#
# python keyboard_agent.py SpaceInvadersNoFrameskip-v4
#

env = gym.make('LunarLander-v2' if len(sys.argv)<2 else sys.argv[1])

if not hasattr(env.action_space, 'n'):
raise Exception('Keyboard agent only supports discrete action spaces')
ACTIONS = env.action_space.n
ROLLOUT_TIME = 1000
SKIP_CONTROL = 0 # Use previous control decision SKIP_CONTROL times, that's how you
# can test what skip is still usable.

Expand Down Expand Up @@ -44,26 +45,36 @@ def rollout(env):
human_wants_restart = False
obser = env.reset()
skip = 0
for t in range(ROLLOUT_TIME):
total_reward = 0
total_timesteps = 0
while 1:
if not skip:
#print("taking action {}".format(human_agent_action))
a = human_agent_action
total_timesteps += 1
skip = SKIP_CONTROL
else:
skip -= 1

obser, r, done, info = env.step(a)
env.render()
if r != 0:
print("reward %0.3f" % r)
total_reward += r
window_still_open = env.render()
if window_still_open==False: return False
if done: break
if human_wants_restart: break
while human_sets_pause:
env.render()
import time
time.sleep(0.1)
time.sleep(0.1)
print("timesteps %i reward %0.2f" % (total_timesteps, total_reward))

print("ACTIONS={}".format(ACTIONS))
print("Press keys 1 2 3 ... to take actions 1 2 3 ...")
print("No keys pressed is taking action 0")

while 1:
rollout(env)
window_still_open = rollout(env)
if window_still_open==False: break

18 changes: 3 additions & 15 deletions examples/agents/random_agent.py
@@ -1,10 +1,8 @@
import argparse
import logging
import sys

import gym
from gym import wrappers

from gym import wrappers, logger

class RandomAgent(object):
"""The world's simplest agent!"""
Expand All @@ -19,19 +17,9 @@ def act(self, observation, reward, done):
parser.add_argument('env_id', nargs='?', default='CartPole-v0', help='Select the environment to run')
args = parser.parse_args()

# Call `undo_logger_setup` if you want to undo Gym's logger setup
# and configure things manually. (The default should be fine most
# of the time.)
gym.undo_logger_setup()
logger = logging.getLogger()
formatter = logging.Formatter('[%(asctime)s] %(message)s')
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(formatter)
logger.addHandler(handler)

# You can set the level to logging.DEBUG or logging.WARN if you
# You can set the level to logger.DEBUG or logger.WARN if you
# want to change the amount of output.
logger.setLevel(logging.INFO)
logger.set_level(logger.INFO)

env = gym.make(args.env_id)

Expand Down
44 changes: 0 additions & 44 deletions examples/agents/tabular_q_agent.py

This file was deleted.

36 changes: 0 additions & 36 deletions examples/scripts/play_go

This file was deleted.

51 changes: 6 additions & 45 deletions gym/__init__.py
@@ -1,56 +1,17 @@
import distutils.version
import logging
import os
import sys
import warnings

from gym import error
from gym.configuration import logger_setup, undo_logger_setup
from gym.utils import reraise
from gym.version import VERSION as __version__

logger = logging.getLogger(__name__)

# Do this before importing any other gym modules, as most of them import some
# dependencies themselves.
def sanity_check_dependencies():
import numpy
import requests
import six

if distutils.version.LooseVersion(numpy.__version__) < distutils.version.LooseVersion('1.10.4'):
logger.warn("You have 'numpy' version %s installed, but 'gym' requires at least 1.10.4. HINT: upgrade via 'pip install -U numpy'.", numpy.__version__)

if distutils.version.LooseVersion(requests.__version__) < distutils.version.LooseVersion('2.0'):
logger.warn("You have 'requests' version %s installed, but 'gym' requires at least 2.0. HINT: upgrade via 'pip install -U requests'.", requests.__version__)

# We automatically configure a logger with a simple stderr handler. If
# you'd rather customize logging yourself, run undo_logger_setup.
#
# (Note: this code runs before importing the rest of gym, since we may
# print a warning at load time.)
#
# It's generally not best practice to configure the logger in a
# library. We choose to do so because, empirically, many of our users
# are unfamiliar with Python's logging configuration, and never find
# their way to enabling our logging. Users who are aware of how to
# configure Python's logging do have to accept a bit of incovenience
# (generally by caling `gym.undo_logger_setup()`), but in exchange,
# the library becomes much more usable for the uninitiated.
#
# Gym's design goal generally is to be simple and intuitive, and while
# the tradeoff is definitely not obvious in this case, we've come down
# on the side of auto-configuring the logger.

if not os.environ.get('GYM_NO_LOGGER_SETUP'):
logger_setup()
del logger_setup

sanity_check_dependencies()

from gym.core import Env, Space, Wrapper, ObservationWrapper, ActionWrapper, RewardWrapper
from gym.benchmarks import benchmark_spec
from gym.envs import make, spec
from gym.scoreboard.api import upload
from gym import wrappers
from gym import wrappers, spaces, logger

def undo_logger_setup():
warnings.warn("gym.undo_logger_setup is deprecated. gym no longer modifies the global logging configuration")

__all__ = ["Env", "Space", "Wrapper", "make", "spec", "upload", "wrappers"]
__all__ = ["Env", "Space", "Wrapper", "make", "spec", "wrappers"]

0 comments on commit 4c460ba

Please sign in to comment.