2929from grid2op .dtypes import dt_float
3030from grid2op .Opponent import BaseOpponent , NeverAttackBudget
3131from grid2op .operator_attention import LinearAttentionBudget
32+ from grid2op .Space import DEFAULT_N_BUSBAR_PER_SUB
33+ from grid2op .Episode import EpisodeData
34+ # on windows if i start using sequential, i need to continue using sequential
35+ # if i start using parallel i need to continue using parallel
36+ # so i force the usage of the "starmap" stuff even if there is one process on windows
37+ from grid2op ._glop_platform_info import _IS_WINDOWS , _IS_LINUX , _IS_MACOS
38+
3239from grid2op .Runner .aux_fun import (
3340 _aux_run_one_episode ,
3441 _aux_make_progress_bar ,
3542 _aux_one_process_parrallel ,
3643)
3744from grid2op .Runner .basic_logger import DoNothingLog , ConsoleLog
38- from grid2op .Episode import EpisodeData
3945
40- # on windows if i start using sequential, i need to continue using sequential
41- # if i start using parallel i need to continue using parallel
42- # so i force the usage of the "starmap" stuff even if there is one process on windows
43- from grid2op ._glop_platform_info import _IS_WINDOWS , _IS_LINUX , _IS_MACOS
4446
4547runner_returned_type = Union [Tuple [str , str , float , int , int ],
4648 Tuple [str , str , float , int , int , EpisodeData ],
5759
5860KEY_TIME_SERIE_ID = "time serie id"
5961
60-
6162class Runner (object ):
6263 """
6364 A runner is a utility tool that allows to run simulations more easily.
@@ -246,7 +247,7 @@ def __init__(
246247 init_env_path : str ,
247248 init_grid_path : str ,
248249 path_chron , # path where chronics of injections are stored
249- n_busbar = 2 ,
250+ n_busbar = DEFAULT_N_BUSBAR_PER_SUB ,
250251 name_env = "unknown" ,
251252 parameters_path = None ,
252253 names_chronics_to_backend = None ,
@@ -918,6 +919,7 @@ def _run_sequential(
918919 ) = self .run_one_episode (
919920 path_save = path_save ,
920921 indx = ep_id ,
922+ episode_id = ep_id ,
921923 pbar = next_pbar [0 ],
922924 env_seed = env_seed ,
923925 agent_seed = agt_seed ,
@@ -1184,6 +1186,7 @@ def _clean_up(self):
11841186 def run (
11851187 self ,
11861188 nb_episode ,
1189+ * , # force kwargs
11871190 nb_process = 1 ,
11881191 path_save = None ,
11891192 max_iter = None ,
@@ -1452,7 +1455,13 @@ def run(
14521455 "either use dictionnary, grid2op actions or list / tuple of actions." )
14531456
14541457 if reset_options is not None :
1455- if isinstance (reset_options , (dict )):
1458+ if isinstance (reset_options , dict ):
1459+ for k in reset_options :
1460+ if not k in self .envClass .KEYS_RESET_OPTIONS :
1461+ raise RuntimeError ("Wehn specifying `reset options` all keys of the dictionary should "
1462+ "be compatible with the available reset options of your environment "
1463+ f"class. You provided the key \" { k } \" for the provided dictionary but"
1464+ f"possible keys are limited to { self .envClass .KEYS_RESET_OPTIONS } ." )
14561465 # user provided one initial state, I copy it to all
14571466 # evaluation
14581467 reset_options = [reset_options .copy () for _ in range (nb_episode )]
@@ -1469,6 +1478,13 @@ def run(
14691478 raise RuntimeError ("When specifying `reset_options` kwargs with a list (or a tuple) "
14701479 "it should be a list (or a tuple) of dictionary or BaseAction. "
14711480 f"You provided { type (el )} at position { i } ." )
1481+ for i , el in enumerate (reset_options ):
1482+ for k in el :
1483+ if not k in self .envClass .KEYS_RESET_OPTIONS :
1484+ raise RuntimeError ("Wehn specifying `reset options` all keys of the dictionary should "
1485+ "be compatible with the available reset options of your environment "
1486+ f"class. You provided the key \" { k } \" for the { i } th dictionary but"
1487+ f"possible keys are limited to { self .envClass .KEYS_RESET_OPTIONS } ." )
14721488 else :
14731489 raise RuntimeError ("When using `reset_options` in the runner, you should make sure to use "
14741490 "either use dictionnary, grid2op actions or list / tuple of actions." )
0 commit comments