2019-01-03 15:15:36 +08:00
|
|
|
import os
|
|
|
|
|
2019-01-23 21:27:26 -08:00
|
|
|
from ray.rllib.utils.annotations import PublicAPI
|
2020-07-27 14:01:17 -07:00
|
|
|
from typing import Any
|
2018-12-12 13:57:48 -08:00
|
|
|
|
|
|
|
|
2019-01-23 21:27:26 -08:00
|
|
|
@PublicAPI
|
2020-01-02 17:42:13 -08:00
|
|
|
class IOContext:
|
2018-12-12 13:57:48 -08:00
|
|
|
"""Attributes to pass to input / output class constructors.
|
|
|
|
|
|
|
|
RLlib auto-sets these attributes when constructing input / output classes.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
log_dir (str): Default logging directory.
|
|
|
|
config (dict): Configuration of the agent.
|
|
|
|
worker_index (int): When there are multiple workers created, this
|
|
|
|
uniquely identifies the current worker.
|
2019-06-03 06:49:24 +08:00
|
|
|
worker (RolloutWorker): rollout worker object reference.
|
2018-12-12 13:57:48 -08:00
|
|
|
"""
|
|
|
|
|
2019-01-23 21:27:26 -08:00
|
|
|
@PublicAPI
|
2020-07-27 14:01:17 -07:00
|
|
|
def __init__(self,
|
|
|
|
log_dir: str = None,
|
|
|
|
config: dict = None,
|
|
|
|
worker_index: int = 0,
|
|
|
|
worker: Any = None):
|
2019-01-03 15:15:36 +08:00
|
|
|
self.log_dir = log_dir or os.getcwd()
|
|
|
|
self.config = config or {}
|
2018-12-12 13:57:48 -08:00
|
|
|
self.worker_index = worker_index
|
2019-06-03 06:49:24 +08:00
|
|
|
self.worker = worker
|
2018-12-12 13:57:48 -08:00
|
|
|
|
2019-01-23 21:27:26 -08:00
|
|
|
@PublicAPI
|
2020-07-27 14:01:17 -07:00
|
|
|
def default_sampler_input(self) -> Any:
|
2019-06-03 06:49:24 +08:00
|
|
|
return self.worker.sampler
|