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

Jupyter Notebook - showing table not working #64

Closed
jarach opened this issue Feb 19, 2020 · 7 comments
Closed

Jupyter Notebook - showing table not working #64

jarach opened this issue Feb 19, 2020 · 7 comments

Comments

@jarach
Copy link

jarach commented Feb 19, 2020

Example behavior:
image

When I run 2nd cell with d.open_browser() it opens (as expected) a new browser tab with the table.
After that when I re-run the 1st cell the table appeared as expected in the notebook.

I did it several times and it started being worse. Running command:
'd = dtale.show(df, notebook=True)`
takes long time to display the table (over 2min).

I restarted kernel and tested several combinations of commands. Only following works:
image
The last 2 cell take very long time to run.

And after several runs it stopped working at all:
image
image

I was restarting kernel each time. I even restarted jupyter notebook several times.

Sorry for so many screenshots. I wanted to explain the issue in details.
I hope it helps.

@aschonfeld
Copy link
Collaborator

@jarach Sorry, was working on getting v1.7.5 out. I will begin looking at this today. The more screenshots the better! 👍

@aschonfeld
Copy link
Collaborator

@jarach couple questions:

  1. we're you calling dtale.show(df) everytime you're executing a cell? If so, D-Tale is not smart enough to know that you're continually passing the same dataframe in so it will open an instance everytime you call it. So one way around that issue is to store your instance in a variable and then keep viewing that instance
    image
    If you need to update the data associated with that instance you can do:
    d.dtata = new_df
    or
    d.data['new_col'] = new_col

  2. Another bug is that when you call dtale.instances() it returns a dictionary of all the ids of the data you've "shown" and their instances. So just executing that in a cell might be costly because it will try to render every instance afterwards. I might change the functionality of this to only return the ids and then once you see the ids you can pick one and do dtale.get_instance(id) to view the data

To get around the issue of showing the same dataframe everytime I could try using something like pandas.util.testing.assert_frame_equal to check if that data has already been loaded but I think it might be very costly depending on the size of your data.

I think a better approach would be to have another message display each time you call dtale.show that tells you how many instances are open (and maybe how much memory you're consuming, might be too costly)

@aschonfeld
Copy link
Collaborator

Here's a demo of the new duplicate data checking:
image

aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all
   instances
 - removal of Dash "Export to png" function
@Robin-Sky
Copy link

Robin-Sky commented Feb 21, 2020

I seem to be getting the same issue in Google Cloud's AI platform notebooks: seems to return a blank preview too
image

Same in Jupyter classic notebook mode:
image

Am wondering whether this is a technical limitation of using a hosted notebook in GCP, or whether Google restricted some actions in their Jupyterlab environment.

BTW also tried the trick above:
d = dtale.show(df, notebook=True)
d.open_browser()

But am getting the following error message:

Error Traceback (most recent call last)
in
1 d = dtale.show(df, notebook=True)
----> 2 d.open_browser()

~/.local/lib/python3.5/site-packages/dtale/views.py in open_browser(self)
146 to this D-Tale instance
147 """
--> 148 webbrowser.get().open(self.main_url())
149
150 def is_up(self):

/usr/lib/python3.5/webbrowser.py in get(using)
49 elif command[0] is not None:
50 return command0
---> 51 raise Error("could not locate runnable browser")
52
53 # Please note: the following definition hides a builtin function.

Error: could not locate runnable browser

image

@aschonfeld
Copy link
Collaborator

Yes, there is a limitation on using D-Tale in hosted notebooks. You would have to go to the administrators running those notebook services and ask them if you can allow port 40000 (the first port D-Tale checks when it starts up) to be viewable.

I've already sent requests out to google collab & kaggle to see if they will allow this, but for the time being theres not much that can be done about it.

You may want to try:

d = dtale.show(df)
print(d.main_url())

and then copying and pasting that link into a new tab. There is a small chance that the issue is around how the notebook is hosted (https) and how D-Tale is hosted (http). But most likely the former is true and you'll have to speak with the admins.

As for the issue with the open_browser if requires that a default browser be set in whatever environment you try to call it from. Without it then it can't determine how to start up the browser. Looks like it looks for the BROWSER environment variable (https://docs.python.org/2/library/webbrowser.html)

@Robin-Sky
Copy link

Thanks for the speedy answer @aschonfeld - makes sense.
Have a good weekend.

aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all instances
 - removal of Dash "Export to png" function
 - passing data grid queries to chart page as default
 - added sys.exit() to the thread that manages the reaper
aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all instances
 - removal of Dash "Export to png" function
 - passing data grid queries to chart page as default
 - added sys.exit() to the thread that manages the reaper
aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all instances
 - removal of Dash "Export to png" function
 - passing data grid queries to chart page as default
 - added sys.exit() to the thread that manages the reaper
aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all instances
 - removal of Dash "Export to png" function
 - passing data grid queries to chart page as default
 - added sys.exit() to the thread that manages the reaper
aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all instances
 - removal of Dash "Export to png" function
 - passing data grid queries to chart page as default
 - added sys.exit() to the thread that manages the reaper
aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all instances
 - removal of Dash "Export to png" function
 - passing data grid queries to chart page as default
 - added sys.exit() to the thread that manages the reaper
aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all instances
 - removal of Dash "Export to png" function
 - passing data grid queries to chart page as default
 - added sys.exit() to the thread that manages the reaper
@aschonfeld aschonfeld mentioned this issue Feb 21, 2020
aschonfeld pushed a commit that referenced this issue Feb 21, 2020
 - #64, handling for loading duplicate data to dtale.show
 - updated dtale.instances() to print urls rather than show all instances
 - removal of Dash "Export to png" function
 - passing data grid queries to chart page as default
 - added sys.exit() to the thread that manages the reaper
@aschonfeld
Copy link
Collaborator

Just released v1.7.6 with the duplicate data check. I'm going to close this issue since the other aspects are related issues with how notebooks are being hosted rather than with code.

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

No branches or pull requests

3 participants