What would it take to bring this Julia 0.6 package to Julia 1.6?

Hi,

I found myself in a position where i need to solve a fully constraint lasso. There is a package there : GitHub - Hua-Zhou/ConstrainedLasso.jl: Algorithms for fit constrained lasso that does exactly what i need, but it’s old and works on Julia 0.6.

I’m not familiar with the differences between old and current Julia. What would it take to have this package work on current Julia 1.6 ? Would it need a full rewrite of the main code, or just a rewrite of the flourishes around the core componants of the package?

Is there some documentations on how to do that ?

1 Like

Best is to use it in Julia 0.7
You will get quite detailed deprecation notes with suggestions (if I remember well).

2 Likes

I do have code that i need to interact with that is already in current julia format, and downgrading it would probably be a pain. Which is why i asked.

Edit: Nevermind I did not understood what you meant. Ok so loading it in Julia 0.7 will give me deprecation notices that would help me port it to Julia 1.0 ?

You can just run the tests of CL.jl on Julia 0.7. Hopefully those would cover all to update it to Julia 1.0. Once it runs on 1.0, it will run on 1.6.

2 Likes

I meant not to use it for your real problem but just use it in 0.7 to get the deprecations and suggestions. Perhaps it’s not so much to do to change everything in this package to make it run in 1.6.
For what I have done in these days it wasn’t much work and quite easy.

2 Likes

Would’nt it be easier to start with a fresh Pkg.Skeleton and copy sources and tests over the new interface until everything works ?

Depends on the size of the package ( I didn’t checked ).
And perhaps you could try to become the maintainer of this package for the future?

I posted an issue, we’ll see if the developper wants to keep it or agrees to give it to me.

In 0.7, after instlal, i have :

(v0.7) pkg> test ConstrainedLasso
   Testing ConstrainedLasso
 Resolving package versions...
    Status `C:\Users\u009192\AppData\Local\Temp\jl_5C93.tmp\Manifest.toml`
  [7d9fca2a] Arpack v0.3.2
  [9e28174c] BinDeps v0.8.10
  [b99e7846] BinaryProvider v0.5.10
  [34da2185] Compat v2.2.1
  [7e327ae7] ConstrainedLasso v0.0.0 [`C:\Users\u009192\.julia\dev\ConstrainedLasso`]
  [f65535da] Convex v0.11.3
  [864edb3b] DataStructures v0.16.1
  [31c24e10] Distributions v0.18.0
  [e2685f51] ECOS v0.9.4
  [8d5ece8b] GLMNet v0.4.2
  [b8f27783] MathOptInterface v0.8.4
  [fdba3010] MathProgBase v0.7.7
  [e1d29d7a] Missings v0.4.0
  [bac558e1] OrderedCollections v1.4.0
  [90014a1f] PDMats v0.9.12
  [1fd47b50] QuadGK v2.4.1
  [79098fc4] Rmath v0.5.1
  [a2af1166] SortingAlgorithms v0.3.1
  [276daf66] SpecialFunctions v0.7.2
  [2913bbd2] StatsBase v0.29.0
  [4c63d2b9] StatsFuns v0.8.0
  [30578b45] URIParser v0.4.1
  [2a0f44e3] Base64  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Base64`]
  [ade2ca70] Dates  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Dates`]
  [8bb1440f] DelimitedFiles  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\DelimitedFiles`]
  [8ba89e20] Distributed  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Distributed`]
  [b77e0a4c] InteractiveUtils  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\InteractiveUtils`]
  [76f85450] LibGit2  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\LibGit2`]
  [8f399da3] Libdl  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Libdl`]
  [37e2e46d] LinearAlgebra  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\LinearAlgebra`]
  [56ddb016] Logging  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Logging`]
  [d6f4376e] Markdown  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Markdown`]
  [a63ad114] Mmap  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Mmap`]
  [44cfe95a] Pkg  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Pkg`]
  [de0858da] Printf  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Printf`]
  [3fa0cd96] REPL  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\REPL`]
  [9a3f8284] Random  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Random`]
  [ea8e919c] SHA  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\SHA`]
  [9e88b42a] Serialization  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Serialization`]
  [1a1011a3] SharedArrays  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\SharedArrays`]
  [6462fe0b] Sockets  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Sockets`]
  [2f01184e] SparseArrays  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\SparseArrays`]
  [10745b16] Statistics  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Statistics`]
  [4607b0f0] SuiteSparse  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\SuiteSparse`]
  [8dfed614] Test  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Test`]
  [cf7118a7] UUIDs  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\UUIDs`]
  [4ec0a83e] Unicode  [`C:\Users\u009192\AppData\Local\Julia-0.7.0\bin\..\share\julia\stdlib\v0.7\Unicode`]
