Skip to content

Commit

Permalink
Rename Env to CompilerEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
sogartar committed Mar 22, 2022
1 parent ecf42fb commit 4a79017
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions compiler_gym/envs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ py_library(
srcs = ["client_service_compiler_env.py"],
visibility = ["//compiler_gym:__subpackages__"],
deps = [
":env",
":compiler_env",
"//compiler_gym:compiler_env_state",
"//compiler_gym:validation_result",
"//compiler_gym/datasets",
Expand All @@ -34,8 +34,8 @@ py_library(
)

py_library(
name = "env",
srcs = ["env.py"],
name = "compiler_env",
srcs = ["compiler_env.py"],
visibility = ["//compiler_gym:__subpackages__"],
deps = [
"//compiler_gym/spaces",
Expand Down
2 changes: 1 addition & 1 deletion compiler_gym/envs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cg_py_library(
NAME
env_py
SRCS
"env.py"
"compiler_env.py"
DEPS
compiler_gym::spaces::spaces
compiler_gym::util::util
Expand Down
4 changes: 2 additions & 2 deletions compiler_gym/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from compiler_gym.envs.client_service_compiler_env import ClientServiceCompilerEnv
from compiler_gym.envs.env import Env
from compiler_gym.envs.compiler_env import CompilerEnv
from compiler_gym.envs.gcc import GccEnv
from compiler_gym.envs.llvm.llvm_env import LlvmEnv
from compiler_gym.envs.loop_tool.loop_tool_env import LoopToolEnv
Expand All @@ -12,7 +12,7 @@
__all__ = [
"COMPILER_GYM_ENVS",
"ClientServiceCompilerEnv",
"Env",
"CompilerEnv",
"GccEnv",
"LlvmEnv",
"LoopToolEnv",
Expand Down
4 changes: 2 additions & 2 deletions compiler_gym/envs/client_service_compiler_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from compiler_gym.compiler_env_state import CompilerEnvState
from compiler_gym.datasets import Benchmark, Dataset, Datasets
from compiler_gym.datasets.uri import BenchmarkUri
from compiler_gym.envs.env import Env
from compiler_gym.envs.compiler_env import CompilerEnv
from compiler_gym.service import (
CompilerGymServiceConnection,
ConnectionOpts,
Expand Down Expand Up @@ -81,7 +81,7 @@ def _wrapped_step(
raise


class ClientServiceCompilerEnv(Env):
class ClientServiceCompilerEnv(CompilerEnv):
"""An OpenAI gym environment for compiler optimizations.
The easiest way to create a CompilerGym environment is to call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from compiler_gym.views import ObservationSpaceSpec


class Env(gym.Env, ABC):
class CompilerEnv(gym.Env, ABC):
@property
@abstractmethod
def observation_space_spec(self) -> ObservationSpaceSpec:
Expand All @@ -27,7 +27,7 @@ def observation_space_spec(
raise NotImplementedError("abstract method")

@abstractmethod
def fork(self) -> "Env":
def fork(self) -> "CompilerEnv":
"""Fork a new environment with exactly the same state.
This creates a duplicate environment instance with the current state.
Expand All @@ -36,7 +36,7 @@ def fork(self) -> "Env":
on the original and new environments.
If not already in an episode, :meth:`reset()
<compiler_gym.envs.Env.reset>` is called.
<compiler_gym.envs.CompilerEnv.reset>` is called.
Example usage:
Expand Down
10 changes: 5 additions & 5 deletions compiler_gym/wrappers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
from gym import Wrapper
from gym.spaces import Space

from compiler_gym.envs import Env
from compiler_gym.envs import CompilerEnv
from compiler_gym.spaces.reward import Reward
from compiler_gym.util.gym_type_hints import ActionType, ObservationType
from compiler_gym.views import ObservationSpaceSpec


class CompilerEnvWrapper(Env, Wrapper):
"""Wraps a :class:`CompilerEnv <compiler_gym.envs.Env>` environment
class CompilerEnvWrapper(CompilerEnv, Wrapper):
"""Wraps a :class:`CompilerEnv <compiler_gym.envs.CompilerEnv>` environment
to allow a modular transformation.
This class is the base class for all wrappers. This class must be used
rather than :code:`gym.Wrapper` to support the CompilerGym API extensions
such as the :code:`fork()` method.
"""

def __init__(self, env: Env): # pylint: disable=super-init-not-called
def __init__(self, env: CompilerEnv): # pylint: disable=super-init-not-called
"""Constructor.
:param env: The environment to wrap.
Expand All @@ -41,7 +41,7 @@ def __init__(self, env: Env): # pylint: disable=super-init-not-called
def reset(self, *args, **kwargs) -> Optional[ObservationType]:
return self.env.reset(*args, **kwargs)

def fork(self) -> Env:
def fork(self) -> CompilerEnv:
return type(self)(env=self.env.fork())

def step( # pylint: disable=arguments-differ
Expand Down

0 comments on commit 4a79017

Please sign in to comment.