Error: Notebooks and library are not in sync

First off, I wanted to thank everybody involved with developing nbdev. It really does make my life as a researcher much much easier every day since I’ve started using it.

While developing a package for my current research project, I’ve recently started to receive the error code “Error: Notebooks and library are not in sync. Please run nbdev_export” during the CI workflow on github (see Screenshots below). I always run nbdev_prepare before committing any code to github, which automatically runs nbdev_export. I’ve tried running only nbdev_export as well, of course, (just like various other random attempts at trying to fix the issue), but I just can’t seem to find the root cause of the error. Maybe it is something really simple and I’m blind somehow. Sry, if that’s the case.

The error only started appearing 2 days ago. Before that, everything worked just fine. During the first commit, that lead to the mentioned error, I unfortunately added quite a few changes to my code at once. Most of them were related to the index.ipynb, because I was building a meaningful README file. The package I’m building itself runs just fine. The local tests pass without any problem (and there are many of them) and I can install and run the package just fine on other hardware.

You can find repo here:

This was the first run, where the error occurred:

Here are said screenshots of the runs on github:


I have no idea, if this is in any way related to my problem, but I also receive the following warning whenever I run nbdev_prepare (it appeared already before the CI error started to happen):

Thanks already in advance for your help. It is greatly appreciated.

2 Likes

This should be fixed by upgrading nbdev to the latest version locally. In general, issues in CI that you struggle to replicate locally are often fixed by using the same version

1 Like

I’ve hit this when copying old notebooks to new ones and forgetting to update default_export.

For example, my day7.ipynb notebook still said #| default_exp: day6. Two signs:

  • day7.py was absent from the module
  • CI was complaining about day6.py which indeed was being clobbered.

But all the docs and notebooks looked fine! :man_facepalming:

Hi! I’ve found this problem when creating a (very basic) PR for Fastai:
(Removed line with no effect from tabular_learner by pablogps · Pull Request #3856 · fastai/fastai · GitHub).
I synced the repo before doing the one commit (removing one line of code), using only online Github, so I’m a bit confused here at a theoretical level. Do I need to fix something?

So Jeremy kindly replied to my PR:

Thanks for the PR. Since this is an nbdev project, any changes need to be made in the source notebook, and then exported to the .py files.

So it seems like it is not possible to make direct contributions to the repository like I tried!

I agree that updating nbdev usually fixes this error.

But what do we do when it doesn’t? i.e. we update nbdev and then re-run nbdev_export but it produces no changes? (thus, nothing new to commit or push)

for example: Actions link: added 2d projection support (still 3d render though) · drscotthawley/aeiou@913b4eb · GitHub