Skip to content

Instantly share code, notes, and snippets.

@ctrekker
Last active July 25, 2021 18:58
Show Gist options
  • Save ctrekker/ba69f09b86ec2fcb68566cfa770ffbb5 to your computer and use it in GitHub Desktop.
Save ctrekker/ba69f09b86ec2fcb68566cfa770ffbb5 to your computer and use it in GitHub Desktop.
import Pluto
function plutostate_to_julia(state::Dict{Any, Any}, juliafile::AbstractString)
cell_order = UUID.(state["cell_order"])
cells_dict = Dict([UUID(k) => Pluto.Cell(cell_id=UUID(k), code=v["code"], code_folded=v["code_folded"]) for (k, v) ∈ state["cell_inputs"]])
cells = [cells_dict[id] for id ∈ cell_order]
nb = Pluto.Notebook(cells, "", uuid4())
open(juliafile, "w") do io
Pluto.save_notebook(io, nb)
end
end
function plutostate_to_julia(statefile::AbstractString, juliafile::AbstractString)
contents = open(f->read(f), statefile)
state = Pluto.unpack(contents)
plutostate_to_julia(state, juliafile)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment