def create_handler_from_str()

in mbrl/util/__init__.py [0:0]


def create_handler_from_str(env_name: str):
    """Creates a new environment handler from its string description.

    Args:
        env_name (str): the string description of the environment. Valid options are:

          - "dmcontrol___<domain>--<task>": a Deep-Mind Control suite environment
            with the indicated domain and task (e.g., "dmcontrol___cheetah--run".
          - "gym___<env_name>": a Gym environment (e.g., "gym___HalfCheetah-v2").
          - "pybulletgym__<env_name>": A Pybullet Gym environment
            (e.g. "pybulletgym__HalfCheetahMuJoCoEnv-v0")
          - "cartpole_continuous": a continuous version of gym's Cartpole environment.
          - "pets_halfcheetah": the implementation of HalfCheetah used in Chua et al.,
            PETS paper.
          - "ant_truncated_obs": the implementation of Ant environment used in Janner et al.,
            MBPO paper.
          - "humanoid_truncated_obs": the implementation of Humanoid environment used in
            Janner et al., MBPO paper.

    Returns:
        (EnvHandler): A handler for the associated gym environment
    """
    if "dmcontrol___" in env_name:
        from mbrl.util.dmcontrol import DmcontrolEnvHandler

        return DmcontrolEnvHandler()
    elif "pybulletgym___" in env_name:
        from mbrl.util.pybullet import PybulletEnvHandler

        return PybulletEnvHandler()
    elif "gym___" in env_name:
        from mbrl.util.mujoco import MujocoEnvHandler

        return MujocoEnvHandler()
    else:
        raise NotImplementedError