Skip to main content

env-ssl-wrapper (wip)

Some handy wrappers around envs for now

Install

pip install env-ssl-wrapper

Usage

Compose environments seamlessly with compose_env:

import torch
import gymnasium as gym
from env_ssl_wrapper import compose_env

env = compose_env(
    gym.make('Pendulum-v1', render_mode = 'rgb_array'),
    ('image', dict(image_size = (64, 64))),
    ('action_transform', dict(
        transforms = dict(rescale_from_to = ((0.0, 1.0), (-2.0, 2.0))),
        clip = (-2.0, 2.0)
    )),
    'auto_batch',
    ('tensor', dict(device = 'cuda' if torch.cuda.is_available() else 'cpu')),
    'done_tracker'
)

# Standard rollout loop — observations are PyTorch GPU tensors,
# and episode lengths are tracked per environment for easy replay buffer insertion

obs, info = env.reset()

while not env.needs_reset:
    actions = policy(obs['image'])
    obs, reward, terminated, truncated, info = env.step(actions)

# Per-environment episode step counts ready for replay buffer
episode_lengths = env.episode_lengths # array of shape (8,)

Wrappers

Done & Episode Length Tracking (done_tracker)

Standardizes terminated, truncated, and dones tracking across vectorized environments while maintaining per-environment episode_lengths:

env = compose_env(
    gym.make_vec('CartPole-v1', num_envs = 16),
    ('tensor', dict(device = 'cpu')),
    'done_tracker'
)

obs, info = env.reset() # obs.shape: (16, 4)

while not env.needs_reset:
    actions = model(obs)
    obs, reward, terminated, truncated, info = env.step(actions)

# episode lengths tracked per environment for replay buffer insertion
print(env.episode_lengths) # shape: (16,)

Auto Batching (auto_batch)

Ensures single non-vectorized environments output and receive leading batch dimensions seamlessly:

env = compose_env(
    gym.make('CartPole-v1'),
    'auto_batch'
)

obs, info = env.reset() # obs.shape: (1, 4)

Tensor Conversion (tensor)

Converts all numpy observations and rewards to PyTorch tensors on your target device, and action tensors back to numpy arrays:

env = compose_env(
    gym.make('CartPole-v1'),
    'auto_batch',
    ('tensor', dict(device = 'cuda'))
)

Citations

@misc{schwarzer2021dataefficientreinforcementlearningselfpredictive,
    title   = {Data-Efficient Reinforcement Learning with Self-Predictive Representations},
    author  = {Max Schwarzer and Ankesh Anand and Rishab Goel and R Devon Hjelm and Aaron Courville and Philip Bachman},
    year    = {2021},
    eprint  = {2007.05929},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2007.05929},
}
@misc{schmidt2024learningactactions,
    title   = {Learning to Act without Actions},
    author  = {Dominik Schmidt and Minqi Jiang},
    year    = {2024},
    eprint  = {2312.10812},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2312.10812},
}
@misc{eysenbach2023contrastivelearninggoalconditionedreinforcement,
    title   = {Contrastive Learning as Goal-Conditioned Reinforcement Learning},
    author  = {Benjamin Eysenbach and Tianjun Zhang and Ruslan Salakhutdinov and Sergey Levine},
    year    = {2023},
    eprint  = {2206.07568},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2206.07568},
}
@misc{ashlag2025stateentropyregularizationrobust,
    title   = {State Entropy Regularization for Robust Reinforcement Learning},
    author  = {Yonatan Ashlag and Uri Koren and Mirco Mutti and Esther Derman and Pierre-Luc Bacon and Shie Mannor},
    year    = {2025},
    eprint  = {2506.07085},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2506.07085},
}
@inproceedings{park2026dual,
    title   = {Dual Goal Representations},
    author  = {Seohong Park and Deepinder Mann and Sergey Levine},
    booktitle = {The Fourteenth International Conference on Learning Representations},
    year    = {2026},
    url     = {https://openreview.net/forum?id=aMKFTidLSM}
}
@misc{almuzairee2026squintfastvisualreinforcement,
    title   = {Squint: Fast Visual Reinforcement Learning for Sim-to-Real Robotics},
    author  = {Abdulaziz Almuzairee and Henrik I. Christensen},
    year    = {2026},
    eprint  = {2602.21203},
    archivePrefix = {arXiv},
    primaryClass = {cs.RO},
    url     = {https://arxiv.org/abs/2602.21203},
}

Download files

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

Source Distribution

env_ssl_wrapper-0.0.6.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

env_ssl_wrapper-0.0.6-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file env_ssl_wrapper-0.0.6.tar.gz.

File metadata

  • Download URL: env_ssl_wrapper-0.0.6.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for env_ssl_wrapper-0.0.6.tar.gz
Algorithm Hash digest
SHA256 2cdf77837fa990c06cc034748cf50574712d50da1a33f9698c03470c885e5e6c
MD5 e9076df6afccabc4d3297cd9810c3bdc
BLAKE2b-256 60829e99262d67eb54443c69930c1590cbad66cb071bd10d0e400307add601b7

See more details on using hashes here.

File details

Details for the file env_ssl_wrapper-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for env_ssl_wrapper-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fa52f62509adf52480222c07ca0b1b7558d2e1a6848e1abf17565a1c6ea4ce3c
MD5 69f931ad6d7d1c9e33a3db925dd369b1
BLAKE2b-256 b83af8c099ce2cb96a7105d820da4d9063a852546dc28f9a5f10ccd7d8913936

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.14

2 files

0.1.11

2 files

0.1.10

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

This release

0.0.6 This release

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

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