Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
32b2f6e
1
Parent(s):
2abf017
Automatically check if juliacall was already imported
Browse files- pysr/julia_helpers.py +7 -1
pysr/julia_helpers.py
CHANGED
@@ -1,7 +1,13 @@
|
|
1 |
"""Functions for initializing the Julia environment and installing deps."""
|
2 |
import os
|
|
|
3 |
import warnings
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
# Required to avoid segfaults (https://juliapy.github.io/PythonCall.jl/dev/faq/)
|
6 |
if os.environ.get("PYTHON_JULIACALL_HANDLE_SIGNALS", "yes") != "yes":
|
7 |
warnings.warn(
|
@@ -10,7 +16,7 @@ if os.environ.get("PYTHON_JULIACALL_HANDLE_SIGNALS", "yes") != "yes":
|
|
10 |
)
|
11 |
|
12 |
os.environ["PYTHON_JULIACALL_HANDLE_SIGNALS"] = "yes"
|
13 |
-
os.environ["JULIA_NUM_THREADS"] = "auto"
|
14 |
|
15 |
import juliapkg
|
16 |
from juliacall import Main as jl
|
|
|
1 |
"""Functions for initializing the Julia environment and installing deps."""
|
2 |
import os
|
3 |
+
import sys
|
4 |
import warnings
|
5 |
|
6 |
+
if "juliacall" in sys.modules:
|
7 |
+
warnings.warn(
|
8 |
+
"juliacall module already imported. Make sure that you have set `PYTHON_JULIACALL_HANDLE_SIGNALS=yes` to avoid segfaults."
|
9 |
+
)
|
10 |
+
|
11 |
# Required to avoid segfaults (https://juliapy.github.io/PythonCall.jl/dev/faq/)
|
12 |
if os.environ.get("PYTHON_JULIACALL_HANDLE_SIGNALS", "yes") != "yes":
|
13 |
warnings.warn(
|
|
|
16 |
)
|
17 |
|
18 |
os.environ["PYTHON_JULIACALL_HANDLE_SIGNALS"] = "yes"
|
19 |
+
os.environ["JULIA_NUM_THREADS"] = os.environ.get("JULIA_NUM_THREADS", "auto")
|
20 |
|
21 |
import juliapkg
|
22 |
from juliacall import Main as jl
|