fbdesignpro / sweetviz

Visualize and compare datasets, target values and associations, with one line of code.
MIT License
2.94k stars 277 forks source link

Bug: show_notebook saving file that can't be opened #161

Closed tvdboom closed 10 months ago

tvdboom commented 11 months ago

Hi,

One bug and one suggestion:

The bug: show_notebook saves an html file that, when opened with chrome, shows the plain text instead of rendering. This doesn't happen with show_html, and the reason is this line self._page_html = html.escape(self._page_html), that does something to the html that prevents it from rendering correctly (at least in chrome).

The suggestion: I would like to use show_html without saving any file. Just like show_notebook, I would like to be able to provide filepath=None. This would also make the API more consistent.

fbdesignpro commented 11 months ago

@tvdboom thank you for the report! That is a bit strange that it would start doing that (this used to work). Your suggestion makes sense I will look into incrementing it. Thank you again!

fbdesignpro commented 11 months ago

@tvdboom actually, I misread your message; it's on purpose that show_notebook makes it "unreadable" for regular browsers, because that's the way the page needs to be formatted if it's to be embedded inside of a notebook (i.e. it can't have the surrounding HTML tags).

On the other hand, show_html needs to write out a file, because the browser has to have something to open.

I can think of 2 things that can be done, but I'm not sure which is your main issue or if it would resolve it:

  1. What I can do (and has been suggested for) is to add an option to show_html to generate the file, but not OPEN it. That way the file is created silently.
  2. Have the notebook function create a file that does not end with .html, to avoid the confusion (e.g. .html_embed)

Let me know if that makes sense or if there is something else that would work better, or if I missed anything!

tvdboom commented 11 months ago

I understand, but I don't see the use of saving the html file in show_notebook without the html tags. What I would like is to show the report inside the notebook and at the same time save the file (with tags) so that I can open it separately in a browser.

If this can't happen, then my workaround would be to run first show_notebook without saving anything, and then show_html saving the file (and preferably not opening anything, so solution 1 would be nice to have), but it's an ugly solution imo since I need to call both show methods.

fbdesignpro commented 11 months ago

@tvdboom that makes sense and I think it's a simple fix, I will look into it shortly.

tvdboom commented 10 months ago

any progress on this?

fbdesignpro commented 10 months ago

@tvdboom thank you for your patience! I was hoping to include it in an upcoming update along with other fixes, but I haven't had the time to get to it all; I will push a new version with just this fix tomorrow!

fbdesignpro commented 10 months ago

Done! I hope this is the functionality you were looking for, check out the documentation for an update on show_notebook(). Let me know if there are any issues with it. Thanks again for your feedback!

tvdboom commented 10 months ago

Works as requested. Thanks for the implementation!