RLlib Callbacks

bsk_rl.utils.rllib.callbacks is a collection of utilities for logging additional data in RLlib.

class EpisodeDataWrapper(env: Env, episode_data_callback: Callable[[GeneralSatelliteTasking], dict[str, float]] | None = None, satellite_data_callback: Callable[[GeneralSatelliteTasking, Satellite], dict[str, float]] | None = None)[source]

Bases: EpisodeDataLogger, Wrapper

Wrapper for logging data at the end of each multiagent episode.

This wrapper should be used with the WrappedEpisodeDataCallbacks in RLlib. At the end of each episode, the environment will log data using the provided callback functions. See Training with RLlib PPO for an example of how to use this class.

Parameters:
  • env (Env) – The environment to wrap.

  • episode_data_callback (Callable[[GeneralSatelliteTasking], dict[str, float]] | None) – A function that takes the environment as an argument and returns a dictionary of episode-level metrics.

  • satellite_data_callback (Callable[[GeneralSatelliteTasking, Satellite], dict[str, float]] | None) – A function that takes the environment and a satellite as arguments and returns a dictionary of satellite-level metrics.

class EpisodeDataParallelWrapper(env: ParallelEnv, episode_data_callback: Callable[[GeneralSatelliteTasking], dict[str, float]] | None = None, satellite_data_callback: Callable[[GeneralSatelliteTasking, Satellite], dict[str, float]] | None = None)[source]

Bases: EpisodeDataLogger, BaseParallelWrapper

Wrapper for logging data at the end of each multiagent episode.

This wrapper should be used with the WrappedEpisodeDataCallbacks in RLlib. At the end of each episode, the environment will log data using the provided callback functions. See Asynchronous Multiagent Decision Making for an example of how to use this class.

Parameters:
  • env (ParallelEnv) – The environment to wrap.

  • episode_data_callback (Callable[[GeneralSatelliteTasking], dict[str, float]] | None) – A function that takes the environment as an argument and returns a dictionary of episode-level metrics.

  • satellite_data_callback (Callable[[GeneralSatelliteTasking, Satellite], dict[str, float]] | None) – A function that takes the environment and a satellite as arguments and returns a dictionary of satellite-level metrics.

class WrappedEpisodeDataCallbacks(*args, **kwargs)[source]

Bases: DefaultCallbacks

Log information at the end of each episode.

Logs data from an environment wrapped with EpisodeDataWrapper or EpisodeDataParallelWrapper. See Training with RLlib PPO for an example of how to use this class.