AccessRemote_standalone
Mix.install([
{:kino, "~> 0.14.0"},
{:kino_vega_lite, "~> 0.1.11"}
])
Section
require Kino.RPC
node = :"test@0.0.0.0"
Node.set_cookie(node, String.to_atom(System.fetch_env!("LB_COOKIE")))
Kino.RPC.eval_string(
node,
~S"""
config = DemoApp.Repo.config()
result = %{
config: config[:database],
fake_time: [1,2,3,4,5,6,7,8,9,10,11,12,13,14],
fake_value: [1,2,3,4,4,4,4,5,5,5,6,6,6,7]
}
""",
file: __ENV__.file
)
Variable is not accessble from other cells.
result
Below is a walkaround to access the variable from another cell.
require Kino.RPC
# Assuming you have already set up the node and authentication
node = :"test@0.0.0.0"
Node.set_cookie(node, String.to_atom(System.fetch_env!("LB_COOKIE")))
# Evaluate the string on the remote node
result = Kino.RPC.eval_string(
node,
~S"""
config = DemoApp.Repo.config()
dataset = %{
config: config[:database],
fake_time: [1,2,3,4,5,6,7,8,9,10,11,12,13,14],
fake_value: [1,2,3,4,4,4,4,5,5,5,6,6,6,7]
}
dataset
""",
file: __ENV__.file
)
selected_dataset = Map.take(result, [:fake_value, :fake_time])
VegaLite.new(width: 920)
|> VegaLite.data_from_values(selected_dataset, only: ["fake_time", "fake_value"])
|> VegaLite.mark(:point)
|> VegaLite.encode_field(:x, "fake_time", type: :quantitative)
|> VegaLite.encode_field(:y, "fake_value", type: :quantitative)