Spaces:
Sleeping
Sleeping
File size: 1,150 Bytes
ce60798 8cf4bf3 7ea0b2f e530637 caf58a4 d72c643 44ff874 4037c2d 6baa534 8cf4bf3 6baa534 80fecb9 6baa534 4bc0a76 68ea1be a4bb529 d72c643 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
"""Functions for initializing the Julia environment and installing deps."""
import warnings
from juliacall import convert as jl_convert # type: ignore
from .julia_import import jl
jl.seval("using Serialization: Serialization")
jl.seval("using PythonCall: PythonCall")
def install(*args, **kwargs):
del args, kwargs
warnings.warn(
"The `install` function has been removed. "
"PySR now uses the `juliacall` package to install its dependencies automatically at import time. "
)
def _escape_filename(filename):
"""Turn a path into a string with correctly escaped backslashes."""
str_repr = str(filename)
str_repr = str_repr.replace("\\", "\\\\")
return str_repr
def _load_cluster_manager(cluster_manager):
jl.seval(f"using ClusterManagers: addprocs_{cluster_manager}")
return jl.seval(f"addprocs_{cluster_manager}")
def jl_array(x):
if x is None:
return None
return jl_convert(jl.Array, x)
def jl_deserialize_s(s):
if s is None:
return s
buf = jl.IOBuffer()
jl.write(buf, jl_array(s))
jl.seekstart(buf)
return jl.Serialization.deserialize(buf)
|