Record and replay gameplay from Gymnasium environments as Hugging Face datasets
Project description
🎮 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.13anduv. - Hugging Face uploads use dataset repos named
{username}/gymrec__{encoded_env_id}by default. - Local datasets are stored under
~/.gymrec/datasetsby default. config.tomlcontrols display scale, FPS defaults, local storage, dataset metadata, and overlay defaults.keymappings.tomlcontrols Atari, VizDoom, and Stable-Retro keyboard bindings.- On Apple Silicon,
uv syncinstalls the committed native Stable-Retro wheel through the project configuration. ffmpegmust be available onPATHforvideoexports.minari-exportrequires Minari; install it withuv sync --extra minarioruv pip install 'minari>=0.5.0'.
Architecture
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gymrec-0.1.1.tar.gz.
File metadata
- Download URL: gymrec-0.1.1.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de28595ddca203af9b4ff6a7272efe03487bbbfcc58dfe2200f85651970ecdec
|
|
| MD5 |
790cb5f1e877ea8d461177bdd93732b7
|
|
| BLAKE2b-256 |
da7bdda9c5c7a11286d492e648c4ec07b8854c379eaa8a11371d06ac06b492f1
|
Provenance
The following attestation bundles were made for gymrec-0.1.1.tar.gz:
Publisher:
release.yml on tsilva/gymrec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gymrec-0.1.1.tar.gz -
Subject digest:
de28595ddca203af9b4ff6a7272efe03487bbbfcc58dfe2200f85651970ecdec - Sigstore transparency entry: 1418423049
- Sigstore integration time:
-
Permalink:
tsilva/gymrec@711bd5227a95591b8b2c60a8d79199dc8ab22e13 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@711bd5227a95591b8b2c60a8d79199dc8ab22e13 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file gymrec-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gymrec-0.1.1-py3-none-any.whl
- Upload date:
- Size: 38.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c94848519e668fe2651bca1b085a6de72032d2fa8d32c1ffc1d1bfc4a6050bec
|
|
| MD5 |
13bcf58ef9ea32b7204df94605a3dc90
|
|
| BLAKE2b-256 |
8bd3a4b05cbab09c285ec48a8df8dbb3914a9b298d34e5d59abcc4c852d18588
|
Provenance
The following attestation bundles were made for gymrec-0.1.1-py3-none-any.whl:
Publisher:
release.yml on tsilva/gymrec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gymrec-0.1.1-py3-none-any.whl -
Subject digest:
c94848519e668fe2651bca1b085a6de72032d2fa8d32c1ffc1d1bfc4a6050bec - Sigstore transparency entry: 1418423156
- Sigstore integration time:
-
Permalink:
tsilva/gymrec@711bd5227a95591b8b2c60a8d79199dc8ab22e13 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@711bd5227a95591b8b2c60a8d79199dc8ab22e13 -
Trigger Event:
workflow_dispatch
-
Statement type: