Nbdev v2 launched

Have you tried setting recursive = True in your settings file? EDIT: and any chance you could share a repo with this issue?

1 Like

@Daniel take a look at the nbdev repo how we have a tutorials and explanations folder nbdev/nbs at master · fastai/nbdev · GitHub

Also look at our _quarto.yml

You also probably want recursive=True like Wasim is saying

1 Like

Thank you so much Wasim, this solves the problem of displaying notebooks from nbs/ and other folders beneath it.

Thanks a lot Hamel! The nbdev folder does give a great example, and it’s very instructive.

However, after I used recursive = True I have unexpected error reported from nbdev_prepare, the error will disappear when recursive=False.

My repo is here

This error is because those notebooks weren’t running during nbdev_test before with recursive=False. What’s happening now is that running one notebook’s tests is causing the following notebook to fail.

Based on your notebooks I managed to narrow it down to the following. This is effectively what nbdev_test is doing under the hood:

from execnb.shell import CaptureShell
s = CaptureShell()
s.run('''from fastdebug.core import *
from fastcore.meta import delegates
g = locals()
fdb = Fastdb(delegates, outloc=g)
fdb.docsrc(16, "", "getattr(to_f, '__annotations__', {})")''')
s2 = CaptureShell()
s2.run('from fastdebug.core import *; Fastdb')
print(s2.prettytb())

I’m not sure how fastdebug works so I stopped debugging there. Might be that it’s manipulating globals() in some unexpected way?

1 Like

@Daniel you might find this write-up helpful. It explains how this all fits together

It would be great if we could figure out how to make each CaptureShell’s imports unaffected by other ones

1 Like

I guess Practical Deep Learning for Coders website itself was created using nbdev, right?

Where can I find the repo? The course22 repo contains only the jupyter notebooks of the lessons. There is not _quarto.yml file with the website structure.

The same for fastai’s website. There is the lib’s repo, is the website fast.ai defined in the lib’s repo? I tried searching for “Being cool is about being exclusive” in Github inside fastai organization and couldn’t find. Could it be that the fastai site is not a public repo?

Thanks a lot Wasim! I think you could be right it was due to my unexpected use of locals() or globals(). I intend to remove most of the g = locals(), and I will report what will happen after the changes.

3 Likes

Today I have skim through the directive page and best practice of nbdev. They are super amazing!

First of all, I remembered I requested this feature, and Jeremy said will think about it. Here it is! Thank you nbdev team so much for creating this directive! :rocket: :+1:

This directive is super useful :+1: when I use run nbdev_prepare on a notebook with training models.

I love this one too!

2 Likes

When I set recursive=True as suggested, it seems that nbdev does something else besides including subfolders in notebook globs. For example, I think it runs cells that are explicitly marked not to be evaluated. My impression is that it ignores #| eval: false and

skip_showdoc: true
skip_exec: true

Interesting. Could you share more? Perhaps a link your repo?

Not in my case. They are not executed when I do nbdev_prepare

Hi guys,

Is there a way to export a function includes codes which contains % or %% like the one below?

#| export
def reload():
    %load_ext autoreload
    %autoreload 2
reload()    

I have raised the question here previously

Note that this question is duplicated and was cross-posted on this GitHub Issue

I will try to recreate the problem I saw with a minimal example and open a new issue if necessary. Therefore, this question is no longer tracked on the issue mentioned by @hamelsmu.

Thanks, I certainly missed it.

1 Like

I found #| export othermodule not working stably in my project, but I received no error or warning on this behavior.

I ask to export to a module named “delete0002” as below in this notebook

Then I want to export the function named “get_exp_data” to a different module, here I tried 4 modules, it succeeded on the oldest two modules, not failed to all the newly created modules. And I have received no errors on this behavior.

I have no idea why it is so, could you have a look? Thanks

Some other Nb needs to set those modules as default_exp

1 Like

Thank you so much Jeremy for your reply!

It was not the cause to the problem as I did make sure all those Nbs have their own modules as default_exp as you can see their modules below, and the current notebook’s module is delete0002 which is also created below.

Hmmm… Maybe the filenames need to be sorted so earlier filenames set the default_exp before others add to their modules?

(sorry I don’t use this feature myself so am not so familiar with it)

1 Like