cstjean / ScikitLearn.jl

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

Problem with python scikit-learn version numbers: eg, 0.22.2.post1 #67

Closed ablaom closed 4 years ago

ablaom commented 4 years ago

Not sure if this is a ScikitLearn or PyCall problem, but I'm having problems using this "post1" version of scikit-learn:

(py37) humus:sandbox anthony$ conda list
# packages in environment at /Users/anthony/anaconda2/envs/py37:
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h0b31af3_2    conda-forge
...
scikit-learn              0.22.2.post1     py37h3dc85bc_0    conda-forge
julia> using ScikitLearn
[ Info: Precompiling ScikitLearn [3646fa90-6ef7-5e7e-9f22-8aca16db6324]

julia> @sk_import linear_model: LogisticRegression
ERROR: ArgumentError: invalid version string: 0.22.2.post1
Stacktrace:
 [1] VersionNumber(::String) at ./version.jl:111
 [2] import_sklearn() at /Users/anthony/.julia/packages/ScikitLearn/bo2Pt/src/Skcore.jl:120
 [3] top-level scope at /Users/anthony/.julia/packages/ScikitLearn/bo2Pt/src/Skcore.jl:153

julia> Pkg.status()
    Status `~/Dropbox/Julia7/MLJ/MLJ/sandbox/junkkk/Project.toml`
  [3646fa90] ScikitLearn v0.5.1

julia> versioninfo()
Julia Version 1.3.0
Commit 46ce4d7933 (2019-11-26 06:09 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.0.0)
  CPU: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_PATH = /Applications/Julia-1.3.app/Contents/Resources/julia/bin/julia
cstjean commented 4 years ago
function import_sklearn()
    global import_already_warned
    mod = PyCall.pyimport_conda("sklearn", "scikit-learn")
    version = VersionNumber(mod.__version__)

VersionNumber is a base function. Apparently 0.22.2post isn't valid according to julia's semver interpretation. I'm assuming that this post is a bit like a prerelease? Then I don't think we should modify the code, but if you want to use bypass the check, I'd recommend just redefining the function interactively to:

ScikitLearn.Skcore.import_sklearn() = PyCall.pyimport_conda("sklearn", "scikit-learn")
stevengj commented 4 years ago

In general you cannot expect non-Julia packages to follow the semver spec for version numbers. To parse version numbers of Python packages, use the https://github.com/stevengj/VersionParsing.jl package.

OkonSamuel commented 4 years ago

@ablaom i'll close this now

stevengj commented 4 years ago

You're still not using VersionParsing, so this doesn't seem resolved?