[fastpages] Notebook rendering error

I am trying to add a new notebook to my fastpages repo to be rendered to a blog post. But it is failing to render throwing this error.

Traceback (most recent call last):
  File "/fastpages/nb2post.py", line 36, in <module>
    export2html.notebook2html(fname='_notebooks/*.ipynb', dest='_posts/', template_file='/fastpages/fastpages.tpl')
  File "/usr/local/lib/python3.7/site-packages/nbdev/export2html.py", line 436, in notebook2html
    raise Exception(msg + '\n'.join([f.name for p,f in zip(passed,files) if not p]))
Exception: Conversion failed on the following:
Failed validating 'oneOf' in display_data['properties']['data']['patternProperties']['^(?!application/json$)[a-zA-Z0-9]+/[a-zA-Z0-9\\-\\+\\.]+$']:

I am using Plotly here so this notebook will be big.
Is the choice of the library the problem or something else.
Can someone help?


What happens when you disable all plots (comment them out)?

I’ve had issues with plotly myself, BTW. What we can try to troubleshoot

With altair, I had problems rendering large notebooks, as it embeds all the data into the notebook itself, making it quite big. It has an option to save the chart data into a json file: by:

alt.data_transformers.enable('json'), keeping the notebook small.

The altair docs say a sensible limit is 5K rows for a javascript in notebook viz, I see your data has 10K rows so that could be an issue.

Anyways, I assume plotly has an option to json the data so the notebook size stays sensible and hence the conversion process should work better.

1 Like

That’s really interesting, how does the page load when a JSON file is separate, I assume this has to still be read in?

I didn’t know about the separate JSON file thing I will have to look into that! Thanks for sharing

The altair code in the notebook links to a json file which altair saves automagically. The process is a bit buggy working with jupyter lab becuase of how files are stored, but the upcoming 4.1 release of altair has an option to specify the path:

alt.data_transformers.enable('json', urlpath='files')

the reason being

The issue is that localhost filepaths are unpredictable between different flavors of Jupyter notebook.

With standard jupyter notebook with default settings it just saves a json file to the notebook folder.

So with fastpages I’m not sure of the best way to use this, but I assume you just point to a data path relative to the notebook, or just in the same directory. The fastpages script would have to copy those json files over to gh-pages. I assume right now it would just ignore those files.

It does make things a lot faster (at least on my dual core laptop). Which I don’t understand why, since the data is being loaded anyways, but it seems large notebooks makes the jupyter server slow down.

I wonder if it would make the web page load faster too ( which might not correlate with the notebook loading faster? ). I suppose we could try it out and see once the new release is out

I am having trouble with the 'front matter" markdown cell. Even though I am following the conventions, my notebook’s first cell is not rendering normally.

This renders as follows:

What am I doing wrong?

Put double quotes around your title and your summary, per the docs. You might need this to escape your apostrophe

Read the first line toc: true … carefully. Do you see what you did wrong?

The apostrophe in Bayes may be giving you trouble in the categories.

I’m sorry Hamel, but I’m still not able to see the mistake. I put the double quotes around my title and summary and same thing happened with just double quotes around it. Could you point out the mistake for me?

No problem,

You have two key value pairs in one line, badges should be on a seperate line

Thanks Hamel, Issue solved. Because of your and Jeremy’s work I was able to publish my first blog today :smile:

Hey @a_bhimany_u! Were you able to solve the issue for plotly? I noticed @khalido shared a solution, but it is for altair viz. I am having the same problem here. It was working normally with static plots, but not anymore with plotly. I got the very same error of yours.

I’m using both plotly and altair (along with matplotlib) for different plots, and discovered:

  • plotly recommends <15k points (no errors, but slow/big notebooks)
  • altair recommends < 5k points (gives errors after)

So especially for a blog, if you have many data things to plot, mpl is a good alternative as it makes a static image and sometimes a picture is good enough.

fastpages recommended altair so I’m trying to stick with it, I don’t know if they have optimized how it displays charts on gh-pages or something.

1 Like

It’s not optimized, its just the one that we have tested most extensively. We are able to override the limit for Altair (see example), however when you embed that much data into a web page it will load very slowly, and may not load at all, especially on slower internet connections