MilesCranmer commited on
Commit
06338fc
1 Parent(s): 2139b62

refactor(gui): avoid compiling from two processes at once

Browse files
Files changed (2) hide show
  1. gui/app.py +0 -1
  2. gui/processing.py +8 -3
gui/app.py CHANGED
@@ -150,7 +150,6 @@ class AdvancedSettings:
150
  label="Optimizer Iterations",
151
  step=1,
152
  )
153
- # Bool:
154
  self.batching = gr.Checkbox(
155
  value=False,
156
  label="Batching",
 
150
  label="Optimizer Iterations",
151
  step=1,
152
  )
 
153
  self.batching = gr.Checkbox(
154
  value=False,
155
  label="Batching",
gui/processing.py CHANGED
@@ -39,8 +39,6 @@ def pysr_fit(queue: mp.Queue, out_queue: mp.Queue):
39
 
40
 
41
  def pysr_predict(queue: mp.Queue, out_queue: mp.Queue):
42
- import pysr
43
-
44
  while True:
45
  args = queue.get()
46
 
@@ -61,6 +59,10 @@ def pysr_predict(queue: mp.Queue, out_queue: mp.Queue):
61
  os.system(f"cp {equation_file_bkup} {equation_file_copy}")
62
  os.system(f"cp {equation_file_pkl} {equation_file_pkl_copy}")
63
 
 
 
 
 
64
  try:
65
  model = pysr.PySRRegressor.from_file(equation_file_pkl_copy, verbosity=0)
66
  except pd.errors.EmptyDataError:
@@ -181,7 +183,10 @@ def processing(
181
  )
182
  )
183
  while PERSISTENT_WRITER.out_queue.empty():
184
- if equation_file.exists():
 
 
 
185
  # First, copy the file to a the copy file
186
  PERSISTENT_READER.queue.put(
187
  dict(
 
39
 
40
 
41
  def pysr_predict(queue: mp.Queue, out_queue: mp.Queue):
 
 
42
  while True:
43
  args = queue.get()
44
 
 
59
  os.system(f"cp {equation_file_bkup} {equation_file_copy}")
60
  os.system(f"cp {equation_file_pkl} {equation_file_pkl_copy}")
61
 
62
+ # Note that we import pysr late in this process to avoid
63
+ # pre-compiling the code in two places at once
64
+ import pysr
65
+
66
  try:
67
  model = pysr.PySRRegressor.from_file(equation_file_pkl_copy, verbosity=0)
68
  except pd.errors.EmptyDataError:
 
183
  )
184
  )
185
  while PERSISTENT_WRITER.out_queue.empty():
186
+ if (
187
+ equation_file.exists()
188
+ and Path(str(equation_file).replace(".csv", ".pkl")).exists()
189
+ ):
190
  # First, copy the file to a the copy file
191
  PERSISTENT_READER.queue.put(
192
  dict(