From 28a20f96a7acc5f4fdbb4e261d3aec446c634b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Thu, 29 Feb 2024 17:24:57 +0700 Subject: [PATCH 1/3] Add Kino.recompile/0 --- lib/kino.ex | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/kino.ex b/lib/kino.ex index a3e244d6..3d85171d 100644 --- a/lib/kino.ex +++ b/lib/kino.ex @@ -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 #{System.version()}" + end + + IEx.Helpers.recompile() + :ok + end end From 0fac044c8a22f55eda2c2df31a88f693b922417d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Thu, 29 Feb 2024 17:30:00 +0700 Subject: [PATCH 2/3] Up --- lib/kino.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kino.ex b/lib/kino.ex index 3d85171d..704ea9c5 100644 --- a/lib/kino.ex +++ b/lib/kino.ex @@ -551,7 +551,7 @@ defmodule Kino do 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 #{System.version()}" + raise "Kino.recompile/0 requires Elixir 1.16.2 or newer to work, but you are using #{elixir_version}" end IEx.Helpers.recompile() From 71e4ef436fa3bf5705cf17129bb011b042a3a4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Thu, 29 Feb 2024 12:18:25 +0100 Subject: [PATCH 3/3] Update lib/kino.ex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: José Valim --- lib/kino.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kino.ex b/lib/kino.ex index 704ea9c5..ffbe6fd6 100644 --- a/lib/kino.ex +++ b/lib/kino.ex @@ -540,7 +540,7 @@ defmodule Kino do > 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. + > utility when prototyping alongside a Mix project. """ @spec recompile() :: :ok def recompile() do