WARNING: Base.Test is deprecated, run `using Test` instead
  likely near C:\Users\u009192\.julia\dev\ConstrainedLasso\test\constrsparsereg_test.jl:3
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
INFO: Test lsq_constrsparsereg: sum-to-zero constraint
WARNING: importing deprecated binding Base.srand into constrsparsereg_test.
WARNING: Base.srand is deprecated: it has been moved to the standard library package `Random`.
Add `using Random` to your imports.
  likely near C:\Users\u009192\.julia\dev\ConstrainedLasso\test\constrsparsereg_test.jl:8
┌ Warning: `srand` is deprecated, use `Random.seed!` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
┌ Warning: using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= x` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
┌ Warning: using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= x` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
┌ Warning: using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= x` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
┌ Warning: using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= x` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
INFO: Optimize at a single tuning parameter value
ERROR: LoadError: LoadError: MethodError: no method matching sqrt(::Array{Float64,1})
Closest candidates are:
  sqrt(::Float16) at math.jl:1004
  sqrt(::Complex{Float16}) at math.jl:1005
  sqrt(::Missing) at math.jl:1056
  ...
Stacktrace:
 [1] #lsq_constrsparsereg#1(::Array{Float64,2}, ::Array{Float64,1}, ::Array{Float64,2}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Bool, ::ECOS.ECOSSolver, ::typeof(ConstrainedLasso.lsq_constrsparsereg), ::Array{Float64,2}, ::Array{Float64,1}, ::Float64) at C:\Users\u009192\.julia\dev\ConstrainedLasso\src\constrsparsereg.jl:66
 [2] (::getfield(ConstrainedLasso, Symbol("#kw##lsq_constrsparsereg")))(::NamedTuple{(:Aeq, :beq, :penwt, :solver),Tuple{Array{Float64,2},Array{Float64,1},Array{Float64,1},ECOS.ECOSSolver}}, ::typeof(ConstrainedLasso.lsq_constrsparsereg), ::Array{Float64,2}, ::Array{Float64,1}, ::Float64) at .\none:0
 [3] top-level scope at none:0
 [4] include at .\boot.jl:317 [inlined]
 [5] include_relative(::Module, ::String) at .\loading.jl:1038
 [6] include at .\sysimg.jl:29 [inlined]
 [7] include(::String) at C:\Users\u009192\.julia\dev\ConstrainedLasso\test\runtests.jl:1
 [8] top-level scope at none:0
 [9] include at .\boot.jl:317 [inlined]
 [10] include_relative(::Module, ::String) at .\loading.jl:1038
 [11] include(::Module, ::String) at .\sysimg.jl:29
 [12] include(::String) at .\client.jl:398
 [13] top-level scope at none:0
in expression starting at C:\Users\u009192\.julia\dev\ConstrainedLasso\test\constrsparsereg_test.jl:26
in expression starting at C:\Users\u009192\.julia\dev\ConstrainedLasso\test\runtests.jl:3
ERROR: Package ConstrainedLasso errored during testing

(v0.7) pkg> ^

Seems like there might be a lot to do.

Edit: To be sure that i am in the right track, is it the right thing to do to dev the package in Julia 0.7, make modifications and commits until tests passes, and then try the same repo on Julia 1.6 directly ?

No, not so much :wink:
4 things:

`srand` is deprecated, use `Random.seed!` instead
Warning: using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= x` instead.
Warning: `info()` is deprecated, use `@info` instead.
sqrt(::Array{Float64,1})

The last one should probably become

sqrt.(::Array{Float64,1})
3 Likes

Sounds good to me (but I haven’t done it like that so I can’t tell from experience).
I don’t even know if the dev thing was already there in 0.7, but you will see.

It was not ><"

I actually expect more to come after you fixed those 4 :wink:

Me to. This would probably be a pain. Was Revise a thing on 0.7 ? What was the way to dev a package on 0.7 ? I’m an archeologist today !

I have the following:

(v0.7) pkg> develop ConstrainedLasso
ERROR: The following package names could not be resolved:
 * ConstrainedLasso (7e327ae7-2474-5f1d-becc-899fe7a0c896 in manifest but not in project)
Please specify by known `name=uuid`.

I do not unserstand as i added it…

This was wrong

I started to correct some bugs and stuff, no i have the follwoing error that i do not understand:

MethodError: no method matching sumsquares(::Array{Convex.MultiplyAtom,1})

(v0.7) pkg> rm ConstrainedLasso

(v0.7) pkg> dev ConstrainedLasso

created the project in the dev folder for me.

Yes i managed to create it in the dev folder also.

i’m now going throughthe bugs. It seems like the handling of broadcast was not the same on 0.7…

I think you should be able to get through it in a few hours (unless you hit some hard to debug edge-case).

x-ref: PSA: use Julia 0.7 if you are upgrading - #11 by jlapeyre and tips therein.

Thnaks for the help so far !

I’m now at a point where, making all modifications requested by the deprecations warnings, the tests do not pass…

I forked the repo there : GitHub - lrnv/ConstrainedLasso.jl: Algorithms for fit constrained lasso and added a first commit with some modifs, would you mind looking at the diff ? Maybe you’ll see something that I missed.