Skip to content

unienv_interface.wrapper.video_record

EpisodeRenderStackWrapper

EpisodeRenderStackWrapper(env: Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType], *, done_index: Optional[int] = None, rendered_index: Optional[int] = None, nested_separator: str = '.')

Bases: Wrapper[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType, BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

Initialize the wrapper. For a batched environment, done_index is used to check episode termination on a specific batch index. If rendered_index is provided, render outputs that are batched tensors are indexed at this batch index before caching/logging.

done_index instance-attribute

done_index = done_index

rendered_index instance-attribute

rendered_index = rendered_index

nested_separator instance-attribute

nested_separator = nested_separator

episodic_frames instance-attribute

episodic_frames: Union[List[Any], Dict[str, List[Any]]] = []

video_episode_num instance-attribute

video_episode_num = 0

video_step_num instance-attribute

video_step_num = 0

video_episode_start_step instance-attribute

video_episode_start_step = 0

metadata property writable

metadata: Dict[str, Any]

Returns the :attr:Env :attr:metadata.

render_mode property

render_mode: Optional[WrapperRenderFrame]

render_fps property

render_fps: Optional[int]

backend property

backend: ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]

device property

device: Optional[WrapperBDeviceT]

batch_size property

batch_size: Optional[int]

action_space property writable

action_space: Space[WrapperActT, WrapperBDeviceT, Any, WrapperBRngT]

observation_space property writable

observation_space: Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]

context_space property writable

context_space: Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]

rng property writable

rng: WrapperBRngT

Returns the :attr:Env :attr:rng attribute.

unwrapped property

unwrapped: Env

Returns the base environment of the wrapper.

This will be the bare :class:gymnasium.Env environment, underneath all layers of wrappers.

prev_wrapper_layer property

prev_wrapper_layer: Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

env instance-attribute

env = env

step

step(action: ActType) -> Tuple[ObsType, Union[SupportsFloat, BArrayType], Union[bool, BArrayType], Union[bool, BArrayType], Dict[str, Any]]

reset

reset(*args, mask: Optional[BArrayType] = None, seed: Optional[int] = None, **kwargs) -> Tuple[ContextType, ObsType, Dict[str, Any]]

render

render() -> Optional[Union[RenderFrame, Sequence[RenderFrame]]]

close

close()

sample_space

sample_space(space: Space) -> Any

Sample from space using and updating self.rng.

sample_action

sample_action() -> ActType

Sample one action from action_space.

sample_observation

sample_observation() -> ObsType

Sample one observation from observation_space.

sample_context

sample_context() -> Optional[ContextType]

Sample one context value if context_space is defined.

update_observation_post_reset

update_observation_post_reset(old_obs: ObsType, newobs_masked: ObsType, mask: BArrayType) -> ObsType

Merge masked reset observations back into a full batched observation.

update_context_post_reset

update_context_post_reset(old_context: ContextType, new_context: ContextType, mask: BArrayType) -> ContextType

Merge masked reset contexts back into a full batched context.

has_wrapper_attr

has_wrapper_attr(name: str) -> bool

Checks if the given attribute is within the wrapper or its environment.

get_wrapper_attr

get_wrapper_attr(name: str) -> Any

Gets an attribute from the wrapper and lower environments if name doesn't exist in this object.

Parameters:

Name Type Description Default
name str

The variable name to get

required

Returns:

Type Description
Any

The variable with name in wrapper or lower environments

set_wrapper_attr

set_wrapper_attr(name: str, value: Any)

Sets an attribute on this wrapper or lower environment if name is already defined.

Parameters:

Name Type Description Default
name str

The variable name

required
value Any

The new variable value

required

EpisodeVideoWrapper

EpisodeVideoWrapper(env: Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType], *, store_dir: PathLike | str, format: Literal['mp4', 'gif', 'webm'] = 'webm', done_index: Optional[int] = None, rendered_index: Optional[int] = None, nested_separator: str = '.')

Bases: EpisodeRenderStackWrapper[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

store_dir instance-attribute

store_dir = store_dir

store_format instance-attribute

store_format = format

metadata property writable

metadata: Dict[str, Any]

Returns the :attr:Env :attr:metadata.

render_mode property

render_mode: Optional[WrapperRenderFrame]

render_fps property

render_fps: Optional[int]

backend property

backend: ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]

device property

device: Optional[WrapperBDeviceT]

batch_size property

batch_size: Optional[int]

action_space property writable

action_space: Space[WrapperActT, WrapperBDeviceT, Any, WrapperBRngT]

observation_space property writable

observation_space: Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]

context_space property writable

context_space: Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]

rng property writable

rng: WrapperBRngT

Returns the :attr:Env :attr:rng attribute.

unwrapped property

unwrapped: Env

Returns the base environment of the wrapper.

This will be the bare :class:gymnasium.Env environment, underneath all layers of wrappers.

prev_wrapper_layer property

prev_wrapper_layer: Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

env instance-attribute

env = env

done_index instance-attribute

done_index = done_index

rendered_index instance-attribute

rendered_index = rendered_index

nested_separator instance-attribute

nested_separator = nested_separator

episodic_frames instance-attribute

episodic_frames: Union[List[Any], Dict[str, List[Any]]] = []

video_episode_num instance-attribute

video_episode_num = 0

video_step_num instance-attribute

video_step_num = 0

video_episode_start_step instance-attribute

video_episode_start_step = 0

step

step(action: ActType) -> Tuple[ObsType, Union[SupportsFloat, BArrayType], Union[bool, BArrayType], Union[bool, BArrayType], Dict[str, Any]]

reset

reset(*args, mask: Optional[BArrayType] = None, seed: Optional[int] = None, **kwargs) -> Tuple[ContextType, ObsType, Dict[str, Any]]

