imbue-ai/jupyter_ascending

Sync from *.ipynb to *.py file

Closed this issue · 4 comments

Hi, I'm wondering does this sync works bi-directional? Say I have a .ipynb file from a collaborator and I want to edit it.

In the example, the command only sync the stuffs in .py file to the notebook.

I tried

python3 -m jupyter_ascending.requests.sync --filename example.sync.ipynb

But it seems to do nothing. I'm wondering is this feature currently supported?

Sorry, this tool currently only does one-directional syncing! Bidirectional syncing is very tricky because you potentially can introduce the equivalent of merge conflicts if both sides change the same part of the file. You could potentially do something simple like "only allow reverse syncing if only one side has changed, otherwise take the .py version", but I wouldn't expect to see support for this anytime soon.

Hi, thank you for the reply. I should make it more clear: the key request is not bi-directional sync, but the ability to create a .py file from a pre-existing .ipynb template (more like an option in init command).

Imagine you have a unfinished notebook or notebook from others that you want to further edit.

And after initiation, and when I have this .ipynb template in my .py, I have no problem with the uni-directional sync, as all the editing should be done in .py file.

Ah, can you just export the ipynb as a .py file in Jupyter? I forget what cell delimiters that'll give you, but it should be pretty easy to fix up manually if needed.

Otherwise check out jupytext - something like jupytext --to py:percent notebook.ipynb should do what you want, I think.

The jupytext did the work! Thank you so much