How to take the advantage of both nbdev and IDE

When I was using nbdev to develop a package, I also heavily use vscode. I frequently use nbdev_update_lib and nbdev_build_lib. However, I organize my code by IDE, which cannot be converted by nbdev_update_lib. What is a good way to balance nbdev notebooks and vscode? Should I always use nbdev to write the code part?

1 Like

You might be able to run your notebooks inside of vs code with the Python extension and still use nbdev to generate the library. Having your notebooks inside VS Code as well would keep you inside your comfort IDE all the time while you can still benefit from interactive output and most of the jupyter goodness. However note that you are still stuck with jupyters shortcuts when using VS Codes notebook viewer.
The Python extension also enables you to define code cells inside a .py using comments (see here), which you can use for both interactive execution (while preserving your default code editing shortcuts) and later converting the file to an .ipynb, which you could use for nbdev. The conversion to .ipynb would probably have to be done manually tho.

I had some problems with doing autopep8 in vscode and my #Cell tag goes everywhere… Have you experienced that?

I don’t use autopep8, but I think it should not mess with comments… Maybe you can add an exception in the config?

Thanks @xeTaiz! I think it’s pylint to try to keep 2 lines of space between functions. And pylint always try to insert lines between # Cell and the function.

Can I suggest you try doing everything in your notebooks (o: In case you’ve not seen this already, it’s well worth a read.

At the risk of sounding really pushy, I’d also encourage you to adopt a more fastai coding style if possible - given time to adjust, I think you’ll prefer this style over pep8 for the kind of data science code you’re writing.

Hope this helps (o:

Thanks Pete! This is very helpful. Now I know why I have those strange error and everyone else seems fine.