MilesCranmer commited on
Commit
754d7db
1 Parent(s): f72e324

Only activate env on first run

Browse files
Files changed (1) hide show
  1. pysr/sr.py +18 -17
pysr/sr.py CHANGED
@@ -423,23 +423,24 @@ def pysr(
423
  except:
424
  _, term_width = subprocess.check_output(["stty", "size"]).split()
425
 
426
- from julia import Pkg
427
-
428
- Pkg.activate(f"{_escape_filename(julia_project)}")
429
- if need_install:
430
- Pkg.instantiate()
431
- Pkg.update()
432
- Pkg.precompile()
433
- elif update:
434
- Pkg.update()
435
-
436
- Main.eval("using SymbolicRegression")
437
-
438
- Main.plus = Main.eval("(+)")
439
- Main.sub = Main.eval("(-)")
440
- Main.mult = Main.eval("(*)")
441
- Main.pow = Main.eval("(^)")
442
- Main.div = Main.eval("(/)")
 
443
 
444
  Main.custom_loss = Main.eval(loss)
445
 
 
423
  except:
424
  _, term_width = subprocess.check_output(["stty", "size"]).split()
425
 
426
+ if not already_ran:
427
+ from julia import Pkg
428
+
429
+ Pkg.activate(f"{_escape_filename(julia_project)}")
430
+ if need_install:
431
+ Pkg.instantiate()
432
+ Pkg.update()
433
+ Pkg.precompile()
434
+ elif update:
435
+ Pkg.update()
436
+
437
+ Main.eval("using SymbolicRegression")
438
+
439
+ Main.plus = Main.eval("(+)")
440
+ Main.sub = Main.eval("(-)")
441
+ Main.mult = Main.eval("(*)")
442
+ Main.pow = Main.eval("(^)")
443
+ Main.div = Main.eval("(/)")
444
 
445
  Main.custom_loss = Main.eval(loss)
446