dc0d

dc0d

VegaLite errors in LiveBook, but not in iex

There is this totally normal mix Elixir project/repository (code and tests and stuff - just a library for now, no Phoenix or anything).
Then added a LiveBook notebook at notebooks/dicect.livemd - needed some exploratory data visualization.

When this code is executed from the inside the LiveBook:

data = [
  %{"category" => "A", "score" => 28},
  %{"category" => "B", "score" => 55}
]

Vl.new()
|> Vl.data_from_values(data)

It returns:

** (Protocol.UndefinedError) protocol Enumerable not implemented for %Table.Mapper{enumerable: [%{"category" => "A", "score" => 28}, %{"category" => "B", "score" => 55}], fun: #Function<1.129280379/1 in Table.Mapper.map/2>} of type Table.Mapper (a struct). This protocol is implemented for the following type(s): Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Range, Stream
    (elixir 1.17.2) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.17.2) lib/enum.ex:166: Enumerable.reduce/3
    (elixir 1.17.2) lib/enum.ex:4423: Enum.map/2
    (vega_lite 0.1.10) lib/vega_lite.ex:304: VegaLite.data_from_values/3
    #cell:r6qixazynpxprvhi:9: (file)

But, when it is run from the iex -S mix prompt, it returns a VegaLite data structure.

What is missing?

The setup part of the LiveBook:

Mix.install(
  [
    {:dicect, path: Path.join(__DIR__, ".."), env: :dev}
  ],
  config_path: :dicect,
  lockfile: :dicect
)

Current dependencies in mix.exs are:

  ...
  defp deps do
    [
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:logger_json, "~> 6.1"},
      {:vega_lite, "~> 0.1.10"},
      {:kino, "~> 0.14.1"},
      {:tucan, "~> 0.3.0"},
      {:kino_vega_lite, "~> 0.1.8"}
    ]
  end
  ...
  1. Also tried tucan , had a similar story - since it uses VegaLite I guess.

Most Liked

dc0d

dc0d

Thanks. Those packages are already in mix.exs - also updated the question with the list of dependencies.

jonatanklosko

jonatanklosko

Creator of Livebook

@dc0d your error looks like an issue with protocol consolidation, but I cannot reproduce it. Try removing the _build directory in the project.

On a sidenote, you generally don’t want to put notebook-specific dependencies inside mix.exs, because then your project unnecessarily depends on them. You could make them only: :dev, but the recommended approach would be to have these dependencies directly in the notebook. Like this:

Mix.install(
  [
    {:dicect, path: Path.join(__DIR__, ".."), env: :dev},
    {:vega_lite, "~> 0.1.10"},
    {:kino, "~> 0.14.1"},
    {:tucan, "~> 0.3.0"},
    {:kino_vega_lite, "~> 0.1.8"}
  ],
  config_path: :dicect,
  lockfile: :dicect
)

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; somethi...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48342 226
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement