Renamed class works in nb, fails for docs

I have renamed my Config class to _Config to indicate that it isn’t meant to be used.
And this works fine in the notebook and for nbdev_build_lib but it fails for nbdev_build_docs and from the error I cannot figure out how/why?

A direct import check outside notebooks in an IPython session also works, so it is properly installed (via pip install -e .):

In [2]: from planetarypy.config import _Config

Did you #export the cell that has the definition of _Config?

Yes. And I checked the created Python code, that’s why it works in the IPython import, so all is there.

It starts with an underscore. Meaning it’s private. You need to add as a all for it to show in the docs

See the vision.augment PadMode class to see what I mean

Ah, I think I understand (even so I did not find a PadMode class in the nbdev repo)
Do you mean add a #add2all as described here: Export to modules | nbdev ?

Now a design question:
I want the users to use the config object from the config module, so I want to document the methods, but I don’t want them to create a new config object using Config(), that sounds like chaos for wanting to store plotting defaults in the config object for example.
That’s why I wanted to make the class definition private but still show the method docs. Would you just have kept it public? What’s the best way to do this?

I meant in the fastai repo, sorry. Now that I’m a computer what you do is have a cell defined as the following:

_all_ = ['_Config']

If it’s private it’s assumed from a design perspective that it’s not shown in the docs, and shouldn’t be. You should have an interface object or class of some form (if we’re talking software design)

You can make an interface config class, something like ConfigManager that can generate an instance of _Config and have public methods to call those methods, etc.

I’d name it something different such as EnvironmentConfig, if it’s geared like how you say and you just expose it publically

1 Like