sample#

OfflineSingleAgentEnvRunner.sample(*, num_timesteps: int = None, num_episodes: int = None, explore: bool = None, random_actions: bool = False, force_reset: bool = False) → List[SingleAgentEpisode][source]#

Samples from environments and writes data to disk.

Samples like SingleAgentEnvRunner.sample() and adds the samples to a buffer. If config.output_max_rows_per_file is set, writes the buffer to config.output once it holds that many rows. Otherwise, writes the samples on every call.

Parameters:
  • num_timesteps (int) – The minimum number of timesteps to sample during this call. Only one of num_timesteps or num_episodes may be provided.

  • num_episodes (int) – The minimum number of episodes to sample during this call. Only one of num_timesteps or num_episodes may be provided.

  • explore (bool) – Whether to compute actions with the RLModule’s forward_exploration() method, instead of forward_inference(). If None, uses the explore setting from the config.

  • random_actions (bool) – Whether to sample actions randomly from the env’s action space, instead of computing them with the RLModule.

  • force_reset (bool) – Whether to force-reset all vectorized environments before sampling.

Returns:

The sampled episodes, as SingleAgentEnvRunner.sample() returns them.

Return type:

List[SingleAgentEpisode]