rllib/utils/pre_checks/env.py
def check_env(env: EnvType) -> None:
    """Run pre-checks on env that uncover common errors in environments.

    Args:
        env: Environment to be checked.

    Raises:
        ValueError: If env is not an instance of SUPPORTED_ENVIRONMENT_TYPES.
        ValueError: See check_gym_env docstring for details.
    """
    from ray.rllib.env import (
        BaseEnv,
        MultiAgentEnv,
        RemoteBaseEnv,
        VectorEnv,
        ExternalMultiAgentEnv,
        ExternalEnv,
    )

    if hasattr(env, "_skip_env_checking") and env._skip_env_checking:
        # This is a work around for some environments that we already have in RLlb
        # that we want to skip checking for now until we have the time to fix them.
        logger.warning("Skipping env checking for this experiment")
        return

    try:
        if not isinstance(
            env,
            (
                BaseEnv,
                gym.Env,
                MultiAgentEnv,
                RemoteBaseEnv,
                VectorEnv,
                ExternalMultiAgentEnv,
                ExternalEnv,
                ActorHandle,
            ),
        ):
            raise ValueError(
                "Env must be one of the supported types: BaseEnv, gym.Env, "
                "MultiAgentEnv, VectorEnv, RemoteBaseEnv, ExternalMultiAgentEnv, "
                f"ExternalEnv, but instead was a {type(env)}"
            )
        if isinstance(env, MultiAgentEnv):
            check_multiagent_environments(env)
        elif isinstance(env, gym.Env):
            check_gym_environments(env)
        elif isinstance(env, BaseEnv):
            check_base_env(env)
        else:
            logger.warning(
                "Env checking isn't implemented for VectorEnvs, RemoteBaseEnvs, "
                "ExternalMultiAgentEnv,or ExternalEnvs or Environments that are "
                "Ray actors"
            )
    except Exception:
        actual_error = traceback.format_exc()
        raise ValueError(
            f"{actual_error}\n"
            "The above error has been found in your environment! "
            "We've added a module for checking your custom environments. It "
            "may cause your experiment to fail if your environment is not set up"
            "correctly. You can disable this behavior by setting "
            "`disable_env_checking=True` in your config "
            "dictionary. You can run the environment checking module "
            "standalone by calling ray.rllib.utils.check_env([env])."
        )
Run pre-checks on env that uncover common errors in environments.

    Args:
        env: Environment to be checked.

    Raises:
        ValueError: If env is not an instance of SUPPORTED_ENVIRONMENT_TYPES.
        ValueError: See check_gym_env docstring for details.
    
Run pre-checks on env that uncover common errors in environments.
Run pre - checks on env that uncover common errors in environments .
def check_env(env: EnvType) -> None:
    from ray.rllib.env import (
        BaseEnv,
        MultiAgentEnv,
        RemoteBaseEnv,
        VectorEnv,
        ExternalMultiAgentEnv,
        ExternalEnv,
    )
    if hasattr(env, "_skip_env_checking") and env._skip_env_checking:
        logger.warning("Skipping env checking for this experiment")
        return
    try:
        if not isinstance(
            env,
            (
                BaseEnv,
                gym.Env,
                MultiAgentEnv,
                RemoteBaseEnv,
                VectorEnv,
                ExternalMultiAgentEnv,
                ExternalEnv,
                ActorHandle,
            ),
        ):
            raise ValueError(
                "Env must be one of the supported types: BaseEnv, gym.Env, "
                "MultiAgentEnv, VectorEnv, RemoteBaseEnv, ExternalMultiAgentEnv, "
                f"ExternalEnv, but instead was a {type(env)}"
            )
        if isinstance(env, MultiAgentEnv):
            check_multiagent_environments(env)
        elif isinstance(env, gym.Env):
            check_gym_environments(env)
        elif isinstance(env, BaseEnv):
            check_base_env(env)
        else:
            logger.warning(
                "Env checking isn't implemented for VectorEnvs, RemoteBaseEnvs, "
                "ExternalMultiAgentEnv,or ExternalEnvs or Environments that are "
                "Ray actors"
            )
    except Exception:
        actual_error = traceback.format_exc()
        raise ValueError(
            f"{actual_error}\n"
            "The above error has been found in your environment! "
            "We've added a module for checking your custom environments. It "
            "may cause your experiment to fail if your environment is not set up"
            "correctly. You can disable this behavior by setting "
            "`disable_env_checking=True` in your config "
            "dictionary. You can run the environment checking module "
            "standalone by calling ray.rllib.utils.check_env([env])."
        )
def check_env ( env : EnvType ) -> None : from ray . rllib . env import ( BaseEnv , MultiAgentEnv , RemoteBaseEnv , VectorEnv , ExternalMultiAgentEnv , ExternalEnv , ) if hasattr ( env , "_skip_env_checking" ) and env . _skip_env_checking : logger . warning ( "Skipping env checking for this experiment" ) return try : if not isinstance ( env , ( BaseEnv , gym . Env , MultiAgentEnv , RemoteBaseEnv , VectorEnv , ExternalMultiAgentEnv , ExternalEnv , ActorHandle , ) , ) : raise ValueError ( "Env must be one of the supported types: BaseEnv, gym.Env, " "MultiAgentEnv, VectorEnv, RemoteBaseEnv, ExternalMultiAgentEnv, " f"ExternalEnv, but instead was a {type(env)}" ) if isinstance ( env , MultiAgentEnv ) : check_multiagent_environments ( env ) elif isinstance ( env , gym . Env ) : check_gym_environments ( env ) elif isinstance ( env , BaseEnv ) : check_base_env ( env ) else : logger . warning ( "Env checking isn't implemented for VectorEnvs, RemoteBaseEnvs, " "ExternalMultiAgentEnv,or ExternalEnvs or Environments that are " "Ray actors" ) except Exception : actual_error = traceback . format_exc ( ) raise ValueError ( f"{actual_error}\n" "The above error has been found in your environment! " "We've added a module for checking your custom environments. It " "may cause your experiment to fail if your environment is not set up" "correctly. You can disable this behavior by setting " "`disable_env_checking=True` in your config " "dictionary. You can run the environment checking module " "standalone by calling ray.rllib.utils.check_env([env])." )
Run pre-checks on env that uncover common errors in environments.
Run pre - checks on env that uncover common errors in environments .
"""Run pre-checks on env that uncover common errors in environments.

    Args:
        env: Environment to be checked.

    Raises:
        ValueError: If env is not an instance of SUPPORTED_ENVIRONMENT_TYPES.
        ValueError: See check_gym_env docstring for details.
    """ # This is a work around for some environments that we already have in RLlb # that we want to skip checking for now until we have the time to fix them.
If env is not an instance of SUPPORTED_ENVIRONMENT_TYPES.
If env is not an instance of SUPPORTED_ENVIRONMENT_TYPES .
ValueError
See check_gym_env docstring for details.
See check_gym_env docstring for details .
ValueError
env
EnvType
Environment to be checked.
Environment to be checked .