GitXplorerGitXplorer
o

gym-recording

public
72 stars
48 forks
8 issues

Commits

List of commits on branch master.
Verified
bea9968055b59551afe51357552fd3b00b65a839

Merge pull request #8 from christopherhesse/update-readme

cchristopherhesse committed 6 years ago
Unverified
5294e8d841a49ef8a11961de8a267d490f6b80d2

update README with repo status

cchristopherhesse committed 6 years ago
Unverified
0f38d6a450f6dbc29011cc503af2dd1c773e9cf8

Rewrite to use json/numpy

ttlbtlbtlb committed 8 years ago
Unverified
1f23c0227fdf43dd0f277005286e8987df15668e

Merge pull request #1 from rmoehn/master

ttlbtlbtlb committed 8 years ago
Unverified
2a979d4832d0c7d2b7b327a5e7862126ed5f4d37

setup.py: Add packages

rrmoehn committed 8 years ago
Unverified
972f241bddc847d68f883c6f1352ecf190df21f1

Docs

ttlbtlbtlb committed 8 years ago

README

The README file for this repository.

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

gym-recording

A Python package to capture the sequences of actions and observations on a Gym environment by wrapping it in a TraceRecordingWrapper, like this:

import gym
from gym_recording.wrappers import TraceRecordingWrapper

def main():
    env = gym.make('CartPole-v0')
    env = TraceRecordingWrapper(env)
    # ... exercise the environment

It will save recorded traces in a directory, which it will print with logging. You can get the directory name from your code as env.directory.

Later you can play back the recording with code like the following, which runs a callback for every episode.

from gym_recording import playback

def handle_ep(observations, actions, rewards):
  # ... learn a model

playback.scan_recorded_traces(directory, handle_ep)

You can also use the storage_s3 module to upload and download traces from S3, so you it can run across machines.

from gym_recording import playback, storage_s3

def main():
    env = gym.make('CartPole-v0')
    env = TraceRecordingWrapper(env)
    # ... exercise the environment

    s3url = storage_s3.upload_recording(env.directory, env.spec.id, 'openai-example-traces')
    # ... store s3url in a database

    # ... Switch to another machine

    # ... load s3url from a database

    def handle_ep(observations, actions, rewards):
      # ... learn a model
    playback.scan_recorded_traces(storage_s3.download_recording(s3url), handle_ep)