Skip to content

Commit

Permalink
Standard names for JuliaCall env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Feb 10, 2024
1 parent 46f8a60 commit 7acebb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pysr/julia_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
warnings.warn(
"juliacall module already imported. "
"Make sure that you have set the environment variable `PYTHON_JULIACALL_HANDLE_SIGNALS=yes` to avoid segfaults. "
"Also note that PySR will not be able to configure `JULIA_NUM_THREADS` or `JULIA_OPTIMIZE` for you."
"Also note that PySR will not be able to configure `PYTHON_JULIACALL_THREADS` or `PYTHON_JULIACALL_OPTLEVEL` for you."
)
else:
# Required to avoid segfaults (https://juliapy.github.io/PythonCall.jl/dev/faq/)
Expand All @@ -19,18 +19,18 @@
+ "You will experience segfaults if running with multithreading."
)

if os.environ.get("JULIA_NUM_THREADS", "auto") != "auto":
if os.environ.get("PYTHON_JULIACALL_THREADS", "auto") != "auto":
warnings.warn(
"JULIA_NUM_THREADS environment variable is set to something other than 'auto', "
"PYTHON_JULIACALL_THREADS environment variable is set to something other than 'auto', "
"so PySR was not able to set it. You may wish to set it to `'auto'` for full use "
"of your CPU."
)

# TODO: Remove these when juliapkg lets you specify this
for k, default in (
("PYTHON_JULIACALL_HANDLE_SIGNALS", "yes"),
("JULIA_NUM_THREADS", "auto"),
("JULIA_OPTIMIZE", "3"),
("PYTHON_JULIACALL_THREADS", "auto"),
("PYTHON_JULIACALL_OPTLEVEL", "3"),
):
os.environ[k] = os.environ.get(k, default)

Expand Down
4 changes: 2 additions & 2 deletions pysr/test/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def test_bad_startup_options(self):
msg="PYTHON_JULIACALL_HANDLE_SIGNALS environment variable is set",
),
dict(
code='import os; os.environ["JULIA_NUM_THREADS"] = "1"; import pysr',
msg="JULIA_NUM_THREADS environment variable is set",
code='import os; os.environ["PYTHON_JULIACALL_THREADS"] = "1"; import pysr',
msg="PYTHON_JULIACALL_THREADS environment variable is set",
),
dict(
code="import juliacall; import pysr",
Expand Down

0 comments on commit 7acebb6

Please sign in to comment.