How to import all modules

I would like to import a bunch of modules using the “.all” for my library the same way it is working for fastai.

from import *

How can I make this to work in my custom nbdev library? I’ve created a sub module but it does not seem to work by importing

from mynbdevlib.submodule.all import *

Instead I need to do this

from mynbdevlib.submodule.a import *
from mynbdevlib.submodule.b import *

Is the “all” notation something that nbdev supports or do I need to manually add my modules inside the file for my autogenerated library?

best regards/
Daniel is a separate module inside each module(like Vision, Tabular, etc) in the fastai library. As the first chapter of the fastbook says, all is a module that contains all the necessary functions that you need to do anything related to the parent module (Like Vision, for example), so you don’t run into any import or recurse errors!

1 Like

Thanks. But do I create the my self or can it be generated using nbdev? I mean it always feels strange to manually add a file to an auto generated folder with files.

I don’t think there is any way to generate with nbdev - so I’m pretty sure these are all created by hand for fastai.

You can see from that might need to import from outside the submodule - I can’t think of a way that nbdev could know what should be in

1 Like

I solved it by creating a notebook that was exported as “all” and where I wrote all import statements.

1 Like