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
...
- Also tried
tucan, had a similar story - since it uses VegaLite I guess.
Most Liked
dc0d
Thanks. Those packages are already in mix.exs - also updated the question with the list of dependencies.
jonatanklosko
@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
)
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









