MilesCranmer commited on
Commit
28639ea
1 Parent(s): ed67e70

feat(gui): add status messages

Browse files
Files changed (2) hide show
  1. gui/app.py +8 -2
  2. gui/processing.py +16 -2
gui/app.py CHANGED
@@ -202,6 +202,8 @@ class Results:
202
  interactive=False,
203
  )
204
 
 
 
205
 
206
  def flatten_attributes(
207
  component_group, absolute_name: str, d: OrderedDict
@@ -246,7 +248,7 @@ class AppInterface:
246
  show_progress=False,
247
  )
248
 
249
- ignore = ["df", "predictions_plot"]
250
  self.run.click(
251
  create_processing_function(self, ignore=ignore),
252
  inputs=[
@@ -254,7 +256,11 @@ class AppInterface:
254
  for k, v in flatten_attributes(self, "interface", OrderedDict()).items()
255
  if last_part(k) not in ignore
256
  ],
257
- outputs=[self.results.df, self.results.predictions_plot],
 
 
 
 
258
  show_progress=True,
259
  )
260
 
 
202
  interactive=False,
203
  )
204
 
205
+ self.messages = gr.Textbox(label="Messages", value="", interactive=False)
206
+
207
 
208
  def flatten_attributes(
209
  component_group, absolute_name: str, d: OrderedDict
 
248
  show_progress=False,
249
  )
250
 
251
+ ignore = ["df", "predictions_plot", "pareto", "messages"]
252
  self.run.click(
253
  create_processing_function(self, ignore=ignore),
254
  inputs=[
 
256
  for k, v in flatten_attributes(self, "interface", OrderedDict()).items()
257
  if last_part(k) not in ignore
258
  ],
259
+ outputs=[
260
+ self.results.df,
261
+ self.results.predictions_plot,
262
+ self.results.messages,
263
+ ],
264
  show_progress=True,
265
  )
266
 
gui/processing.py CHANGED
@@ -182,6 +182,15 @@ def processing(
182
  ),
183
  )
184
  )
 
 
 
 
 
 
 
 
 
185
  while PERSISTENT_WRITER.out_queue.empty():
186
  if (
187
  equation_file.exists()
@@ -198,8 +207,13 @@ def processing(
198
  out = PERSISTENT_READER.out_queue.get()
199
  predictions = out["ypred"]
200
  equations = out["equations"]
201
- yield equations[["Complexity", "Loss", "Equation"]], plot_predictions(
202
- y, predictions
 
 
203
  )
 
204
 
205
  time.sleep(0.1)
 
 
 
182
  ),
183
  )
184
  )
185
+
186
+ last_yield = (
187
+ pd.DataFrame({"Complexity": [], "Loss": [], "Equation": []}),
188
+ plot_predictions([], []),
189
+ "Started!",
190
+ )
191
+
192
+ yield last_yield
193
+
194
  while PERSISTENT_WRITER.out_queue.empty():
195
  if (
196
  equation_file.exists()
 
207
  out = PERSISTENT_READER.out_queue.get()
208
  predictions = out["ypred"]
209
  equations = out["equations"]
210
+ last_yield = (
211
+ equations[["Complexity", "Loss", "Equation"]],
212
+ plot_predictions(y, predictions),
213
+ "Running...",
214
  )
215
+ yield last_yield
216
 
217
  time.sleep(0.1)
218
+
219
+ yield (*last_yield[:-1], "Done")