Skip to main content
gymrec

🎮 Record and replay gameplay from Gymnasium environments as Hugging Face datasets 📊

gymrec is a Python CLI for collecting gameplay from Gymnasium environments and saving it as replayable Hugging Face datasets. It supports human keyboard capture, built-in agent policies, local dataset storage, Hub uploads, playback verification, and MP4 exports.

It works across Atari through ALE-py, Stable-Retro console environments, and VizDoom. Recordings store observations, actions, rewards, episode metadata, collector provenance, and the gymrec version used to collect the run.

Install

git clone https://github.com/tsilva/gymrec.git
cd gymrec
uv sync
cp .env.example .env

Add your Hugging Face token to .env when you want to upload datasets:

HF_TOKEN=your-api-token

Run the CLI from the repo root with uv run gymrec ... or uv run python main.py ....

Commands

uv run gymrec login                                      # authenticate with Hugging Face Hub
uv run gymrec list_environments                         # list Atari, Stable-Retro, and VizDoom envs

uv run gymrec record BreakoutNoFrameskip-v4             # record human gameplay
uv run gymrec record BreakoutNoFrameskip-v4 --dry-run   # save locally without upload prompt
uv run gymrec record SuperMarioBros-Nes --agent random --headless --episodes 100
uv run gymrec record BreakoutNoFrameskip-v4 --agent breakout --headless --episodes 50
uv run gymrec record BreakoutNoFrameskip-v4 --agent random --headless --episodes 100 --workers 5

uv run gymrec upload BreakoutNoFrameskip-v4             # upload new local episodes to Hub
uv run gymrec playback BreakoutNoFrameskip-v4           # replay recorded actions
uv run gymrec playback BreakoutNoFrameskip-v4 --verify  # compare replay frames against recorded frames

uv run gymrec video BreakoutNoFrameskip-v4              # export all episodes to MP4
uv run gymrec video BreakoutNoFrameskip-v4 --range 3-7  # export a 1-based episode range
uv run gymrec video BreakoutNoFrameskip-v4 --first 5
uv run gymrec video BreakoutNoFrameskip-v4 --last 5

uv run gymrec import_roms ./roms                        # import Stable-Retro ROMs
uv run gymrec minari-export BreakoutNoFrameskip-v4      # export local data to Minari format

Usage

Human recording opens a pygame window. Press Space to start recording, use the environment-specific controls printed in the terminal, press Tab to toggle the overlay, use +/- to adjust FPS, and press Esc to stop.

Agent recording supports human, random, mario, and breakout. --headless is for agent mode only and requires --episodes; --workers runs parallel headless collection and cannot exceed the requested episode count.

Playback uses the local dataset first, then falls back to the Hugging Face Hub dataset repo. Video export requires ffmpeg and writes MP4 files from local data or downloaded Hub data.

Notes

  • Requires Python >=3.12,<3.13 and uv.
  • Hugging Face uploads use dataset repos named {username}/gymrec__{encoded_env_id} by default.
  • Local datasets are stored under ~/.gymrec/datasets by default.
  • config.toml controls display scale, FPS defaults, local storage, dataset metadata, and overlay defaults.
  • keymappings.toml controls Atari, VizDoom, and Stable-Retro keyboard bindings.
  • On Apple Silicon, uv sync installs the committed native Stable-Retro wheel through the project configuration.
  • ffmpeg must be available on PATH for video exports.
  • minari-export requires Minari; install it with uv sync --extra minari or uv pip install 'minari>=0.5.0'.

Architecture

gymrec architecture diagram

License

MIT

Metadata

Release files for gymrec 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gymrec 0.1.1
File Size Uploaded Provenance Actions
gymrec-0.1.1.tar.gz 1.7 MB With provenance Details for gymrec-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gymrec 0.1.1
File Interpreter ABI Platform Actions
gymrec-0.1.1-py3-none-any.whl Python 3 none any Details for gymrec-0.1.1-py3-none-any.whl

Total release size: 1.7 MB

Release files / gymrec-0.1.1.tar.gz

Download URL gymrec-0.1.1.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
de28595ddca203af9b4ff6a7272efe03487bbbfcc58dfe2200f85651970ecdec
BLAKE2b-256 checksum
How to use checksums
da7bdda9c5c7a11286d492e648c4ec07b8854c379eaa8a11371d06ac06b492f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 1, 2026.

Transparency log

Release files / gymrec-0.1.1-py3-none-any.whl

Download URL gymrec-0.1.1-py3-none-any.whl
Size 38.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c94848519e668fe2651bca1b085a6de72032d2fa8d32c1ffc1d1bfc4a6050bec
BLAKE2b-256 checksum
How to use checksums
8bd3a4b05cbab09c285ec48a8df8dbb3914a9b298d34e5d59abcc4c852d18588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 1, 2026.

Transparency log

Security for gymrec 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gymrec-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page