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

Renames remote cell to remote execution #331

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
2 changes: 1 addition & 1 deletion lib/kino/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Kino.Application do

Kino.Counter.initialize()

Kino.SmartCell.register(Kino.RemoteCell)
Kino.SmartCell.register(Kino.RemoteExecutionCell)

children = [
{DynamicSupervisor, strategy: :one_for_one, name: Kino.DynamicSupervisor},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
defmodule Kino.RemoteCell do
defmodule Kino.RemoteExecutionCell do
@moduledoc false

use Kino.JS, assets_path: "lib/assets/remote_cell"
use Kino.JS, assets_path: "lib/assets/remote_execution_cell"
use Kino.JS.Live
use Kino.SmartCell, name: "Remote cell"
use Kino.SmartCell, name: "Remote execution"

@default_code ":ok"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
defmodule Kino.RemoteCellTest do
defmodule Kino.RemoteExecutionCellTest do
use ExUnit.Case, async: true

import Kino.Test

alias Kino.RemoteCell
alias Kino.RemoteExecutionCell

setup :configure_livebook_bridge

Expand All @@ -15,13 +15,13 @@ defmodule Kino.RemoteCellTest do
}

test "returns the defaults when starting fresh with no data" do
{_kino, source} = start_smart_cell!(RemoteCell, %{})
{_kino, source} = start_smart_cell!(RemoteExecutionCell, %{})

assert source == ""
end

test "from saved attrs" do
{_kino, source} = start_smart_cell!(RemoteCell, @fields)
{_kino, source} = start_smart_cell!(RemoteExecutionCell, @fields)

assert source == """
node = :name@node
Expand All @@ -32,7 +32,7 @@ defmodule Kino.RemoteCellTest do

test "from saved attrs with result" do
attrs = %{@fields | "assign_to" => "result"}
{_kino, source} = start_smart_cell!(RemoteCell, attrs)
{_kino, source} = start_smart_cell!(RemoteExecutionCell, attrs)

assert source == """
node = :name@node
Expand All @@ -44,23 +44,23 @@ defmodule Kino.RemoteCellTest do
describe "code generation" do
test "do not generate code when there's no node" do
attrs = %{@fields | "node" => ""}
assert RemoteCell.to_source(attrs) == ""
assert RemoteExecutionCell.to_source(attrs) == ""
end

test "do not generate code when there's no cookie" do
attrs = %{@fields | "cookie" => ""}
assert RemoteCell.to_source(attrs) == ""
assert RemoteExecutionCell.to_source(attrs) == ""
end

test "do not generate code when there's no code" do
attrs = %{@fields | "code" => ""}
assert RemoteCell.to_source(attrs) == ""
assert RemoteExecutionCell.to_source(attrs) == ""
end

test "emites Code.string_to_quoted! when the code is invalid" do
attrs = %{@fields | "code" => "1 + "}

assert RemoteCell.to_source(attrs) == """
assert RemoteExecutionCell.to_source(attrs) == """
# Invalid code for RPC, reproducing the error below
Code.string_to_quoted!("1 + ")\
"""
Expand All @@ -71,25 +71,25 @@ defmodule Kino.RemoteCellTest do
code2 = %{@fields | "code" => "1 == 1"}
code3 = %{@fields | "code" => "a = 1\na + a"}

assert RemoteCell.to_source(@fields) == """
assert RemoteExecutionCell.to_source(@fields) == """
node = :name@node
Node.set_cookie(node, :"node-cookie")
:erpc.call(node, fn -> :ok end)\
"""

assert RemoteCell.to_source(code1) == """
assert RemoteExecutionCell.to_source(code1) == """
node = :name@node
Node.set_cookie(node, :"node-cookie")
:erpc.call(node, fn -> 1 + 1 end)\
"""

assert RemoteCell.to_source(code2) == """
assert RemoteExecutionCell.to_source(code2) == """
node = :name@node
Node.set_cookie(node, :"node-cookie")
:erpc.call(node, fn -> 1 == 1 end)\
"""

assert RemoteCell.to_source(code3) == """
assert RemoteExecutionCell.to_source(code3) == """
node = :name@node
Node.set_cookie(node, :"node-cookie")

Expand All @@ -103,7 +103,7 @@ defmodule Kino.RemoteCellTest do
test "assign to a variable" do
attrs = %{@fields | "assign_to" => "result"}

assert RemoteCell.to_source(attrs) == """
assert RemoteExecutionCell.to_source(attrs) == """
node = :name@node
Node.set_cookie(node, :"node-cookie")
result = :erpc.call(node, fn -> :ok end)\
Expand All @@ -113,7 +113,7 @@ defmodule Kino.RemoteCellTest do
test "do not assign to an invalid variable" do
attrs = %{@fields | "assign_to" => "invalid result"}

assert RemoteCell.to_source(attrs) == """
assert RemoteExecutionCell.to_source(attrs) == """
node = :name@node
Node.set_cookie(node, :"node-cookie")
:erpc.call(node, fn -> :ok end)\
Expand Down
Loading