SciML / diffeqpy

Solving differential equations in Python using DifferentialEquations.jl and the SciML Scientific Machine Learning organization
MIT License
508 stars 39 forks source link

FYI: Support PythonCall.jl #97

Closed PallHaraldsson closed 8 months ago

PallHaraldsson commented 2 years ago

https://cjdoris.github.io/PythonCall.jl/stable/juliacall/#Installation

I checked it myself and it does download Julia for you, as claimed (1.7) and its example works. So I tried with your package to see if it worked too, but got some PyCall error, understandably. I just think if might help your users to not have to download or know much about Julia. I've not used PythonCall extensively myself. It does have a larger startup cost (currently, I have a PR coming up bringing down to 3.06 sec. maybe further).

julia> @time using PythonCall
  4.431433 seconds (2.88 M allocations: 164.448 MiB, 1.13% gc time, 82.64% compilation time)

julia> @time using PyCall
  0.978491 seconds (963.43 k allocations: 62.176 MiB, 1.16% gc time, 73.61% compilation time)

compared to:

$ ~/julia-1.7.0/bin/julia -O0 --compile=min

julia> @time using PythonCall
  1.051802 seconds (816.71 k allocations: 58.820 MiB, 1.40% gc time, 17.52% compilation time)

julia> @time using PyCall
  0.630133 seconds (484.69 k allocations: 35.356 MiB, 52.99% compilation time)

PyCall didn't work right away, I had to build it.

sibyjackgrove commented 2 years ago

@PallHaraldsson Have you compared JuliaCall with PyJulia? Diffeqpy uses PyJulia for calling Julia from Python.

PallHaraldsson commented 2 years ago

I haven't used PythonCall much but it compares to PyJulia. I realize PyJulia is currently used, I'm not sure PythonCall could be a non-default option, might be confusing to have two options. It might be better to support PythonCall only.

ChrisRackauckas commented 2 years ago

Having two options is untenable. Really it needs to be one well-supported one. If it's just the Julia installation, right now it seems like pyjulia with https://github.com/JuliaPy/pyjulia/issues/473 might be best. I would be happy if @00sapo could help us figure out a nice solution for automating the diffeqpy installation.

PallHaraldsson commented 2 years ago

PythonCall already downloads Julia for you, that was my main reason for proposing the change, otherwise your call.

ChrisRackauckas commented 2 years ago

That's a gigantic change. If you're willing to do all of that work then go for it.

00sapo commented 2 years ago

Hello, I did some comparisons that you can use for your use case to check if juliacall is as performant as pyjulia: https://github.com/00sapo/pyjulia-vs-juliacall. If you do that, feel free to send a PR.

In that project there are also usable examples of how mu proposal https://github.com/JuliaPy/pyjulia/issues/473 can be used, and it's compared with juliacall approach.

Juliacall downloads Julia at the first usage, I don't actually like this way of working. My function can be used on the user need. Morever , on my system (Linux Manjaro), my function can reliably detect the existing Julia version, JuliaCall can't do that.

Maybe, we could create a separate python package that simply provides this function and other tools if needed (e.g. a pre-compiled environment to improve startup time).

jlapeyre commented 2 years ago

There are very big differences between PythonCall and PyJulia. The fact that one downloads julia automatically is a minor detail in comparison. It shouldn't determine the choice--- like buying car because you like the cup holder. For example, the script that Chris linked to or something like it would be reasonable for automatic downloading.

ChrisRackauckas commented 8 months ago

Now done via PythonCall