Registry¶
Exported from sekai and sekai.registry. See the Registry guide.
Functions¶
register
¶
Register an environment with the global registry.
make
¶
Create an environment by ID (or EnvSpec) from the global registry.
Keyword arguments are forwarded to the environment's constructor, overriding the kwargs it was registered with. max_episode_steps overrides the registered time limit (it is not passed to the constructor); -1 removes it.
make_vec
¶
make_vec(id: str | EnvSpec, num_envs: int = 1, *, vectorization_mode: VectorizationMode | None = None, vector_kwargs: dict[str, Any] | None = None, wrappers: Sequence[Callable[[Any], Any]] = (), **env_kwargs: Any) -> Any
Create a vectorised environment of num_envs copies of a registered env.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str | EnvSpec
|
Registered environment ID or EnvSpec. |
required |
num_envs
|
int
|
Number of sub-environments. |
1
|
vectorization_mode
|
VectorizationMode | None
|
"native" (the env's own batched implementation, its
registered vector_entry_point; "vector_entry_point" is an alias),
"sync" (SyncVecEnv), "async" (AsyncVecEnv, asyncio) or "proc"
(ProcVecEnv, worker processes). None (the default) picks "native"
when the env has one and no per-env wrappers apply (neither
|
None
|
vector_kwargs
|
dict[str, Any] | None
|
Extra keyword arguments for the VecEnv constructor (e.g. autoreset, or num_workers / shared_memory for "proc"). |
None
|
wrappers
|
Sequence[Callable[[Any], Any]]
|
Callables applied in order to each sub-env, e.g. [lambda env: sekai.FlattenObservation(env)]. Not available with "native", which has no per-env objects (nor are the spec's additional_wrappers: "native" raises ValueError for either); use Vec* wrappers instead. |
()
|
**env_kwargs
|
Any
|
Forwarded to make() for every sub-env (or to the native
implementation, which is called as |
{}
|
register_namespace
¶
Register a lazy namespace loader on the global registry.
pprint_registry
¶
Print all registered environments, grouped by namespace.
Specs¶
EnvSpec
dataclass
¶
EnvSpec(id: str, entry_point: str | Callable[..., Any] | None = None, reward_threshold: float | None = None, nondeterministic: bool = False, max_episode_steps: int | None = None, kwargs: dict[str, Any] = dict(), additional_wrappers: tuple[WrapperSpec, ...] = tuple(), vector_entry_point: str | Callable[..., Any] | None = None)
Serialisable environment specification.
IDs follow the format: [namespace/]Name[-vN] Examples: "CartPole-v1", "qc/MarketEnv-v0", "my_ns/CustomEnv"
vector_entry_point optionally names a natively vectorised implementation
(a VecEnv taking num_envs plus the env's kwargs) that make_vec() uses by default.
WrapperSpec
dataclass
¶
Specification for a wrapper to apply on top of an environment.
The registry class¶
The functions above operate on a module-level EnvRegistry; create your own instance for an
isolated registry (for example in tests).