Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kino.recompile/0 #399

Merged
merged 3 commits into from
Feb 29, 2024
Merged
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
29 changes: 29 additions & 0 deletions lib/kino.ex
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,33 @@ defmodule Kino do
{:error, _} -> nil
end
end

@doc """
Recompiles dependenies.

Once you have installed dependencies with `Mix.install/1`, this will
recompile any outdated path dependencies declared during the install.

> #### Reproducability {: .warning}
>
> Keep in mind that recompiling dependency modules is **not** going
> to mark any cells as stale. This means that the given notebook
> state may no longer be reproducable. This function is meant as a
> utility when prototyping alongside a Mix project.
"""
@spec recompile() :: :ok
def recompile() do
unless Mix.installed?() do
raise "trying to call Kino.recompile/0, but Mix.install/2 was never called"
end

elixir_version = System.version()

if Version.compare(elixir_version, "1.16.2") == :lt do
raise "Kino.recompile/0 requires Elixir 1.16.2 or newer to work, but you are using #{elixir_version}"
end

IEx.Helpers.recompile()
:ok
end
end
Loading