@@ -108,43 +108,8 @@ def update(
108108@state .change (
109109 "experiment" ,
110110 "experiment_date_range" ,
111- )
112- def update_on_change_experiment (** kwargs ):
113- # skip if triggered on server ready (all state variables marked as modified)
114- if len (state .modified_keys ) == 1 :
115- print ("Experiment changed..." )
116- update (
117- reset_model = True ,
118- reset_output = True ,
119- reset_parameters = True ,
120- reset_calibration = True ,
121- reset_plots = True ,
122- reset_gui_route_home = True ,
123- reset_gui_route_nersc = False ,
124- reset_gui_route_chat = False ,
125- reset_gui_layout = False ,
126- )
127-
128-
129- @state .change ("model_type" , "model_training_time" )
130- def update_on_change_model (** kwargs ):
131- # skip if triggered on server ready (all state variables marked as modified)
132- if len (state .modified_keys ) == 1 :
133- print ("Model type changed..." )
134- update (
135- reset_model = True ,
136- reset_output = False ,
137- reset_parameters = False ,
138- reset_calibration = False ,
139- reset_plots = True ,
140- reset_gui_route_home = True ,
141- reset_gui_route_nersc = False ,
142- reset_gui_route_chat = False ,
143- reset_gui_layout = False ,
144- )
145-
146-
147- @state .change (
111+ "model_type" ,
112+ "model_training_time" ,
148113 "displayed_output" ,
149114 "parameters" ,
150115 "opacity" ,
@@ -154,21 +119,70 @@ def update_on_change_model(**kwargs):
154119 "simulation_calibration" ,
155120 "use_inferred_calibration" ,
156121)
157- def update_on_change_others (** kwargs ):
122+ def reset (** kwargs ):
158123 # skip if triggered on server ready (all state variables marked as modified)
159124 if len (state .modified_keys ) == 1 :
160- print ("Parameters, opacity changed..." )
161- update (
162- reset_model = False ,
163- reset_output = False ,
164- reset_parameters = False ,
165- reset_calibration = False ,
166- reset_plots = True ,
167- reset_gui_route_home = False ,
168- reset_gui_route_nersc = False ,
169- reset_gui_route_chat = False ,
170- reset_gui_layout = False ,
171- )
125+ print (f"Reacting to state change in { state .modified_keys } ..." )
126+ if any (
127+ key in state .modified_keys
128+ for key in [
129+ "experiment" ,
130+ "experiment_date_range" ,
131+ ]
132+ ):
133+ update (
134+ reset_model = True ,
135+ reset_output = True ,
136+ reset_parameters = True ,
137+ reset_calibration = True ,
138+ reset_plots = True ,
139+ reset_gui_route_home = True ,
140+ reset_gui_route_nersc = False ,
141+ reset_gui_route_chat = False ,
142+ reset_gui_layout = False ,
143+ )
144+ elif any (
145+ key in state .modified_keys
146+ for key in [
147+ "model_type" ,
148+ "model_training_time" ,
149+ ]
150+ ):
151+ update (
152+ reset_model = True ,
153+ reset_output = False ,
154+ reset_parameters = False ,
155+ reset_calibration = False ,
156+ reset_plots = True ,
157+ reset_gui_route_home = True ,
158+ reset_gui_route_nersc = False ,
159+ reset_gui_route_chat = False ,
160+ reset_gui_layout = False ,
161+ )
162+ elif any (
163+ key in state .modified_keys
164+ for key in [
165+ "displayed_output" ,
166+ "parameters" ,
167+ "opacity" ,
168+ "parameters_min" ,
169+ "parameters_max" ,
170+ "parameters_show_all" ,
171+ "simulation_calibration" ,
172+ "use_inferred_calibration" ,
173+ ]
174+ ):
175+ update (
176+ reset_model = False ,
177+ reset_output = False ,
178+ reset_parameters = False ,
179+ reset_calibration = False ,
180+ reset_plots = True ,
181+ reset_gui_route_home = False ,
182+ reset_gui_route_nersc = False ,
183+ reset_gui_route_chat = False ,
184+ reset_gui_layout = False ,
185+ )
172186
173187
174188def find_simulation (event , db ):
0 commit comments