Skip to main content

A simple and ubiquitous transition recorder wrapper for Gym Environments to facilitate offline reinforcement learning dataset manufacturing.

Project description

Transition Recorder Wrapper for Gym Environments

A simple and ubiquitous transition recorder wrapper for Gym Environments to facilitate offline Reinforcement Learning (RL) dataset manufacturing. Transitions (observations, actions, rewards, dones & infos) and episodes (set of transitions) are buffered with LZ4 compression and each episode is saved as a JSON line (.jsonl). Output files may be further processed to be compatible with offline RL libraries like Ray RLlib (see Usage).

Requirements

  • Python >= 3.6
  • Pypi packages: pip install -r requirements.txt

Usage

Simply import & wrap your Gym environment:

import gym
from gym_recorder import TransitionRecorderWrapper  # import the wrapper

env = gym.make("CartPole-v1")
env = TransitionRecorderWrapper(env)  # wrap your environment
env.reset()

# Use your environment as you would
while True:
    env.render()
    action = env.action_space.sample()
    obs, reward, done, info = env.step(action)
    if done:
        env.reset()

You may also use the save_folder option to customize where the transitions are saved, min_transitions_per_file to customize the output file size, and disable compression with the compress option.

Conversion

The generated .jsonl files may be further processed to be used by offline RL libraries like Ray RLlib. To convert a .jsonl dataset generated by the wrapper to a RLlib offline dataset you may run the following command:

python -m gym_recorder.converters.ray -i data/raw -o data/ray

More options can be found with python -m gym_recorder.converters.ray --help.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gym-recorder-0.0.3.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

gym_recorder-0.0.3-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file gym-recorder-0.0.3.tar.gz.

File metadata

  • Download URL: gym-recorder-0.0.3.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for gym-recorder-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2c1a4cc9c5bccfbb35d0e313650604f678416c0680c185af88d9ba352da0820e
MD5 555baba168051fa01f76756474c2e2c1
BLAKE2b-256 8d4da505083c82d5538fcb9fd2d63fc388ca7f1e1be4c61529061b559c54da5e

See more details on using hashes here.

File details

Details for the file gym_recorder-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: gym_recorder-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for gym_recorder-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 68b2dcf73f964b2f9be1f076145e36a7b6af5ebdadb92669edf54213054edf9f
MD5 9fe19e52d7ebe1aa68e6ccbb08db6e5f
BLAKE2b-256 9ee87d71807d8c0255c98cf563e2548d71956f6c26f658d10215b1a05c499627

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page