diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a259c23..4a0286f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,7 +50,7 @@ jobs: steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v3 # v4 not working... with: submodules: true diff --git a/lightsim2grid/rewards/n1ContingencyReward.py b/lightsim2grid/rewards/n1ContingencyReward.py index 0a0de40..e2db2a0 100644 --- a/lightsim2grid/rewards/n1ContingencyReward.py +++ b/lightsim2grid/rewards/n1ContingencyReward.py @@ -78,11 +78,11 @@ def __init__(self, self._timer_post_proc = 0. def initialize(self, env: "grid2op.Environment.Environment"): - from grid2op.Environment import Environment + from grid2op.Environment import BaseEnv from grid2op.Backend import PandaPowerBackend # lazy import because grid2op -> pandapower-> lightsim2grid -> grid2op - if not isinstance(env, Environment): + if not isinstance(env, BaseEnv): raise RuntimeError("You can only initialize this reward with a " - "proper grid2op environment") + "proper grid2op environment (`BaseEnv`)") if not isinstance(env.backend, (PandaPowerBackend, LightSimBackend)): raise RuntimeError("Impossible to use the `N1ContingencyReward` with " @@ -179,6 +179,7 @@ def reset(self, env: "grid2op.Environment.BaseEnv") -> None: return super().reset(env) def close(self): - self._backend.close() + if self._backend is not None: + self._backend.close() del self._backend self._backend = None