- Notifications
You must be signed in to change notification settings - Fork137
API to access OpenAI Gym from other languages via HTTP
License
openai/gym-http-api
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Status: Archive (code is provided as-is, no updates expected)
This project provides a local REST API to thegym 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!
To download the code and install the requirements, you can run the following shell commands:
git clone https://github.com/openai/gym-http-apicd gym-http-apipip install -r requirements.txtThis 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.pyIn a separate terminal, you can then try running the example python agent and see what happens:
python example_agent.pyThe example lua agent behaves very similarly:
cd binding-lualua example_agent.luaYou 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)This repository contains integration tests, using the python client implementation to send requests to the local server. They can be run using thenose2 framework. From a shell (such as bash) you can run nose2 directly:
cd gym-http-apinose2POST
/v1/envs/- Create an instance of the specified environment
- param:
env_id-- gym environment ID string, such as 'CartPole-v0' - returns:
instance_id-- a short identifier (such as '3c657dbc')for the created environment instance. The instance_id isused in future API calls to identify the environment to bemanipulated
GET
/v1/envs/- List all environments running on the server
- returns:
envs-- dict mappinginstance_idtoenv_id(e.g.{'3c657dbc': 'CartPole-v0'}) for every env on the server
POST
/v1/envs/<instance_id>/reset/- Reset the state of the environment and return an initialobservation.
- param:
instance_id-- a short identifier (such as '3c657dbc')for the environment instance - returns:
observation-- the initial observation of the space
POST
/v1/envs/<instance_id>/step/- Step though an environment using an action.
- param:
instance_id-- a short identifier (such as '3c657dbc')for the environment instance - param:
action-- an action to take in the environment - returns:
observation-- agent's observation of the currentenvironment - returns:
reward-- amount of reward returned after previous action - returns:
done-- whether the episode has ended - returns:
info-- a dict containing auxiliary diagnostic information
GET
/v1/envs/<instance_id>/action_space/- Get information (name and dimensions/bounds) of the env's
action_space - param:
instance_id-- a short identifier (such as '3c657dbc')for the environment instance - returns:
info-- a dict containing 'name' (such as 'Discrete'), andadditional dimensional info (such as 'n') which varies fromspace to space
- Get information (name and dimensions/bounds) of the env's
GET
/v1/envs/<instance_id>/observation_space/- Get information (name and dimensions/bounds) of the env's
observation_space - param:
instance_id-- a short identifier (such as '3c657dbc')for the environment instance - returns:
info-- a dict containing 'name' (such as 'Discrete'), andadditional dimensional info (such as 'n') which varies fromspace to space
- Get information (name and dimensions/bounds) of the env's
POST
/v1/envs/<instance_id>/monitor/start/- Start monitoring
- param:
instance_id-- a short identifier (such as '3c657dbc')for the environment instance - param:
force(default=False) -- Clear out existing trainingdata from this directory (by deleting every fileprefixed with "openaigym.") - param:
resume(default=False) -- Retain the training dataalready in this directory, which will be merged withour new data - (NOTE: the
video_callableparameter from the nativeenv.monitor.startfunction is NOT implemented)
POST
/v1/envs/<instance_id>/monitor/close/- Flush all monitor data to disk
- param:
instance_id-- a short identifier (such as '3c657dbc')for the environment instance
POST
/v1/upload/- Flush all monitor data to disk
- param:
training_dir-- A directory containing the results of atraining run. - param:
api_key-- Your OpenAI API key - param:
algorithm_id(default=None) -- An arbitrary stringindicating the paricular version of the algorithm(including choices of parameters) you are running.
POST
/v1/shutdown/- Request a server shutdown
- Currently used by the integration tests to repeatedly create and destroy fresh copies of the server running in a separate thread
See the [contributors page] (https://github.com/openai/gym-http-api/graphs/contributors)
About
API to access OpenAI Gym from other languages via HTTP
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
