I am exploring SciML with Julia and found that the best way to experiment with Julia advanced feature without touchingt the core OS was using Devcontainers via vscode. This could be useful for beginners.
This is is simplest Devcontainer I was able to build in 47 lines, and includes:
- Julia
- Quarto
- JupyterLab
- Essential SciML libraries
- Python 3 (to test PyCall)
- Examples
Requirements
- Docker
- VS Code
- VSCode Extensions:
Dev Containers
Files
devcontainer.json
{
"name": "JuliaQuartoPycall",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
// A Feature to install Julia via juliaup. More info: https://github.com/JuliaLang/devcontainer-features/tree/main/src/julia.
"ghcr.io/julialang/devcontainer-features/julia:1": {
"channel": "release"
},
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"configureZshAsDefaultShell": true,
"username": "vscode",
"upgradePackages": "true"
},
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
"version": "latest",
"installTinyTex": false,
"installChromium": false
},
// A comma separated list of Linux packages
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
"packages": "libpython3-dev,python3-dev,python3-pip,qpdf"
}
},
"onCreateCommand": "pip install --no-cache-dir jupyterlab jupyterlab-git jupyterlab-lsp notebook nbclassic nbconvert",
"postCreateCommand": "julia ./.devcontainer/pkgs.jl",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"julialang.language-julia",
"tamasfe.even-better-toml",
"ms-python.python",
"ms-toolsai.jupyter"
]
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
pkgs.jl
using Pkg
# Pkg.add("BandedMatrices")
# Pkg.add("BenchmarkTools")
# Pkg.add("BlockBandedMatrices")
Pkg.add("ComponentArrays")
Pkg.add("Conda")
# Pkg.add("CSV")
# Pkg.add("Dates")
Pkg.add(["DataDrivenDiffEq", "DataDrivenSparse"])
# Pkg.add("DataFrames")
# Pkg.add("DelimitedFiles")
Pkg.add("DifferentialEquations")
# Pkg.add("Distributions")
# Pkg.add("Flux")
Pkg.add("ForwardDiff")
# Pkg.add("GLM")
# Pkg.add("HypothesisTests")
# Pkg.add(["Images", "ImageMagick"])
Pkg.add("IJulia")
# Pkg.add("IterativeSolvers")
# Pkg.add("JLD")
# Pkg.add("KernelDensity")
# Pkg.add("KrylovKit")
# Pkg.add("Libdl")
Pkg.add("LinearAlgebra")
Pkg.add("LineSearches")
# Pkg.add("LsqFit")
Pkg.add("Lux")
Pkg.add("MAT")
# Pkg.add("MatrixDepot")
# Pkg.add("Measurements")
# Pkg.add("Metalhead")
# Pkg.add("MLBase")
Pkg.add("ModelingToolkit")
Pkg.add("NonlinearSolve")
Pkg.add(["Optimization", "OptimizationNLopt", "OptimizationPolyalgorithms"])
Pkg.add(["OptimizationOptimisers", "OptimizationOptimJL"])
Pkg.add("OrdinaryDiffEq")
Pkg.add("NPZ")
Pkg.add("Plots")
# Pkg.add("Primes")
Pkg.add("PyCall")
# Pkg.add("Printf")
# Pkg.add("RData")
# Pkg.add("RDatasets")
Pkg.add("SciMLSensitivity")
# Pkg.add("SparseArrays")
Pkg.add("StableRNGs")
Pkg.add("Statistics")
# Pkg.add("StatsBase")
# Pkg.add("StatsPlots")
Pkg.add("SymPy")
# Pkg.add("Tables")
# Pkg.add("Test")
# Pkg.add("TSVD")
Pkg.add("UnicodePlots")
# Pkg.add("Unitful")
# Pkg.add("XLSX")
Pkg.add("Zygote")
# ENV["PYCALL_DEBUG_BUILD"] = "yes"
Pkg.build("IJulia")
Pkg.build("PyCall")
Pkg.precompile()
File, folder structure
Installation
- Create a folder, let’s say
julia-quarto-pycall
- Create a sub-folder
.devcontainer
- Copy the two files
devcontainer.json
andpkgs.jl
under the sub-folder.devcontainer
- Open the folder
julia-quarto-pycall
with VS Code - Press the green button on the bottom left corner of the IDE, and select “Reopen in Container”. That will start the building process.
- Run any Julia file (.jl) or Julia Jupyter notebook (.ipynb) from the IDE.
- That’s it
Link: Dropbox