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

BUG: Interactive mode returned expression and not value in Jupyter #2157

Merged
merged 11 commits into from
May 26, 2020
Merged

BUG: Interactive mode returned expression and not value in Jupyter #2157

merged 11 commits into from
May 26, 2020

Conversation

datapythonista
Copy link
Contributor

Closes #2155

In Jupyter, interactive mode is not interactive, expressions are displayed.

I don't see Expr much tested, I guess not worth of having a test only for this.

@datapythonista datapythonista added the bug Incorrect behavior inside of ibis label Mar 30, 2020
@xmnlab
Copy link
Contributor

xmnlab commented Mar 31, 2020

@datapythonista maybe you can add a tests for that here: https://github.com/ibis-project/ibis/blob/master/ibis/expr/tests/test_interactive.py

let me know if it makes sense.

Copy link
Contributor

@xmnlab xmnlab left a comment

Choose a reason for hiding this comment

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

LGTM! thanks for working on that @datapythonista !

@datapythonista
Copy link
Contributor Author

@jreback do you mind having a look at this? It's been rebased and is green. I need this bug fixed to work on the tutorial.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

also pls add a release note

@@ -30,6 +30,12 @@ def test_interactive_execute_on_repr(self):

assert len(self.con.executed_queries) > 0

def test_png_repr_returns_correct_type(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a test when interactive is False a well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I tried that in the past, and it's not trivial. There are different cases that affect the output of _repr_png_. Like, graphviz not being installed, anything that makes importing ibis.expr.visualize fail, or call the to_graph method. Also if the graphviz_repr option is set to False.

I added the test, to see what fails, but I think it'll be tricky to find a way to add that test in a deterministic and reliable way. We may end up introducing a test that doesn't provide much value, but it's flaky when new builds are added.

Copy link
Contributor

Choose a reason for hiding this comment

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

right its just to verify that it is NOT none

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, but the problem is that even with interactive set to False, _repr_png_ can still be None for different reasons:

  • graphviz not installed
  • option graphviz_repr set to False
  • an exception happens when importing the visualization module

I added a test for the case when all conditions are met for the result to be not None. It's a bit tricky, but I think it's the best we can do.

assert table._repr_png_() is None

try:
import ibis.expr.visualize
Copy link
Contributor

Choose a reason for hiding this comment

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

this import doesn't need to be here

with config.option_context('interactive', True):
assert table._repr_png_() is None

try:
Copy link
Contributor

Choose a reason for hiding this comment

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

make this a new test


ibis.expr.visualize.to_graph(table).pipe(format='png')
except Exception:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

here just skip the test if you can't format

@jreback jreback added this to the Next Bugfix Release milestone May 25, 2020
@datapythonista
Copy link
Contributor Author

Thanks for the feedback @jreback, it was useful. This should be ready now.

@jreback jreback merged commit 14522fd into ibis-project:master May 26, 2020
@jreback
Copy link
Contributor

jreback commented May 26, 2020

thanks @datapythonista

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interactive mode doesn't work in Jupyter
3 participants