Pipeline

Helper methods to generate learning environment pipeline, consisting in an bare-bone environment inheriting from BaseJiminyEnv, wrapped together with any number of successive blocks as a unified environment, in Matlab Simulink fashion.

It enables to break down a complex control architectures in many submodules, making it easier to maintain and avoiding code duplications between use cases.

class gym_jiminy.common.utils.pipeline.EnvConfig[source]

Bases: TypedDict

Environment class type.

Note

Both class type or fully qualified dotted path are supported.

cls: Type[BaseJiminyEnv] | str

Environment constructor default arguments.

This attribute can be omitted.

class gym_jiminy.common.utils.pipeline.BlockConfig[source]

Bases: TypedDict

Block class type. If must derive from BaseControllerBlock for controller blocks or from BaseObserverBlock for observer blocks.

Note

Both class type or fully qualified dotted path are supported.

cls: Type[BaseControllerBlock] | Type[BaseObserverBlock] | str

Block constructor default arguments.

This attribute can be omitted.

class gym_jiminy.common.utils.pipeline.WrapperConfig[source]

Bases: TypedDict

Wrapper class type.

Note

Both class type or fully qualified dotted path are supported.

cls: Type[BasePipelineWrapper] | str

Wrapper constructor default arguments.

This attribute can be omitted.

class gym_jiminy.common.utils.pipeline.LayerConfig[source]

Bases: TypedDict

Block constructor default arguments.

This attribute can be omitted. If so, then ‘wrapper_cls’ must be specified and must not require any block. Typically, it happens when the wrapper is not doing any computation on its own but just transforming the action or observation, e.g. stacking observation frames.

block: BlockConfig | None

Wrapper configuration.

This attribute can be omitted. If so, then ‘block’ must be specified and must this block must be associated with a unique wrapper type to allow for automatic type inference. It works with any observer and controller block.

gym_jiminy.common.utils.pipeline.build_pipeline(env_config, layers_config)[source]

Wrap together an environment inheriting from BaseJiminyEnv with any number of layers, as a unified pipeline environment class inheriting from BasePipelineWrapper. Each layer is wrapped individually and successively.

Parameters:
  • env_config (EnvConfig) – Configuration of the environment, as a dict of type EnvConfig.

  • layers_config (Sequence[LayerConfig]) – Configuration of the blocks, as a list. The list is ordered from the lowest level layer to the highest, each element corresponding to the configuration of a individual layer, as a dict of type LayerConfig.

Return type:

Callable[[…], InterfaceJiminyEnv]

gym_jiminy.common.utils.pipeline.load_pipeline(fullpath)[source]

Load pipeline from JSON or TOML configuration file.

Param:

Fullpath of the configuration file.

Parameters:

fullpath (str)

Return type:

Callable[[…], InterfaceJiminyEnv]