Page MenuHomePhabricator

Remove chart data from monthly report notebook
Open, LowPublic


Currently, Wikichart.finalize_plot calls in addition to saving the chart to its specified location. This displays the charts in the reporting notebook, which is helpful for the person running the metrics.

However, this also means that the full image data of each chart gets included within the notebook. That makes the file really large: currently 2.1 MB. This means that GitLab is usually unable to display a diff when the notebook is changed, which makes code review much harder.

We can work around this by including the graphs in the notebook via Markdown. Just put the following in a Markdown cell:


From the user's point of view, this looks nearly the same, but the contents of the image are not included in the notebook file. When I tested, switching to this method decreased the size of the file by 99%, to just 26 kB.

This apparently breaks when there's a space in the name of the image file, but it's easy enough for us to change those file names.

The images will still display in the notebook rendered by GitLab (example).

There may be a rough edge if an open notebook does not automatically update the displayed graph when the file changes (which will happen because the notebook calls the code to update the charts), but that's probably acceptable.