Closed mesonepigreco closed 9 months ago
I do not known much about julia, but I notice that init_q_opposite is not the only call to a julia function in the code without a pure python alternative. Where are this "julia.Main" to check the calling functions and look for python alternatives?
Hi Diego, the new algorith to evaluate the gradient in fourier space is only implemented in julia. The source of the julia file is at the beginning of the Ensemble.py module
__JULIA_EXT__ = False
__JULIA_ERROR__ = ""
try:
import julia, julia.Main
julia.Main.include(os.path.join(os.path.dirname(__file__),
"fourier_gradient.jl"))
__JULIA_EXT__ = True
except:
So the julia source is fourier_gradient.jl, whoch is here imported into the Main of the python-julia wrapper. Thanks to that, we can call all the functions defined in the julia source inside python, preserving the speed of the original julia code.
The variable JULIAEXT stores if there is an error in loading julia (i.e., julia is not installed) and should be used to check wether to use the julia version or the python alternative of the implementations.
Indeed, since the new algorith to compute the gradient in fourier space is only implemented in julia, there are functions that do not have a python implementation. However, there is still the version of the gradient in the previous 1.3. So in principle, if __JULIA_EXT__ is false, the code should fallback to the old gradient implementation and avoid to call functions like init_q_opposite that are needed only by the the new julia implementation. Therefore, if julia is not installed, the code should not call at all init_q_opposite. If it is doing that, or if something in init_q_opposite is necessary with the new refactoring to run the gradient calculation, then it is a bug
Thanks, I see that it tries julia tree times; one that I suppose is when called with python-jl, the other is when called with python, and the last one tries to install the julia modules.
I'll take a look at the __JULIA_EXT__
flag for when it is FALSE
to go to the old python methods.
Lorenzo, in the __init__
of class Ensemble at line 268 there is a call for the init_q_opposite()
without checking the julia library.
Thanks, that is definitvely an error. We need to check if init_q_opposite is doing some necessary stuff also for the nonJulia code, otherwise we can just put a condition on JULIAEXT before calling that function
It seems that now the issue is solved, I created a conda environment without julia and now the code works without error messages if julia is not installed.
If we try to use the new 1.4 version without julia installed in the system, there is an error in function init_q_opposite of the Ensemble.py module.
This should be avoided, as the code must run even without julia enabled before the 1.4 release