Nbdev and huggingface login

I created a notebook which does not export any module, but has some documentation (with code). One of the cells is calls huggingface_hub.login(), which is now being asked by nbdev_prepare. How do I handle hf tokens with nbdev?

The login method most likely will have a parameter where you can pass your access token as an argument.

If your code is going to be visible for everyone to see, you may want to create a local text file that you don’t push to GitHub (or wherever you’re hosting your docs). The local text file would contain your access token, and your program would read this file and pass the access token as an argument to login.

Alternatively, you could try using the #| exec_doc or the #| eval cell options. You can read more here: nbdev - Directives

1 Like