Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
b487874
1
Parent(s):
2128884
Avoid processing julia project twice
Browse files- pysr/julia_helpers.py +10 -16
pysr/julia_helpers.py
CHANGED
@@ -64,17 +64,11 @@ def install(julia_project=None, quiet=False): # pragma: no cover
|
|
64 |
|
65 |
_version_assertion()
|
66 |
# Set JULIA_PROJECT so that we install in the pysr environment
|
67 |
-
|
68 |
-
_set_julia_project_env(
|
69 |
|
70 |
julia.install(quiet=quiet)
|
71 |
-
|
72 |
-
if is_shared:
|
73 |
-
# is_shared is only true if the julia_project arg was None
|
74 |
-
# See _process_julia_project
|
75 |
-
Main = init_julia(None)
|
76 |
-
else:
|
77 |
-
Main = init_julia(julia_project)
|
78 |
|
79 |
Main.eval("using Pkg")
|
80 |
|
@@ -84,7 +78,7 @@ def install(julia_project=None, quiet=False): # pragma: no cover
|
|
84 |
# Can't pass IO to Julia call as it evaluates to PyObject, so just directly
|
85 |
# use Main.eval:
|
86 |
Main.eval(
|
87 |
-
f'Pkg.activate("{_escape_filename(
|
88 |
)
|
89 |
if is_shared:
|
90 |
# Install SymbolicRegression.jl:
|
@@ -117,14 +111,14 @@ def _import_error_string(julia_project=None):
|
|
117 |
def _process_julia_project(julia_project):
|
118 |
if julia_project is None:
|
119 |
is_shared = True
|
120 |
-
|
121 |
elif julia_project[0] == "@":
|
122 |
is_shared = True
|
123 |
-
|
124 |
else:
|
125 |
is_shared = False
|
126 |
-
|
127 |
-
return
|
128 |
|
129 |
|
130 |
def is_julia_version_greater_eq(juliainfo=None, version=(1, 6, 0)):
|
@@ -164,8 +158,8 @@ def init_julia(julia_project=None):
|
|
164 |
from julia.core import JuliaInfo, UnsupportedPythonError
|
165 |
|
166 |
_version_assertion()
|
167 |
-
|
168 |
-
_set_julia_project_env(
|
169 |
|
170 |
try:
|
171 |
info = JuliaInfo.load(julia="julia")
|
|
|
64 |
|
65 |
_version_assertion()
|
66 |
# Set JULIA_PROJECT so that we install in the pysr environment
|
67 |
+
processed_julia_project, is_shared = _process_julia_project(julia_project)
|
68 |
+
_set_julia_project_env(processed_julia_project, is_shared)
|
69 |
|
70 |
julia.install(quiet=quiet)
|
71 |
+
Main = init_julia(julia_project)
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
Main.eval("using Pkg")
|
74 |
|
|
|
78 |
# Can't pass IO to Julia call as it evaluates to PyObject, so just directly
|
79 |
# use Main.eval:
|
80 |
Main.eval(
|
81 |
+
f'Pkg.activate("{_escape_filename(processed_julia_project)}", shared = Bool({int(is_shared)}), {io_arg})'
|
82 |
)
|
83 |
if is_shared:
|
84 |
# Install SymbolicRegression.jl:
|
|
|
111 |
def _process_julia_project(julia_project):
|
112 |
if julia_project is None:
|
113 |
is_shared = True
|
114 |
+
processed_julia_project = f"pysr-{__version__}"
|
115 |
elif julia_project[0] == "@":
|
116 |
is_shared = True
|
117 |
+
processed_julia_project = julia_project[1:]
|
118 |
else:
|
119 |
is_shared = False
|
120 |
+
processed_julia_project = Path(julia_project)
|
121 |
+
return processed_julia_project, is_shared
|
122 |
|
123 |
|
124 |
def is_julia_version_greater_eq(juliainfo=None, version=(1, 6, 0)):
|
|
|
158 |
from julia.core import JuliaInfo, UnsupportedPythonError
|
159 |
|
160 |
_version_assertion()
|
161 |
+
processed_julia_project, is_shared = _process_julia_project(julia_project)
|
162 |
+
_set_julia_project_env(processed_julia_project, is_shared)
|
163 |
|
164 |
try:
|
165 |
info = JuliaInfo.load(julia="julia")
|