rllib/agents/trainer_config.py
def environment(
        self,
        *,
        env: Optional[Union[str, EnvType]] = None,
        env_config: Optional[EnvConfigDict] = None,
        observation_space: Optional[gym.spaces.Space] = None,
        action_space: Optional[gym.spaces.Space] = None,
        env_task_fn: Optional[Callable[[ResultDict, EnvType, EnvContext], Any]] = None,
        render_env: Optional[bool] = None,
        record_env: Optional[bool] = None,
        clip_rewards: Optional[Union[bool, float]] = None,
        normalize_actions: Optional[bool] = None,
        clip_actions: Optional[bool] = None,
        disable_env_checking: Optional[bool] = None,
    ) -> "TrainerConfig":
        """Sets the config's RL-environment settings.

        Args:
            env: The environment specifier. This can either be a tune-registered env,
                via `tune.register_env([name], lambda env_ctx: [env object])`,
                or a string specifier of an RLlib supported type. In the latter case,
                RLlib will try to interpret the specifier as either an openAI gym env,
                a PyBullet env, a ViZDoomGym env, or a fully qualified classpath to an
                Env class, e.g. "ray.rllib.examples.env.random_env.RandomEnv".
            env_config: Arguments dict passed to the env creator as an EnvContext
                object (which is a dict plus the properties: num_workers, worker_index,
                vector_index, and remote).
            observation_space: The observation space for the Policies of this Trainer.
            action_space: The action space for the Policies of this Trainer.
            env_task_fn: A callable taking the last train results, the base env and the
                env context as args and returning a new task to set the env to.
                The env must be a `TaskSettableEnv` sub-class for this to work.
                See `examples/curriculum_learning.py` for an example.
            render_env: If True, try to render the environment on the local worker or on
                worker 1 (if num_workers > 0). For vectorized envs, this usually means
                that only the first sub-environment will be rendered.
                In order for this to work, your env will have to implement the
                `render()` method which either:
                a) handles window generation and rendering itself (returning True) or
                b) returns a numpy uint8 image of shape [height x width x 3 (RGB)].
            record_env: If True, stores videos in this relative directory inside the
                default output dir (~/ray_results/...). Alternatively, you can
                specify an absolute path (str), in which the env recordings should be
                stored instead. Set to False for not recording anything.
                Note: This setting replaces the deprecated `monitor` key.
            clip_rewards: Whether to clip rewards during Policy's postprocessing.
                None (default): Clip for Atari only (r=sign(r)).
                True: r=sign(r): Fixed rewards -1.0, 1.0, or 0.0.
                False: Never clip.
                [float value]: Clip at -value and + value.
                Tuple[value1, value2]: Clip at value1 and value2.
            normalize_actions: If True, RLlib will learn entirely inside a normalized
                action space (0.0 centered with small stddev; only affecting Box
                components). We will unsquash actions (and clip, just in case) to the
                bounds of the env's action space before sending actions back to the env.
            clip_actions: If True, RLlib will clip actions according to the env's bounds
                before sending them back to the env.
                TODO: (sven) This option should be deprecated and always be False.
            disable_env_checking: If True, disable the environment pre-checking module.

        Returns:
            This updated TrainerConfig object.
        """
        if env is not None:
            self.env = env
        if env_config is not None:
            self.env_config = env_config
        if observation_space is not None:
            self.observation_space = observation_space
        if action_space is not None:
            self.action_space = action_space
        if env_task_fn is not None:
            self.env_task_fn = env_task_fn
        if render_env is not None:
            self.render_env = render_env
        if record_env is not None:
            self.record_env = record_env
        if clip_rewards is not None:
            self.clip_rewards = clip_rewards
        if normalize_actions is not None:
            self.normalize_actions = normalize_actions
        if clip_actions is not None:
            self.clip_actions = clip_actions
        if disable_env_checking is not None:
            self.disable_env_checking = disable_env_checking

        return self
Sets the config's RL-environment settings.

        Args:
            env: The environment specifier. This can either be a tune-registered env,
                via `tune.register_env([name], lambda env_ctx: [env object])`,
                or a string specifier of an RLlib supported type. In the latter case,
                RLlib will try to interpret the specifier as either an openAI gym env,
                a PyBullet env, a ViZDoomGym env, or a fully qualified classpath to an
                Env class, e.g. "ray.rllib.examples.env.random_env.RandomEnv".
            env_config: Arguments dict passed to the env creator as an EnvContext
                object (which is a dict plus the properties: num_workers, worker_index,
                vector_index, and remote).
            observation_space: The observation space for the Policies of this Trainer.
            action_space: The action space for the Policies of this Trainer.
            env_task_fn: A callable taking the last train results, the base env and the
                env context as args and returning a new task to set the env to.
                The env must be a `TaskSettableEnv` sub-class for this to work.
                See `examples/curriculum_learning.py` for an example.
            render_env: If True, try to render the environment on the local worker or on
                worker 1 (if num_workers > 0). For vectorized envs, this usually means
                that only the first sub-environment will be rendered.
                In order for this to work, your env will have to implement the
                `render()` method which either:
                a) handles window generation and rendering itself (returning True) or
                b) returns a numpy uint8 image of shape [height x width x 3 (RGB)].
            record_env: If True, stores videos in this relative directory inside the
                default output dir (~/ray_results/...). Alternatively, you can
                specify an absolute path (str), in which the env recordings should be
                stored instead. Set to False for not recording anything.
                Note: This setting replaces the deprecated `monitor` key.
            clip_rewards: Whether to clip rewards during Policy's postprocessing.
                None (default): Clip for Atari only (r=sign(r)).
                True: r=sign(r): Fixed rewards -1.0, 1.0, or 0.0.
                False: Never clip.
                [float value]: Clip at -value and + value.
                Tuple[value1, value2]: Clip at value1 and value2.
            normalize_actions: If True, RLlib will learn entirely inside a normalized
                action space (0.0 centered with small stddev; only affecting Box
                components). We will unsquash actions (and clip, just in case) to the
                bounds of the env's action space before sending actions back to the env.
            clip_actions: If True, RLlib will clip actions according to the env's bounds
                before sending them back to the env.
                TODO: (sven) This option should be deprecated and always be False.
            disable_env_checking: If True, disable the environment pre-checking module.

        Returns:
            This updated TrainerConfig object.
        
Sets the config's RL-environment settings.
Sets the config ' s RL - environment settings .
def environment(
        self,
        *,
        env: Optional[Union[str, EnvType]] = None,
        env_config: Optional[EnvConfigDict] = None,
        observation_space: Optional[gym.spaces.Space] = None,
        action_space: Optional[gym.spaces.Space] = None,
        env_task_fn: Optional[Callable[[ResultDict, EnvType, EnvContext], Any]] = None,
        render_env: Optional[bool] = None,
        record_env: Optional[bool] = None,
        clip_rewards: Optional[Union[bool, float]] = None,
        normalize_actions: Optional[bool] = None,
        clip_actions: Optional[bool] = None,
        disable_env_checking: Optional[bool] = None,
    ) -> "TrainerConfig":
        if env is not None:
            self.env = env
        if env_config is not None:
            self.env_config = env_config
        if observation_space is not None:
            self.observation_space = observation_space
        if action_space is not None:
            self.action_space = action_space
        if env_task_fn is not None:
            self.env_task_fn = env_task_fn
        if render_env is not None:
            self.render_env = render_env
        if record_env is not None:
            self.record_env = record_env
        if clip_rewards is not None:
            self.clip_rewards = clip_rewards
        if normalize_actions is not None:
            self.normalize_actions = normalize_actions
        if clip_actions is not None:
            self.clip_actions = clip_actions
        if disable_env_checking is not None:
            self.disable_env_checking = disable_env_checking
        return self
