Import of several versions / branches of the module for testing in Julia

How can I use several different versions or branches of the same module in one script in Julia?

eg. If I wanted to compare each of the marked issues.

(Recently, someone asked a similar question, and I didn’t answer something, but although this may be useful in any case.)

Edit: I answered this myself, but I'm sure they can be the best way!

+5
source share
2 answers

You can just git check a different version of the module and then use benchmarkTools.jl for comparison. However, it might be better to use several scenarios (or at least ignore the first study) (see Comment Import several versions of the same module / package for benchmarking for more information. Information).

eg.

packagedir = Pkg.dir("DSP") version2checkout = "v0.0.7" run(`cd $packagedir`); run(`git checkout tags/$version2checkout`) import DSP # do all your benmarking stuff # start again 

Prevents the need for copying modules, but still a bit awkward, I think. You can even do this in a loop for multiple versions by capturing the output of the git tag

 for i in readlines(`git tag`) version2checkout = chomp(i) # checkout version and benchmark end 
+4
source

Note that Pkg.checkout accepts an optional branch argument:

 help?> Pkg.checkout checkout(pkg, [branch="master"]; merge=true, pull=true) Checkout the Pkg.dir(pkg) repo to the branch branch. Defaults to checking out the "master" branch. To go back to using the newest compatible released version, use Pkg.free(pkg). Changes are merged (fast-forward only) if the keyword argument merge == true, and the latest version is pulled from the upstream repo if pull == true. 

So you can do Pkg.checkout("MyPackage", "v0.6.0") . To ensure that the modules are reloaded, the workspace() function may be useful; or a new Julia process can be performed for each version of the package.

+1
source

All Articles