Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
eadad9f
1
Parent(s):
ea5ba6d
Turn off warning for static libpython
Browse files- .github/workflows/CI.yml +0 -2
- .github/workflows/CI_conda_forge.yml +0 -2
- pysr/sr.py +1 -18
- test/test_static_libpython_warning.py +0 -20
.github/workflows/CI.yml
CHANGED
@@ -119,8 +119,6 @@ jobs:
|
|
119 |
python3 -c 'import pysr; pysr.install()'
|
120 |
- name: "Install Coverage tool"
|
121 |
run: python3 -m pip install coverage coveralls
|
122 |
-
- name: "Ensure that static libpython warning appears"
|
123 |
-
run: coverage run --source=pysr --omit='*/feynman_problems.py' -m unittest test.test_static_libpython_warning
|
124 |
- name: "Run tests"
|
125 |
run: coverage run --append --source=pysr --omit='*/feynman_problems.py' -m unittest test.test
|
126 |
- name: Coveralls
|
|
|
119 |
python3 -c 'import pysr; pysr.install()'
|
120 |
- name: "Install Coverage tool"
|
121 |
run: python3 -m pip install coverage coveralls
|
|
|
|
|
122 |
- name: "Run tests"
|
123 |
run: coverage run --append --source=pysr --omit='*/feynman_problems.py' -m unittest test.test
|
124 |
- name: Coveralls
|
.github/workflows/CI_conda_forge.yml
CHANGED
@@ -35,7 +35,5 @@ jobs:
|
|
35 |
run: conda activate test && mamba install pysr
|
36 |
- name: "Set up PySR's Julia dependencies"
|
37 |
run: conda activate test && python3 -c 'import pysr; pysr.install()'
|
38 |
-
- name: "Ensure that static libpython warning appears"
|
39 |
-
run: conda activate test && python3 -m unittest test.test_static_libpython_warning
|
40 |
- name: "Run tests"
|
41 |
run: conda activate test && python3 -m unittest test.test
|
|
|
35 |
run: conda activate test && mamba install pysr
|
36 |
- name: "Set up PySR's Julia dependencies"
|
37 |
run: conda activate test && python3 -c 'import pysr; pysr.install()'
|
|
|
|
|
38 |
- name: "Run tests"
|
39 |
run: conda activate test && python3 -m unittest test.test
|
pysr/sr.py
CHANGED
@@ -17,8 +17,6 @@ from hashlib import sha256
|
|
17 |
|
18 |
from .version import __version__, __symbolic_regression_jl_version__
|
19 |
|
20 |
-
is_julia_warning_silenced = False
|
21 |
-
|
22 |
|
23 |
def install(julia_project=None, quiet=False): # pragma: no cover
|
24 |
"""Install PyCall.jl and all required dependencies for SymbolicRegression.jl.
|
@@ -296,11 +294,6 @@ def _get_julia_project(julia_project):
|
|
296 |
return julia_project, is_shared
|
297 |
|
298 |
|
299 |
-
def silence_julia_warning():
|
300 |
-
global is_julia_warning_silenced
|
301 |
-
is_julia_warning_silenced = True
|
302 |
-
|
303 |
-
|
304 |
def is_julia_version_greater_eq(Main, version="1.6"):
|
305 |
"""Check if Julia version is greater than specified version."""
|
306 |
return Main.eval(f'VERSION >= v"{version}"')
|
@@ -308,7 +301,6 @@ def is_julia_version_greater_eq(Main, version="1.6"):
|
|
308 |
|
309 |
def init_julia():
|
310 |
"""Initialize julia binary, turning off compiled modules if needed."""
|
311 |
-
global is_julia_warning_silenced
|
312 |
from julia.core import JuliaInfo, UnsupportedPythonError
|
313 |
|
314 |
try:
|
@@ -328,16 +320,7 @@ def init_julia():
|
|
328 |
|
329 |
Main = _Main
|
330 |
except UnsupportedPythonError:
|
331 |
-
|
332 |
-
warnings.warn(
|
333 |
-
"""
|
334 |
-
Your Python version is statically linked to libpython. For example, this could be the python included with conda, or maybe your system's built-in python.
|
335 |
-
This will still work, but the precompilation cache for Julia will be turned off, which may result in slower startup times on the initial pysr() call.
|
336 |
-
|
337 |
-
To install a Python version that is dynamically linked to libpython, pyenv is recommended (https://github.com/pyenv/pyenv). With pyenv, you can run: `PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.10` to install Python 3.9.10 with dynamic linking.
|
338 |
-
|
339 |
-
To silence this warning, you can run pysr.silence_julia_warning() after importing pysr."""
|
340 |
-
)
|
341 |
from julia.core import Julia
|
342 |
|
343 |
jl = Julia(compiled_modules=False)
|
|
|
17 |
|
18 |
from .version import __version__, __symbolic_regression_jl_version__
|
19 |
|
|
|
|
|
20 |
|
21 |
def install(julia_project=None, quiet=False): # pragma: no cover
|
22 |
"""Install PyCall.jl and all required dependencies for SymbolicRegression.jl.
|
|
|
294 |
return julia_project, is_shared
|
295 |
|
296 |
|
|
|
|
|
|
|
|
|
|
|
297 |
def is_julia_version_greater_eq(Main, version="1.6"):
|
298 |
"""Check if Julia version is greater than specified version."""
|
299 |
return Main.eval(f'VERSION >= v"{version}"')
|
|
|
301 |
|
302 |
def init_julia():
|
303 |
"""Initialize julia binary, turning off compiled modules if needed."""
|
|
|
304 |
from julia.core import JuliaInfo, UnsupportedPythonError
|
305 |
|
306 |
try:
|
|
|
320 |
|
321 |
Main = _Main
|
322 |
except UnsupportedPythonError:
|
323 |
+
# Static python binary, so we turn off pre-compiled modules.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
from julia.core import Julia
|
325 |
|
326 |
jl = Julia(compiled_modules=False)
|
test/test_static_libpython_warning.py
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
"""Test that running PySR with static libpython raises a warning.
|
2 |
-
|
3 |
-
Note: This test will ONLY pass with statically-linked python binaries, such
|
4 |
-
as provided by conda. It will not pass on other versions of python, and that is
|
5 |
-
okay."""
|
6 |
-
|
7 |
-
import unittest
|
8 |
-
import warnings
|
9 |
-
import pysr
|
10 |
-
|
11 |
-
# Taken from https://stackoverflow.com/a/14463362/2689923
|
12 |
-
class TestLibpythonWarning(unittest.TestCase):
|
13 |
-
def test_warning(self):
|
14 |
-
with warnings.catch_warnings(record=True) as warning_catcher:
|
15 |
-
warnings.simplefilter("always")
|
16 |
-
pysr.sr.init_julia()
|
17 |
-
|
18 |
-
self.assertEqual(len(warning_catcher), 1)
|
19 |
-
self.assertTrue(issubclass(warning_catcher[-1].category, UserWarning))
|
20 |
-
self.assertIn("static", str(warning_catcher[-1].message))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|