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

Enable livemd export for Kino.DataTable #346

Merged
merged 1 commit into from
Sep 21, 2023
Merged
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
6 changes: 5 additions & 1 deletion lib/kino/data_table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ defmodule Kino.DataTable do
{data, meta.columns}
end

Kino.Table.new(__MODULE__, {data_rows, data_columns, count, name, sorting_enabled})
inspected = inspect(tabular)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we inspect lazily? I guess we have to choose between keeping a reference to the inspect vs to the whole data.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For small data it doesn't matter, and if it's large data then inspect is less copying (or zero-copy if big enough).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not worried about the copying but the amount of in-memory data we need to keep. I guess at best we can guess for now (and if the data is really large, inspect truncates, so that's a plus).


Kino.Table.new(__MODULE__, {data_rows, data_columns, count, name, sorting_enabled},
export: fn _ -> {"text", inspected} end
)
end

defp normalize_tabular([%struct{} | _] = tabular) do
Expand Down