def environment ( self , * , env : Optional [ Union [ str , EnvType ] ] = None , env_config : Optional [ EnvConfigDict ] = None , observation_space : Optional [ gym . spaces . Space ] = None , action_space : Optional [ gym . spaces . Space ] = None , env_task_fn : Optional [ Callable [ [ ResultDict , EnvType , EnvContext ] , Any ] ] = None , render_env : Optional [ bool ] = None , record_env : Optional [ bool ] = None , clip_rewards : Optional [ Union [ bool , float ] ] = None , normalize_actions : Optional [ bool ] = None , clip_actions : Optional [ bool ] = None , disable_env_checking : Optional [ bool ] = None , ) -> "TrainerConfig" : if env is not None : self . env = env if env_config is not None : self . env_config = env_config if observation_space is not None : self . observation_space = observation_space if action_space is not None : self . action_space = action_space if env_task_fn is not None : self . env_task_fn = env_task_fn if render_env is not None : self . render_env = render_env if record_env is not None : self . record_env = record_env if clip_rewards is not None : self . clip_rewards = clip_rewards if normalize_actions is not None : self . normalize_actions = normalize_actions if clip_actions is not None : self . clip_actions = clip_actions if disable_env_checking is not None : self . disable_env_checking = disable_env_checking return self
Sets the config's RL-environment settings.
Sets the config ' s RL - environment settings .
"""Sets the config's RL-environment settings.

        Args:
            env: The environment specifier. This can either be a tune-registered env,
                via `tune.register_env([name], lambda env_ctx: [env object])`,
                or a string specifier of an RLlib supported type. In the latter case,
                RLlib will try to interpret the specifier as either an openAI gym env,
                a PyBullet env, a ViZDoomGym env, or a fully qualified classpath to an
                Env class, e.g. "ray.rllib.examples.env.random_env.RandomEnv".
            env_config: Arguments dict passed to the env creator as an EnvContext
                object (which is a dict plus the properties: num_workers, worker_index,
                vector_index, and remote).
            observation_space: The observation space for the Policies of this Trainer.
            action_space: The action space for the Policies of this Trainer.
            env_task_fn: A callable taking the last train results, the base env and the
                env context as args and returning a new task to set the env to.
                The env must be a `TaskSettableEnv` sub-class for this to work.
                See `examples/curriculum_learning.py` for an example.
            render_env: If True, try to render the environment on the local worker or on
                worker 1 (if num_workers > 0). For vectorized envs, this usually means
                that only the first sub-environment will be rendered.
                In order for this to work, your env will have to implement the
                `render()` method which either:
                a) handles window generation and rendering itself (returning True) or
                b) returns a numpy uint8 image of shape [height x width x 3 (RGB)].
            record_env: If True, stores videos in this relative directory inside the
                default output dir (~/ray_results/...). Alternatively, you can
                specify an absolute path (str), in which the env recordings should be
                stored instead. Set to False for not recording anything.
                Note: This setting replaces the deprecated `monitor` key.
            clip_rewards: Whether to clip rewards during Policy's postprocessing.
                None (default): Clip for Atari only (r=sign(r)).
                True: r=sign(r): Fixed rewards -1.0, 1.0, or 0.0.
                False: Never clip.
                [float value]: Clip at -value and + value.
                Tuple[value1, value2]: Clip at value1 and value2.
            normalize_actions: If True, RLlib will learn entirely inside a normalized
                action space (0.0 centered with small stddev; only affecting Box
                components). We will unsquash actions (and clip, just in case) to the
                bounds of the env's action space before sending actions back to the env.
            clip_actions: If True, RLlib will clip actions according to the env's bounds
                before sending them back to the env.
                TODO: (sven) This option should be deprecated and always be False.
            disable_env_checking: If True, disable the environment pre-checking module.

        Returns:
            This updated TrainerConfig object.
        """
