ray.rllib.callbacks.callbacks.RLlibCallback.on_sub_environment_created#
- RLlibCallback.on_sub_environment_created(*, worker: EnvRunner, sub_environment: Any | gymnasium.Env, env_context: EnvContext, env_index: int | None = None, **kwargs) None [source]#
Callback run when a new sub-environment has been created.
This method gets called after each sub-environment (usually a gym.Env) has been created, validated (RLlib built-in validation + possible custom validation function implemented by overriding
Algorithm.validate_env()
), wrapped (e.g. video-wrapper), and seeded.- Parameters:
worker – Reference to the current rollout worker.
sub_environment – The sub-environment instance that has been created. This is usually a gym.Env object.
env_context – The
EnvContext
object that has been passed to the env’s constructor.env_index – The index of the sub-environment that has been created (within the vector of sub-environments of the BaseEnv).
kwargs – Forward compatibility placeholder.