QuantEcon / lecture-source-jl

Source files for "Lectures in Quantitative Economics" -- Julia version
https://julia.quantecon.org
BSD 3-Clause "New" or "Revised" License
131 stars 53 forks source link

Add precompiling some key packages to colab to increase perceived speed #836

Closed jlperla closed 4 years ago

jlperla commented 4 years ago

We can't precompile everything, but it might help to precompile the most commonly used packages? Maybe try changing https://github.com/QuantEcon/lecture-source-jl/blob/master/source/_static/includes/colab_code_cell.txt to soemthing like


wget 'https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.1-linux-x86_64.tar.gz' \
    -O /tmp/julia.tar.gz
tar -x -f /tmp/julia.tar.gz -C /usr/local --strip-components 1
rm /tmp/julia.tar.gz
julia -e 'using Pkg; pkg"add IJulia InstantiateFromURL; precompile;"'
julia -e 'using InstantiateFromURL; github_project("QuantEcon/quantecon-notebooks-julia", version = "0.5.0", instantiate = true, precompile = false);using Plots, Distributions, Parameters, NLsolve, ForwardDiff, Expectations'
echo 'Done'

Alternatively you could have another line there where you run julia with `julia --project=@. -e 'using Plots, Distributions, Parameters, NLsolve, ForwardDiff, Expectations"'

Or something like that... I think if this adds 3-4'ish minutes to the setup, it is probably worth it for the better experience post installation. Plots would always be used, and I think most of the others are relatively fast.

The other changes there: We need to put in the version number, and to modify this when we bump versions along with the other file there.

I found that preventing reinstallation with a if ! command -v julia 3>&1 > /dev/null may have been useless since after juila installation, the %% python magic wasn't even supported?

arnavs commented 4 years ago

This should be closed, I tried it and worked well.