Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
afca090
1
Parent(s):
971cfde
Add quiet mode to julia.install; fixes #97
Browse files- pysr/sr.py +13 -4
pysr/sr.py
CHANGED
@@ -18,20 +18,29 @@ from hashlib import sha256
|
|
18 |
is_julia_warning_silenced = False
|
19 |
|
20 |
|
21 |
-
def install(julia_project=None): # pragma: no cover
|
22 |
"""Install PyCall.jl and all required dependencies for SymbolicRegression.jl.
|
23 |
|
24 |
Also updates the local Julia registry."""
|
25 |
import julia
|
26 |
|
27 |
-
julia.install()
|
28 |
|
29 |
julia_project = _get_julia_project(julia_project)
|
30 |
|
31 |
-
init_julia()
|
32 |
from julia import Pkg
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
try:
|
36 |
Pkg.update()
|
37 |
except RuntimeError as e:
|
|
|
18 |
is_julia_warning_silenced = False
|
19 |
|
20 |
|
21 |
+
def install(julia_project=None, quiet=False): # pragma: no cover
|
22 |
"""Install PyCall.jl and all required dependencies for SymbolicRegression.jl.
|
23 |
|
24 |
Also updates the local Julia registry."""
|
25 |
import julia
|
26 |
|
27 |
+
julia.install(quiet=quiet)
|
28 |
|
29 |
julia_project = _get_julia_project(julia_project)
|
30 |
|
31 |
+
Main = init_julia()
|
32 |
from julia import Pkg
|
33 |
|
34 |
+
if quiet:
|
35 |
+
# Point IO to /dev/null
|
36 |
+
io = "devnull"
|
37 |
+
else:
|
38 |
+
io = "stderr"
|
39 |
+
|
40 |
+
|
41 |
+
# Can't pass IO to Julia call as it evaluates to PyObject, so just directly
|
42 |
+
# use Main.eval:
|
43 |
+
Main.eval(f"Pkg.activate(\"{_escape_filename(julia_project)}\", io={io})")
|
44 |
try:
|
45 |
Pkg.update()
|
46 |
except RuntimeError as e:
|