render

render() -> Optional[Union[RenderFrame, Sequence[RenderFrame]]]

close

close()

sample_space

sample_space(space: Space) -> Any

Sample from space using and updating self.rng.

sample_action

sample_action() -> ActType

Sample one action from action_space.

sample_observation

sample_observation() -> ObsType

Sample one observation from observation_space.

sample_context

sample_context() -> Optional[ContextType]

Sample one context value if context_space is defined.

update_observation_post_reset

update_observation_post_reset(old_obs: ObsType, newobs_masked: ObsType, mask: BArrayType) -> ObsType

Merge masked reset observations back into a full batched observation.

update_context_post_reset

update_context_post_reset(old_context: ContextType, new_context: ContextType, mask: BArrayType) -> ContextType

Merge masked reset contexts back into a full batched context.

has_wrapper_attr

has_wrapper_attr(name: str) -> bool

Checks if the given attribute is within the wrapper or its environment.

get_wrapper_attr

get_wrapper_attr(name: str) -> Any

Gets an attribute from the wrapper and lower environments if name doesn't exist in this object.

Parameters:

Name Type Description Default
name str

The variable name to get

required

Returns:

Type Description
Any

The variable with name in wrapper or lower environments

set_wrapper_attr

set_wrapper_attr(name: str, value: Any)

Sets an attribute on this wrapper or lower environment if name is already defined.

Parameters:

Name Type Description Default
name str

The variable name

required
value Any

The new variable value

required

EpisodeWandbVideoWrapper

EpisodeWandbVideoWrapper(env: Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType], *, wandb_log_key: str, format: Literal['mp4', 'gif', 'webm'] = 'webm', control_wandb_step: bool = False, log_wandb_episode_id: bool = True, done_index: Optional[int] = None, rendered_index: Optional[int] = None, nested_separator: str = '.')

Bases: EpisodeRenderStackWrapper[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

wandb instance-attribute

wandb = wandb

wandb_log_key instance-attribute

wandb_log_key = wandb_log_key

log_wandb_episode_id instance-attribute

log_wandb_episode_id = log_wandb_episode_id

control_wandb_step instance-attribute

control_wandb_step = control_wandb_step

store_format instance-attribute

store_format = format

metadata property writable

metadata: Dict[str, Any]

Returns the :attr:Env :attr:metadata.

render_mode property

render_mode: Optional[WrapperRenderFrame]

render_fps property

render_fps: Optional[int]

backend property

backend: ComputeBackend[Any, WrapperBDeviceT, Any, WrapperBRngT]

device property

device: Optional[WrapperBDeviceT]

batch_size property

batch_size: Optional[int]

action_space property writable

action_space: Space[WrapperActT, WrapperBDeviceT, Any, WrapperBRngT]

observation_space property writable

observation_space: Space[WrapperObsT, WrapperBDeviceT, Any, WrapperBRngT]

context_space property writable

context_space: Optional[Space[WrapperContextT, WrapperBDeviceT, Any, WrapperBRngT]]

rng property writable

rng: WrapperBRngT

Returns the :attr:Env :attr:rng attribute.

unwrapped property

unwrapped: Env

Returns the base environment of the wrapper.

This will be the bare :class:gymnasium.Env environment, underneath all layers of wrappers.

prev_wrapper_layer property

prev_wrapper_layer: Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

env instance-attribute

env = env

done_index instance-attribute

done_index = done_index

rendered_index instance-attribute

rendered_index = rendered_index

nested_separator instance-attribute

nested_separator = nested_separator

episodic_frames instance-attribute

episodic_frames: Union[List[Any], Dict[str, List[Any]]] = []

video_episode_num instance-attribute

video_episode_num = 0

video_step_num instance-attribute

video_step_num = 0

video_episode_start_step instance-attribute

video_episode_start_step = 0

step

step(action: ActType) -> Tuple[ObsType, Union[SupportsFloat, BArrayType], Union[bool, BArrayType], Union[bool, BArrayType], Dict[str, Any]]

reset

reset(*args, mask: Optional[BArrayType] = None, seed: Optional[int] = None, **kwargs) -> Tuple[ContextType, ObsType, Dict[str, Any]]

render

render() -> Optional[Union[RenderFrame, Sequence[RenderFrame]]]

close

close()

sample_space

sample_space(space: Space) -> Any

Sample from space using and updating self.rng.

sample_action

sample_action() -> ActType

Sample one action from action_space.

sample_observation

sample_observation() -> ObsType

Sample one observation from observation_space.

sample_context

sample_context() -> Optional[ContextType]

Sample one context value if context_space is defined.

update_observation_post_reset

update_observation_post_reset(old_obs: ObsType, newobs_masked: ObsType, mask: BArrayType) -> ObsType

Merge masked reset observations back into a full batched observation.

update_context_post_reset

update_context_post_reset(old_context: ContextType, new_context: ContextType, mask: BArrayType) -> ContextType

Merge masked reset contexts back into a full batched context.

has_wrapper_attr

has_wrapper_attr(name: str) -> bool

Checks if the given attribute is within the wrapper or its environment.

get_wrapper_attr

get_wrapper_attr(name: str) -> Any

Gets an attribute from the wrapper and lower environments if name doesn't exist in this object.

Parameters:

Name Type Description Default
name str

The variable name to get

required

Returns:

Type Description
Any

The variable with name in wrapper or lower environments

set_wrapper_attr

set_wrapper_attr(name: str, value: Any)

Sets an attribute on this wrapper or lower environment if name is already defined.

Parameters:

Name Type Description Default
name str

The variable name

required
value Any

The new variable value

required