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

Fix export_data to match the spec #153

Merged
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
6 changes: 3 additions & 3 deletions lib/kino/explorer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ defmodule Kino.Explorer do
@impl true
def export_data(%{df: df}, "CSV") do
data = df |> DataFrame.collect() |> DataFrame.dump_csv!()
%{data: data, extension: ".csv", type: "text/csv"}
{:ok, %{data: data, extension: ".csv", type: "text/csv"}}
end

def export_data(%{df: df}, "NDJSON") do
data = df |> DataFrame.collect() |> DataFrame.dump_ndjson!()
%{data: data, extension: ".ndjson", type: "application/x-ndjson"}
{:ok, %{data: data, extension: ".ndjson", type: "application/x-ndjson"}}
end

def export_data(%{df: df}, "Parquet") do
data = df |> DataFrame.collect() |> DataFrame.dump_parquet!()
%{data: data, extension: ".parquet", type: "application/x-parquet"}
{:ok, %{data: data, extension: ".parquet", type: "application/x-parquet"}}
end

defp columns(df, lazy, groups) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule KinoExplorer.MixProject do

defp deps do
[
{:kino, "~> 0.12.2"},
{:kino, "~> 0.12.3"},
{:explorer, "~> 0.8.0"},
{:rustler, "~> 0.29.0", optional: true},
{:ex_doc, "~> 0.31.0", only: :dev, runtime: false}
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"explorer": {:hex, :explorer, "0.8.0", "1996b524f70b80cc9de2a17a05482f1eb21a7a034cca20ea6549800515fd29b9", [:mix], [{:adbc, "~> 0.1", [hex: :adbc, repo: "hexpm", optional: true]}, {:aws_signature, "~> 0.3", [hex: :aws_signature, repo: "hexpm", optional: false]}, {:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:fss, "~> 0.1", [hex: :fss, repo: "hexpm", optional: false]}, {:nx, "~> 0.4", [hex: :nx, repo: "hexpm", optional: true]}, {:rustler, "~> 0.29.0", [hex: :rustler, repo: "hexpm", optional: true]}, {:rustler_precompiled, "~> 0.7", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}, {:table, "~> 0.1.2", [hex: :table, repo: "hexpm", optional: false]}, {:table_rex, "~> 3.1.1 or ~> 4.0.0", [hex: :table_rex, repo: "hexpm", optional: false]}], "hexpm", "2397a9e0846c90e40e860c28ec0367ecef78aad9294f63b13934e5cafbd71268"},
"fss": {:hex, :fss, "0.1.1", "9db2344dbbb5d555ce442ac7c2f82dd975b605b50d169314a20f08ed21e08642", [:mix], [], "hexpm", "78ad5955c7919c3764065b21144913df7515d52e228c09427a004afe9c1a16b0"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"kino": {:hex, :kino, "0.12.2", "3840f58891860a887a71d042be966f50a3bc2697243d031a46eab19ac101d866", [:mix], [{:fss, "~> 0.1.0", [hex: :fss, repo: "hexpm", optional: false]}, {:nx, "~> 0.1", [hex: :nx, repo: "hexpm", optional: true]}, {:table, "~> 0.1.2", [hex: :table, repo: "hexpm", optional: false]}], "hexpm", "4347a1c30b88999eaa82da6a5a651f8d79f639539f1c3189fb75ac3c03ebab4b"},
"kino": {:hex, :kino, "0.12.3", "a5f48a243c60a7ac18ba23869f697b1c775fc7794e8cd55dd248ba33c6fe9445", [:mix], [{:fss, "~> 0.1.0", [hex: :fss, repo: "hexpm", optional: false]}, {:nx, "~> 0.1", [hex: :nx, repo: "hexpm", optional: true]}, {:table, "~> 0.1.2", [hex: :table, repo: "hexpm", optional: false]}], "hexpm", "a6dfa3d54ba0edec9ca6e5940154916b381901001f171c85a2d8c67869dbc2d8"},
"makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.3", "d684f4bac8690e70b06eb52dad65d26de2eefa44cd19d64a8095e1417df7c8fd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "b78dc853d2e670ff6390b605d807263bf606da3c82be37f9d7f68635bd886fc9"},
Expand Down
6 changes: 3 additions & 3 deletions test/kino/explorer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ defmodule Kino.ExplorerTest do
for format <- ["CSV", "NDJSON", "Parquet"] do
exported = Kino.Explorer.export_data(%{df: df}, format)
extension = ".#{String.downcase(format)}"
assert %{extension: ^extension} = exported
assert {:ok, %{extension: ^extension}} = exported
end
end

Expand All @@ -478,7 +478,7 @@ defmodule Kino.ExplorerTest do
for format <- ["CSV", "NDJSON", "Parquet"] do
exported = Kino.Explorer.export_data(%{df: df}, format)
extension = ".#{String.downcase(format)}"
assert %{extension: ^extension} = exported
assert {:ok, %{extension: ^extension}} = exported
end
end

Expand All @@ -493,7 +493,7 @@ defmodule Kino.ExplorerTest do
for format <- ["NDJSON", "Parquet"] do
exported = Kino.Explorer.export_data(%{df: df}, format)
extension = ".#{String.downcase(format)}"
assert %{extension: ^extension} = exported
assert {:ok, %{extension: ^extension}} = exported
end
end
end
Loading