Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
1b34e61
1
Parent(s):
60d08b2
Automatically instantiate Project.toml
Browse files- pysr/sr.py +10 -7
pysr/sr.py
CHANGED
@@ -445,19 +445,22 @@ def pysr(
|
|
445 |
from julia import Pkg
|
446 |
|
447 |
Pkg.activate(f"{_escape_filename(julia_project)}")
|
448 |
-
|
449 |
-
|
450 |
Pkg.resolve()
|
451 |
-
|
452 |
-
|
453 |
-
|
|
|
|
|
|
|
454 |
Required dependencies are not installed or built. Run the following code in the Python REPL:
|
455 |
|
456 |
>>> import pysr
|
457 |
>>> pysr.install()
|
458 |
-
|
459 |
Tried to activate project {julia_project} but failed."""
|
460 |
-
|
461 |
Main.eval("using SymbolicRegression")
|
462 |
|
463 |
Main.plus = Main.eval("(+)")
|
|
|
445 |
from julia import Pkg
|
446 |
|
447 |
Pkg.activate(f"{_escape_filename(julia_project)}")
|
448 |
+
try:
|
449 |
+
if update:
|
450 |
Pkg.resolve()
|
451 |
+
Pkg.instantiate()
|
452 |
+
else:
|
453 |
+
Pkg.instantiate()
|
454 |
+
except RuntimeError as e:
|
455 |
+
raise ImportError(
|
456 |
+
f"""
|
457 |
Required dependencies are not installed or built. Run the following code in the Python REPL:
|
458 |
|
459 |
>>> import pysr
|
460 |
>>> pysr.install()
|
461 |
+
|
462 |
Tried to activate project {julia_project} but failed."""
|
463 |
+
) from e
|
464 |
Main.eval("using SymbolicRegression")
|
465 |
|
466 |
Main.plus = Main.eval("(+)")
|