fastai / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.93k stars 488 forks source link

Allow for a one-time only (potentially) .py -> .ipynb generation #369

Closed muellerzr closed 3 years ago

muellerzr commented 3 years ago

Goal is to allow for quick and easy use/conversion from non-nbdev repositories into nbdev repositories. Will be looking into this

hamelsmu commented 3 years ago

Are you still working on this? Should this be left open?

muellerzr commented 3 years ago

@hamelsmu I passively am. If you/Jeremy see enough value in it I can post my code here, otherwise I may develop it separately.

hamelsmu commented 3 years ago

Today I learned about JupyText

You can convert any python file to a JupyterNotebook with the command jupytext --to ipynb somefile.py

In your directory with .py files you can run:

#!/bin/bash
for f in [^_]*.py; do # .py files except those with underscore in front
    jupytext --to ipynb $f
done

This will convert all python files to notebooks, excluding any file names that begin with an underscore! Let me know if you want to keep this open, but I'll close for now!

muellerzr commented 3 years ago

@hamelsmu this is awesome! May write a blog post or something about this, great find!

hamelsmu commented 3 years ago

May write a blog post or something about this, great find!

That's a great idea! I particularly like your ideas you brought up in discord about building on this and inserting some additional nbdev things into the notebooks automatically for the user