Skip to content

lit_sb3.huggingface.naming_schemes

source module lit_sb3.huggingface.naming_schemes

Naming conventions for HuggingFace Hub model repositories.

Adapted from https://github.com/huggingface/huggingface_sb3/blob/main/huggingface_sb3/naming_schemes.py

This module provides string subclasses that enforce a uniform naming scheme for repository ids, making it safe to build file paths and URLs from environment / model names.

Classes

  • EnvironmentName — A normalized environment name safe for use in file paths and URLs.

  • ModelName — A model name derived from algorithm and environment.

  • ModelRepoId — The name of a HuggingFace repository.

source class EnvironmentName()

Bases : str

A normalized environment name safe for use in file paths and URLs.

Slashes are replaced by dashes, and namespace:EnvName style ids are stripped of their namespace prefix so that:

EnvironmentName("ALE/Pong-v5")  # → "ALE-Pong-v5"
EnvironmentName("ns:CartPole-v1")  # → "CartPole-v1"

The original gym id (to pass to gym.make) is available via the :attr:gym_id property.

Attributes

  • gym_id : str — The original gym id to pass to gym.make.

source property EnvironmentName.gym_id: str

The original gym id to pass to gym.make.

source class ModelName()

Bases : str

A model name derived from algorithm and environment.

Safe to use in file paths and URLs because a normalized :class:EnvironmentName is used.

ModelName("ppo", EnvironmentName("CartPole-v1"))  # → "ppo-CartPole-v1"

Attributes

  • filename : str — The filename under which the model is stored when calling model.save.

source property ModelName.filename: str

The filename under which the model is stored when calling model.save.

source class ModelRepoId()

Bases : str

The name of a HuggingFace repository.

Derived from the associated organization and the model name.

ModelRepoId("sb3", ModelName("ppo", EnvironmentName("CartPole-v1")))
# → "sb3/ppo-CartPole-v1"