Contributing: Environment¶
Environments live in plugrl-env-client.
Where to edit¶
- Implementation:
src/plugrl_env_client/envs/<family>/<family>_env.py. The CLI imports every*_env.pyfile underenvs/at startup. - Registration:
plugrl_env_client.utils.registration(register_env,register_env_config). - Optional dependencies: a new extra under
[project.optional-dependencies]inpyproject.toml, and a check at the top of the module that raisesImportErrornaming that extra, asenvs/mujoco/mujoco_env.pydoes. The CLI then skips the env with a warning when the extra is missing, instead of failing to start.
Checklist¶
- Implement a
BaseEnvand a dataclass config with a default for every field. - Register an env UID so
plugrl-run-env-client <env-id>works; the subcommand is the UID in lowercase. - Follow the contract: set
single_action_space, return batched arrays fromstep, honourreset_indices, seed throughseed_rngs, and never reset insidestep. - Return an
Observationwhose image and state arrays all havenum_envsas their leading axis. TheRecorder(plugrl_env_client.recorder) slices it per env to save first and last observations and videos. - If the task has a notion of success, pass
best_reward_threshold_for_successtoregister_env, or the server'srollout/successstays 0.
Verify¶
Start a dummy server, in plugrl-server. Set --policy.action-dim to your
env's action size; for a discrete action, add --policy.discrete and set it
to the number of choices.
Start an env client with your env, in plugrl-env-client.
Troubleshooting¶
- Env client CLI cannot find the env UID: its module was not imported. Look
for a
Skip loading env module ...warning at startup. Expected action shape tail ...: the dummy server's--policy.action-dimdoes not match the env.- Env creation fails: check optional dependencies and your config defaults.