MilesCranmer commited on
Commit
b046fc8
1 Parent(s): 7b12257

Check backend version to avoid potential errors

Browse files
Files changed (1) hide show
  1. pysr/julia_helpers.py +18 -0
pysr/julia_helpers.py CHANGED
@@ -252,3 +252,21 @@ def _load_backend(Main, julia_project):
252
  Main.eval("using SymbolicRegression")
253
  except (JuliaError, RuntimeError) as e:
254
  raise ImportError(_import_error_string(julia_project)) from e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  Main.eval("using SymbolicRegression")
253
  except (JuliaError, RuntimeError) as e:
254
  raise ImportError(_import_error_string(julia_project)) from e
255
+
256
+ try:
257
+ backend_version = Main.eval("string(SymbolicRegression.PACKAGE_VERSION)")
258
+ expected_backend_version = __symbolic_regression_jl_version__
259
+ if backend_version != expected_backend_version: # pragma: no cover
260
+ warnings.warn(
261
+ f"PySR backend (SymbolicRegression.jl) version {backend_version} "
262
+ "does not match expected version {expected_backend_version}. "
263
+ "Things may break. "
264
+ "Please update your PySR installation."
265
+ )
266
+ except JuliaError: # pragma: no cover
267
+ warnings.warn(
268
+ "You seem to have an outdated version of SymbolicRegression.jl. "
269
+ "Things may break. "
270
+ "Please update your PySR installation with "
271
+ "`python -c 'import pysr; pysr.install()'`."
272
+ )