output_writer.py 660 B

1234567891011121314151617181920212223242526
  1. from ray.rllib.utils.annotations import override, PublicAPI
  2. from ray.rllib.utils.typing import SampleBatchType
  3. @PublicAPI
  4. class OutputWriter:
  5. """Writer API for saving experiences from policy evaluation."""
  6. @PublicAPI
  7. def write(self, sample_batch: SampleBatchType):
  8. """Saves a batch of experiences.
  9. Args:
  10. sample_batch: SampleBatch or MultiAgentBatch to save.
  11. """
  12. raise NotImplementedError
  13. @PublicAPI
  14. class NoopOutput(OutputWriter):
  15. """Output writer that discards its outputs."""
  16. @override(OutputWriter)
  17. def write(self, sample_batch: SampleBatchType):
  18. # Do nothing.
  19. pass