Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 5 additions & 31 deletions tools/combine_pkg_envs.jl
Original file line number Diff line number Diff line change
@@ -1,43 +1,17 @@
if !isdir("pluto-deployment-environment") || length(ARGS) != 1
include("./common.jl")

if length(ARGS) != 1
error("""
Run me from the root of the repository directory, using:
Syntax:

julia tools/combine_pkg_envs.jl <update (true or false)>
julia tools/$(basename(@__FILE__)) <update (true or false)>

Where <update> is true or false to update all packages as well.
""")
end

update = parse(Bool, ARGS[1])

import Pkg
Pkg.activate("./pluto-deployment-environment")
Pkg.instantiate()
import Pluto
ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0



# Find all notebooks
lectures_dir = joinpath(@__DIR__, "..", "lectures")
prob_prog_dir = joinpath(@__DIR__, "..", "probprog")
minis_dir = joinpath(@__DIR__, "..", "minis")
ignore_dir = joinpath(@__DIR__, "..", "ignore_dir")

all_notebooks = mapreduce(union, [
lectures_dir,
prob_prog_dir,
minis_dir,
ignore_dir
]) do d
isdir(d) ?
filter(Pluto.is_pluto_notebook, readdir(d; join=true)) :
String[]
end




"Extract embedded project and manifest contents from each notebook"
function extract_toml_contents(notebook_path::String)
content = read(notebook_path, String)
Expand Down
41 changes: 41 additions & 0 deletions tools/common.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
if !isdir("pluto-deployment-environment")
error("""
Run me from the root of the repository directory, using:

julia tools/scriptname.jl argument1 argument2 ...
""")
end


begin
import TOML
manifest_version = TOML.parsefile("./pluto-deployment-environment/Manifest.toml")["julia_version"]

@assert manifest_version == string(VERSION) "This repository uses Julia version $(manifest_version) (in pluto-deployment-environment), but this is Julia $(VERSION). Start a new Julia session with the correct version, or create a new Manifest.toml."
end

import Pkg
Pkg.activate("./pluto-deployment-environment")
Pkg.instantiate()
import Pluto
ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0

flatmap(args...) = vcat(map(args...)...)


# Find all notebooks
lectures_dir = joinpath(@__DIR__, "..", "lectures")
prob_prog_dir = joinpath(@__DIR__, "..", "probprog")
minis_dir = joinpath(@__DIR__, "..", "minis")
ignore_dir = joinpath(@__DIR__, "..", "ignore_dir")

all_notebooks = mapreduce(union, [
lectures_dir,
prob_prog_dir,
minis_dir,
ignore_dir
]) do d
isdir(d) ?
filter(Pluto.is_pluto_notebook, readdir(d; join=true)) :
String[]
end
21 changes: 21 additions & 0 deletions tools/find_open_markdown_cells.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
include("./common.jl")


for path in all_notebooks
@info "🌸 Checking $path"
notebook = Pluto.load_notebook_nobackup(path)


old = notebook.topology
new = notebook.topology = Pluto.updated_topology(old, notebook, notebook.cells)


for c in notebook.cells
c.code_folded && continue
!Pluto.is_just_text(new, c) && continue
if startswith(strip(c.code), "md") || startswith(strip(c.code), "html")
@error "Markdown cell is not folded" path c.cell_id
end
end

end
2 changes: 0 additions & 2 deletions tools/generate_pdf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ output_dir = mktempdir(; cleanup=false)
@info "Output directory: $(output_dir)"

lecture_urls = [
"TODO You need to update this list",
"https://bmlip.github.io/course/lectures/Course%20Syllabus.html",
"https://bmlip.github.io/course/lectures/Machine%20Learning%20Overview.html",
"https://bmlip.github.io/course/lectures/Probability%20Theory%20Review.html",
"https://bmlip.github.io/course/lectures/Bayesian%20Machine%20Learning.html",
"https://bmlip.github.io/course/lectures/Factor%20Graphs.html",
"https://bmlip.github.io/course/lectures/Density%20Estimation.html",
"https://bmlip.github.io/course/lectures/The%20Multinomial%20Distribution.html",
"https://bmlip.github.io/course/lectures/Regression.html",
"https://bmlip.github.io/course/lectures/Generative%20Classification.html",
"https://bmlip.github.io/course/lectures/Discriminative%20Classification.html",
Expand Down
27 changes: 5 additions & 22 deletions tools/update_notebook_packages.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
if !isdir("pluto-deployment-environment") || length(ARGS) != 2
include("./common.jl")

if length(ARGS) != 2
error("""
Run me from the root of the repository directory, using:

Expand All @@ -9,33 +11,14 @@ if !isdir("pluto-deployment-environment") || length(ARGS) != 2
""")
end

begin
import TOML
manifest_version = TOML.parsefile("./pluto-deployment-environment/Manifest.toml")["julia_version"]

@assert manifest_version == string(VERSION) "This repository uses Julia version $(manifest_version) (in pluto-deployment-environment), but this is Julia $(VERSION). Start a new Julia session with the correct version, or create a new Manifest.toml."
end

import Pkg
Pkg.activate("./pluto-deployment-environment")
Pkg.instantiate()

import Pluto

flatmap(args...) = vcat(map(args...)...)
level = getfield(Pkg, Symbol("UPLEVEL_$(ARGS[1])"))
run_notebooks = parse(Bool, ARGS[2])


getfrom(dir) = flatmap(walkdir(dir)) do (root, _dirs, files)
joinpath.((root,), files)
end

all_files_recursive = [getfrom("lectures")..., getfrom("probprog")..., getfrom("minis")...]

all_notebooks = filter!(Pluto.is_pluto_notebook, all_files_recursive)

level = getfield(Pkg, Symbol("UPLEVEL_$(ARGS[1])"))
run_notebooks = parse(Bool, ARGS[2])

for n in all_notebooks
@info "Updating" n
ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0
Expand Down
Loading