evidently icon indicating copy to clipboard operation
evidently copied to clipboard

Feature request: generate html dashboard from json

Open abockmann opened this issue 1 year ago • 7 comments

As of today, it seems one can either choose between outputting a report as json or an html dashboard. These seem to contain more or less the same data. I would really like to use both, but it seems redundant to duplicate the data in the json. A feature where an html dashboard could be built at runtime from a json file would be very welcome. It would also be nice if there was an option to output the html as a string rather than just save a file - especially when working with s3.

abockmann avatar May 02 '23 09:05 abockmann

Hi @abockmann , Thank you for sharing your thoughts!

We agree that feature where an html dashboard could be built at runtime from dumped data needs to be implemented. We are in the process of designing this option. I can not promise that it will be directly from json data, because we consider some other options, but I fully agree with the idea of building html in the runtime.

I think I can suggest an immediate solution to output the html as a string. If you call command report.show().data where report is your evidently Report, you should get the html as a string.

emeli-dral avatar May 11 '23 11:05 emeli-dral

Hello @emeli-dral

I'm trying to migrate to the new version and I was using something like report.html() where report was a dashboard. I've seen that the option is not available anymore. Now, you need to download the html file and I don't want it, i need the html itself to use it as part of a dash app.

I tried your solution (report.show().data) and it seems to return actual html code with a lot of data, but at the end it only shows a Loading... message.

<div class="reset-this-parent" id="root_evidently_dashboard_1a742a20693240cda4e857eaf89f80d4">Loading...</div>

Do you have any idea or solution? thanks.

alvarodemig avatar Jul 18 '23 15:07 alvarodemig

Hi @alvarodemig, in which environment (e.g. Jupyter notebook) are you trying to display the report?

Here is the documentation https://docs.evidentlyai.com/integrations/notebook-environments

E.g., in Google Colab: you can simply call the report object to display it inline after generating it.

In Jupyter notebook, you must also install nbextension - this is required to be able to display the report inline.

In other environments (e.g. Jupyter notebook on Windows, Databricks notebooks) - you must explicitly add an argument to display the report inline: report.show(mode='inline')

elenasamuylova avatar Jul 18 '23 16:07 elenasamuylova

Thanks for your response @elenasamuylova

It is a dash-app that I run in gunicorn.

I need the plain html code to add it inside a dash html.Iframe object. In older versions, i just needed to do something like: drift_html = report.html() (a deprecated Dashboard object) and I could use it directly.

But now, html() is deprecated and only save_html() is available, but I don't want to save any file.

alvarodemig avatar Jul 18 '23 18:07 alvarodemig

Hi @alvarodemig , to double-check: have you tried the above solution?

drift_report.show() or drift_report.show(mode='inline')

This is the functionality that generates the HTML code directly in your execution environment. It is different from drift_report.save_html("file.html") that saves the file externally.

elenasamuylova avatar Jul 18 '23 20:07 elenasamuylova

Hello again @elenasamuylova !

I finally was able to make it work with: drift_report.show(mode='inline').data ;)

Thank you for your help!

alvarodemig avatar Jul 19 '23 15:07 alvarodemig

Hi @abockmann - wanted to follow up on your initial question about converting JSON <-> HTML.

Starting from Evidently 0.4.0, we introduced ML monitoring service that relies on JSON snapshots for logging. A snapshot is a rich JSON representation of the Evidently Report or Test Suite. To generate a snapshot, you must use the _save function:

data_drift_checks._save("data_drift_snapshot.json")

If you save Evidently Reports / Test Suites as snapshots, you can load them back and recreate the original Evidently Report of Test Suite in any of the familiar formats (HTML, JSON, Python dictionary).

This might be an option to consider if you want to minimize storing Evidently outputs in two formats simultaneously.

Docs here: https://docs.evidentlyai.com/user-guide/monitoring/snapshots#save-the-snapshot

elenasamuylova avatar Aug 01 '23 12:08 elenasamuylova