openai / gym-http-api

API to access OpenAI Gym from other languages via HTTP
MIT License
293 stars 142 forks source link

Status: Archive (code is provided as-is, no updates expected)

gym-http-api

This project provides a local REST API to the gym open-source library, allowing development in languages other than python.

A python client is included, to demonstrate how to interact with the server.

Contributions of clients in other languages are welcomed!

Installation

To download the code and install the requirements, you can run the following shell commands:

git clone https://github.com/openai/gym-http-api
cd gym-http-api
pip install -r requirements.txt

Getting started

This code is intended to be run locally by a single user. The server runs in python. You can implement your own HTTP clients using any language; a demo client written in python is provided to demonstrate the idea.

To start the server from the command line, run this:

python gym_http_server.py

In a separate terminal, you can then try running the example python agent and see what happens:

python example_agent.py

The example lua agent behaves very similarly:

cd binding-lua
lua example_agent.lua

You can also write code like this to create your own client, and test it out by creating a new environment. For example, in python:

remote_base = 'http://127.0.0.1:5000'
client = Client(remote_base)

env_id = 'CartPole-v0'
instance_id = client.env_create(env_id)
client.env_step(instance_id, 0)

Testing

This repository contains integration tests, using the python client implementation to send requests to the local server. They can be run using the nose2 framework. From a shell (such as bash) you can run nose2 directly:

cd gym-http-api
nose2

API specification

Contributors

See the [contributors page] (https://github.com/openai/gym-http-api/graphs/contributors)