Nbdev ignoring "recursive = False"

I don’t want recursion, but it does anyway.

My settings.ini contains:

nbs_path = .
doc_path = docs
recursive = False

However, when I run nbdev_build_lib it finds notebooks in other folders, such as exploratory/myproject/*.ipynb and tries to convert those too.

How do I get it to stop doing this?

What version of nbdev are you using? Can you upgrade?

I was using 1.1.12, which I see is before you patched this. So I upgraded to current (1.1.14).

  • nbdev_build_lib respects the flag: toggling it changes recursion.
  • nbdev_build_docs ignores it: always recurses.

Example with recursive = False:

notebooks>touch example.ipynb                        # Create empty file
notebooks>mv example.ipynb exploratory/              # Move it to subdir
example.ipynb -> exploratory/example.ipynb
(peregrine) notebooks>nbdev_build_docs               # Run build_docs
converting: /Volumes/Peregrine/pg_tools/code/notebooks/exploratory/example.ipynb
Notebook does not appear to be JSON: ''...
Conversion failed on the following:

It seems I’m running today’s version (Apr 19):

notebooks>ll `which nbdev_build_docs`
-rwxrwxr-x  1 ...  wheel   297B Apr 19 10:35 /opt/anaconda3/envs/peregrine/bin/nbdev_build_docs

Fixed in https://github.com/fastai/nbdev/pull/467

1 Like

Thank you! :pray: Pulled and tested.

I think the same patch is needed in _create_default_sidebar(). At least that solved a remaining issue for me.

    #files = nbglob(recursive=Config().get('recursive',None))
    files = nbglob(recursive=Config().get('recursive', 'False').lower() == 'true')

Grep shows 3 locations with Config().get('recursive'..., so maybe one more:

nbdev//nbs/03_export2html.ipynb:    "    notebook2script(fname=fname, bare=bare, recursive=Config().get('recursive', 'False').lower() == 'true')"
nbdev//nbs/03_export2html.ipynb:    "    recursive=Config().get('recursive', 'False').lower() == 'true'\n",
nbdev//nbs/03_export2html.ipynb:    "    files = nbglob(recursive=Config().get('recursive',None))\n",

I audited all instances of this and fixed in https://github.com/fastai/nbdev/pull/470


Thank you! Unsurprisingly much better than my attempt would have been.

:coffee: (Do you have a coffee fund?)

Just pass on the love to someone else :slight_smile:

1 Like