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

Must require Explorer.Dataframe in each cell #2133

Closed
lehoff opened this issue Aug 2, 2023 · 4 comments · Fixed by #2134
Closed

Must require Explorer.Dataframe in each cell #2133

lehoff opened this issue Aug 2, 2023 · 4 comments · Fixed by #2134

Comments

@lehoff
Copy link

lehoff commented Aug 2, 2023

Environment

  • Elixir & Erlang/OTP versions (elixir --version): 1.15.2
  • Operating system: MacOS Ventura 13.5
  • How have you started Livebook (mix phx.server, livebook CLI, Docker, etc): Desktop app
  • Livebook version (use git rev-parse HEAD if running with mix): 0.10.0
  • Browsers that reproduce this bug (the more the merrier): Orion
  • Include what is logged in the browser console: na
  • Include what is logged to the server console: na

Current behavior

Include detailed steps to reproduce error, errors and stacktraces if appropriate.

First cell:

require Explorer.DataFrame, as: DF

Second cell:

df = Explorer.Datasets.fossil_fuels()
grouped = DF.group_by(df, ["country"])
DF.mutate(df, new_column: solid_fuel + cement)
grouped
 |> DF.summarise(max_per_capita: max(per_capita))
 |> DF.arrange(desc: max_per_capita)
error: undefined variable "solid_fuel"
  esl/budget/budget_tool/mvp.livemd#cell:xfpznyqojik7ad6hwmtdpt5kjqmjkyd5:5

Expected behavior

A short description on how you expect the code to behave.

I did a require Explorer.Dataframe very early in my Livebook, so I would have expected that the code did what it does in the documentation in every cell, but it only works if I require Explorer.Dataframe in every cell.

Now I know the limitation so I can work around it, but it is not intuitive.

@josevalim
Copy link
Contributor

I cannot reproduce this. Can you share your notebook? :)

@josevalim
Copy link
Contributor

For example, this notebook worked fine here:

# Untitled notebook

```elixir
Mix.install([
  {:explorer, "~> 0.6.1"}
])
```

## Section

```elixir
require Explorer.DataFrame, as: DF
```

```elixir
df = Explorer.Datasets.fossil_fuels()
grouped = DF.group_by(df, ["country"])
DF.mutate(df, new_column: solid_fuel + cement)

grouped
|> DF.summarise(max_per_capita: max(per_capita))
|> DF.arrange(desc: max_per_capita)
```

@cristineguadelupe
Copy link
Contributor

Same here. I was unable to reproduce it and the code example worked without problems.

@lehoff
Copy link
Author

lehoff commented Aug 2, 2023

I have found the root cause, but I don't know why it happens. I tried to trim down my notebook, but I forgot to try it out before reporting - I will remember that next time, sorry about wasting your time.

Anyway, here is my notebook:

# Untitled notebook

```elixir
Mix.install([
  {:timex, "~> 3.7"},
  {:explorer, "~> 0.6.0"},
  {:kino, "~> 0.9.0"},
  {:kino_explorer, "~> 0.1.4"}
])

Section

use Timex
require Explorer.DataFrame, as: DF
df = Explorer.Datasets.fossil_fuels()
grouped = DF.group_by(df, ["country"])
DF.mutate(df, new_column: solid_fuel + cement)

grouped
|> DF.summarise(max_per_capita: max(per_capita))
|> DF.arrange(desc: max_per_capita)

This is reproducible at my end.
The problem comes when use Timex is in the the same cell (order does not matter). If I split out the use and the require in two separate cells it works just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants