File tree Expand file tree Collapse file tree
usecases_examples/PowerGrid Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ def dashboard():
5555 username = username ,
5656 server = server ,
5757 config = simu .config ,
58+ scenarios = simu .list_scenarios (),
5859 com = com ,
5960 messages = messages )
6061
Original file line number Diff line number Diff line change 1+ import os
12import time
23from datetime import datetime , timedelta , timezone
34import grid2op
@@ -41,6 +42,24 @@ def __init__(self, socketio):
4142 self .agent_reco = None
4243 self .socketio = socketio
4344
45+ def list_scenarios (self ):
46+ """
47+ List the scenarios (chronics folders) available in the environment.
48+
49+ Returns:
50+ list[str]: Sorted scenario names, always including the configured one.
51+ """
52+ chronics_dir = os .path .join (self .config .get ('env_name' , '' ), 'chronics' )
53+ try :
54+ names = [d for d in os .listdir (chronics_dir )
55+ if os .path .isdir (os .path .join (chronics_dir , d ))]
56+ except OSError :
57+ names = []
58+ current = self .config .get ('scenario_name' )
59+ if current and current not in names :
60+ names .append (current )
61+ return sorted (names )
62+
4463 def load_and_edit_config (self , params = None ):
4564 """
4665 Load and optionally edit the configuration from a TOML file.
Original file line number Diff line number Diff line change 172172 margin-top : 8px ;
173173 margin-bottom : 2px ;
174174 }
175- # user-info input {
175+ # user-info input ,
176+ # user-info select {
176177 padding : 9px 12px ;
177178 font-size : 14px ;
178179 border : 1px solid var ( --border ) ;
183184 margin-bottom : 4px ;
184185 transition : border-color 0.15s , box-shadow 0.15s ;
185186 }
186- # user-info input : focus {
187+ # user-info input : focus ,
188+ # user-info select : focus {
187189 outline : none;
188190 border-color : var ( --primary ) ;
189191 box-shadow : 0 0 0 3px var ( --primary-soft ) ;
@@ -436,8 +438,12 @@ <h3>Simulator configuration</h3>
436438 < form action ="{{ url_for('edit_config') }} " method ="post ">
437439 < label > Grid2Op environment's seed</ label >
438440 < input type ="text " name ="env_seed " value ="{{ config['env_seed'] }} ">
439- < label > Scenario name</ label >
440- < input type ="text " name ="scenario_name " value ="{{ config['scenario_name'] }} ">
441+ < label for ="scenario_name "> Scenario</ label >
442+ < select id ="scenario_name " name ="scenario_name " required >
443+ {% for name in scenarios %}
444+ < option value ="{{ name }} " {% if name == config[ 'scenario_name'] %}selected{% endif %}> {{ name }}</ option >
445+ {% endfor %}
446+ </ select >
441447 < label > Assistant seed</ label >
442448 < input type ="text " name ="assistant_seed " value ="{{ config['assistant_seed'] }} ">
443449 < button type ="submit "> Update</ button >
You can’t perform that action at this time.
0 commit comments