This updated TrainerConfig object.
This updated TrainerConfig object .
self
env
Optional[Union[str, EnvType]]
The environment specifier. This can either be a tune-registered env,
via `tune.register_env([name], lambda env_ctx: [env object])`,
or a string specifier of an RLlib supported type. In the latter case,
RLlib will try to interpret the specifier as either an openAI gym env,
a PyBullet env, a ViZDoomGym env, or a fully qualified classpath to an
Env class, e.g. "ray.rllib.examples.env.random_env.RandomEnv".
The environment specifier . This can either be a tune - registered env via ` tune . register_env ( [ name ] lambda env_ctx : [ env object ] ) ` or a string specifier of an RLlib supported type . In the latter case RLlib will try to interpret the specifier as either an openAI gym env a PyBullet env a ViZDoomGym env or a fully qualified classpath to an Env class e . g . " ray . rllib . examples . env . random_env . RandomEnv " .
env_config
Optional[EnvConfigDict]
Arguments dict passed to the env creator as an EnvContext
object (which is a dict plus the properties: num_workers, worker_index,
vector_index, and remote).
Arguments dict passed to the env creator as an EnvContext object ( which is a dict plus the properties : num_workers worker_index vector_index and remote ) .
observation_space
Optional[gym.spaces.Space]
The observation space for the Policies of this Trainer.
The observation space for the Policies of this Trainer .
action_space
Optional[gym.spaces.Space]
The action space for the Policies of this Trainer.
The action space for the Policies of this Trainer .
env_task_fn
Optional[Callable[[ResultDict, EnvType, EnvContext], Any]]
A callable taking the last train results, the base env and the
env context as args and returning a new task to set the env to.
The env must be a `TaskSettableEnv` sub-class for this to work.
See `examples/curriculum_learning.py` for an example.
A callable taking the last train results the base env and the env context as args and returning a new task to set the env to . The env must be a ` TaskSettableEnv ` sub - class for this to work . See ` examples / curriculum_learning . py ` for an example .
render_env
Optional[bool]
If True, try to render the environment on the local worker or on
worker 1 (if num_workers > 0). For vectorized envs, this usually means
that only the first sub-environment will be rendered.
In order for this to work, your env will have to implement the
`render()` method which either:
a) handles window generation and rendering itself (returning True) or
b) returns a numpy uint8 image of shape [height x width x 3 (RGB)].
If True try to render the environment on the local worker or on worker 1 ( if num_workers > 0 ) . For vectorized envs this usually means that only the first sub - environment will be rendered . In order for this to work your env will have to implement the ` render () ` method which either : a ) handles window generation and rendering itself ( returning True ) or b ) returns a numpy uint8 image of shape [ height x width x 3 ( RGB ) ] .
record_env
Optional[bool]
If True, stores videos in this relative directory inside the
default output dir (~/ray_results/...). Alternatively, you can
specify an absolute path (str), in which the env recordings should be
stored instead. Set to False for not recording anything.
Note: This setting replaces the deprecated `monitor` key.
If True stores videos in this relative directory inside the default output dir ( ~ / ray_results / ... ) . Alternatively you can specify an absolute path ( str ) in which the env recordings should be stored instead . Set to False for not recording anything . Note : This setting replaces the deprecated ` monitor ` key .
clip_rewards
Optional[Union[bool, float]]
Whether to clip rewards during Policy's postprocessing.
None (default): Clip for Atari only (r=sign(r)).
Whether to clip rewards during Policy ' s postprocessing . None ( default ) : Clip for Atari only ( r = sign ( r )) .
normalize_actions
Optional[bool]
If True, RLlib will learn entirely inside a normalized
action space (0.0 centered with small stddev; only affecting Box
components). We will unsquash actions (and clip, just in case) to the
bounds of the env's action space before sending actions back to the env.
If True RLlib will learn entirely inside a normalized action space ( 0 . 0 centered with small stddev ; only affecting Box components ) . We will unsquash actions ( and clip just in case ) to the bounds of the env ' s action space before sending actions back to the env .
clip_actions
Optional[bool]
If True, RLlib will clip actions according to the env's bounds
before sending them back to the env.
TODO: (sven) This option should be deprecated and always be False.
If True RLlib will clip actions according to the env ' s bounds before sending them back to the env . TODO : ( sven ) This option should be deprecated and always be False .
disable_env_checking
Optional[bool]
If True, disable the environment pre-checking module.
If True disable the environment pre - checking module .