Open aplavin opened 9 months ago
Nice! I think it's good to have a curated list of packages that can be auto-installed (instead of an auto search of all registered packages), just like in your case:
:StaticArrays => [:SVector, Symbol("@SVector")],
:Statistics => [:mean, :median, :std, :cor, :cov, :quantile],
How should we go about writing this list? How do we decide what goes in and what doesn't?
In your case the feature gives a faster dev experience in the REPL "for the pros", but what I find most exciting is that it can help Julia beginners. I think it's common to copy-paste a code snippet (eg from ChatGPT) that contains a call to a popular function like plot
or mean
and it would be cool if Pluto could help with that, instead of just "plot
not defined, did you mean splat
?"
plot
is one of the best/worst examples here, depending on how you look at it :) There are so many options: Plots, Makie (Cairo or WGL), PyPlot, ....
I think this autoinstall feature has to involve a prompt anyway, it shouldn't be fully automatic. So, if I type plot()
or weights()
, I don't really want to wait for some package installation – maybe I just want to define a function with this name myself in the notebook.
Then the question is, what should be in that prompt.
plot()
are clearly out of scope. The list can just be defined in Pluto code as a function, and users would be able to customize it by overriding Pluto.autoinstall_package_symbols() = [... my list ...]
before Pluto.run()
.Maybe, "prompt" could be as simple as Pluto adding a cell above the executed one, with the content like
using StatsBase
using # Plots, CairoMakie, WGLMakie, PyPlot, PythonPlot – uncomment one name here
The cell should just be added automatically, but not executed. Then the user either just checks it and runs, or decides which of the "ambiguous" packages they want and then runs the cell.
Pluto pioneered automatic package installation in Julia: just type
using PackageName
, and it's already there!Over the recent years, Julia REPL got features that make even more seamless exploratory experience possible. Julia itself provides auto-installation now (with a confirmation prompt), and autoloading can be added with a short
startup.jl
. Here's mine startup.jl, and below is a realtime recording of how it works. All installations are done into a temp env.Would be nice if an undefined function/macro name is detected, Pluto looked up a list of common packages and symbols, and suggest to add
using ThisPackage
to the notebook!