cstjean / ScikitLearn.jl

Julia implementation of the scikit-learn API https://cstjean.github.io/ScikitLearn.jl/dev/
Other
547 stars 75 forks source link

package error when calling fit! - windows only #128

Open odunbar opened 6 months ago

odunbar commented 6 months ago

First, thanks a lot for this great interface.

I have some failing code on Windows machines (but passes on Mac and Linux). It fails across a range of Julia, scikit-learn and scipy versions.

I wondered if you can reproduce it, or have seen similar issues before. To me it seems it could be a cross-language issue rather than a scikitlearn package issue?

Recreating the error

Install julia packages to a project with their latest available versions (Conda v1.10.0,Pycall v1.96.4, SciKitLearn v0.7.0)

Install python packages are installed on windows with

julia --project -e 'using Conda; Conda.add(\"scipy=1.11.4\")'
julia --project -e 'using Conda; Conda.add(\"scikit-learn=1.3.2\")'

(linux/mac is the same but with " replacing \")

Create the following script:

using PyCall
using ScikitLearn
const pykernels = PyNULL()
const pyGP = PyNULL()

function init()
    copy!(pykernels, pyimport_conda("sklearn.gaussian_process.kernels", "scikit-learn=1.3.2"))
    copy!(pyGP, pyimport_conda("sklearn.gaussian_process", "scikit-learn=1.3.2"))
end

function minimal_failing_example()
    # some kind of kernel
    kernel = pykernels.ConstantKernel(constant_value = 1.0)

    # some data
    n = 20                                       # number of training points
    x = reshape(2.0 * π * rand(n), 1, n)         # predictors/features: 1 x n
    y = reshape(sin.(x) + 0.05 * randn(n)', 1, n) # predictands/targets: 1 x n

    # the model
    m = pyGP.GaussianProcessRegressor(kernel = kernel)

    # call fit!
    ScikitLearn.fit!(m, x, y)
    @info "fit successful"
end

init()
minimal_failing_example()

Result (e.g on Julia 1.10)

with linux/mac i get

[ Info: fit successful

With windows I get a very opaque exit code, I have checked this occurs precisely when fit! is called

ERROR: Package MyPackage errored during testing (exit code: 3228369022)
Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types C:\hostedtoolcache\windows\julia\1.10.0\x64\share\julia\stdlib\v1.10\Pkg\src\Types.jl:70
 [2] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, julia_args::Cmd, test_args::Cmd, test_fn::Nothing, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
   @ Pkg.Operations C:\hostedtoolcache\windows\julia\1.10.0\x64\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:2018
 [3] test
   @ C:\hostedtoolcache\windows\julia\1.10.0\x64\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1899 [inlined]
 [4] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, test_fn::Nothing, julia_args::Cmd, test_args::Cmd, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool, kwargs::@Kwargs{io::Base.PipeEndpoint})
   @ Pkg.API C:\hostedtoolcache\windows\julia\1.10.0\x64\share\julia\stdlib\v1.10\Pkg\src\API.jl:444
 [5] test(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.PipeEndpoint, kwargs::@Kwargs{})
   @ Pkg.API C:\hostedtoolcache\windows\julia\1.10.0\x64\share\julia\stdlib\v1.10\Pkg\src\API.jl:159
 [6] test(pkgs::Vector{Pkg.Types.PackageSpec})
   @ Pkg.API C:\hostedtoolcache\windows\julia\1.10.0\x64\share\julia\stdlib\v1.10\Pkg\src\API.jl:148
 [7] test(; name::Nothing, uuid::Nothing, version::Nothing, url::Nothing, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::@Kwargs{})
   @ Pkg.API C:\hostedtoolcache\windows\julia\1.10.0\x64\share\julia\stdlib\v1.10\Pkg\src\API.jl:174
 [8] test()
   @ Pkg.API C:\hostedtoolcache\windows\julia\1.10.0\x64\share\julia\stdlib\v1.10\Pkg\src\API.jl:165
 [9] top-level scope
   @ none:1
Error: Process completed with exit code 1.

(NB the MyPackage reference is just because I use the github actions test-suite of this package to run the example easily over the different operating systems. The example is simply included at the very start of the test pipeline, and the package is not involved)

cstjean commented 6 months ago

Yikes, that is very opaque indeed. Never seen it! I don't think there's much we can do here. Google has some results for it. Maybe it's antivirus software? Let me know if you can narrow it down to something ScikitLearn-related.

odunbar commented 6 months ago

Yeah - I definitely wouldn't rule it out as being something else. I was primarily suspicious of this package as it only seems to occur when calling the SciKitLearn.jl method fit!( and I haven't found other instances yet.