mwouts / jupytext

Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts
https://jupytext.readthedocs.io
MIT License
6.51k stars 385 forks source link

jupytext plugin for pycharm. #495

Open hongyi-zhao opened 4 years ago

hongyi-zhao commented 4 years ago

Hi,

It seems there is still no jupytext plugin for pycharm.

Any hints?

Regards

mwouts commented 4 years ago

Hello @hongyi-zhao , that is correct, we don't have a plugin for PyCharm yet. Note that we discussed that previously at #147, but I think now the notebook mode of PyCharm Professional works well - do you think the plugin would still be useful?

Also, in my experience, even without a plugin, jupytext works well with PyCharm. You just have to pair your .ipynb notebooks with .py files, using either the Jupytext menu or command in Jupyter, or with e.g. jupytext --set-formats ipynb,py:percent *.ipynb. And then, once you've edited your .py files, the changes are pushed to the notebook when you either reload the notebook in Jupyter, or run jupytext --sync *.ipynb.

hongyi-zhao commented 4 years ago

Hello @hongyi-zhao , that is correct, we don't have a plugin for PyCharm yet. Note that we discussed that previously at #147, but I think now the notebook mode of PyCharm Professional works well - do you think the plugin would still be useful?

I set the following option in ~/.jupyter/jupyter_notebook_config.py:

c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"
c.ContentsManager.default_jupytext_formats = "ipynb,py:percent"
c.ContentsManager.outdated_text_notebook_margin = float("inf")

It seems this mode doesn't respect the paring settings.

Also, in my experience, even without a plugin, jupytext works well with PyCharm. You just have to pair your .ipynb notebooks with .py files, using either the Jupytext menu or command in Jupyter, or with e.g. jupytext --set-formats ipynb,py:percent *.ipynb. And then, once you've edited your .py files, the changes are pushed to the notebook when you either reload the notebook in Jupyter, or run jupytext --sync *.ipynb.

Thanks for your detail notes.

matanox commented 2 years ago

I got a little lost on how to pair for PyCharm Professional to make or maintain the pairing through jupytext. Is it really straightforward? I mean have them paired in the sense that as you edit the notebook (ipynb) file in PyCharm, it updates the markdown/python mirror file which goes to git. Which is our flow with Jupyter Lab at least, and seems like the more natural way of working up notebooks to me.

Is it supposed to work with PyCharm?

matanox commented 2 years ago

Okay I think I get your suggestion ― basically, just manage the sync from outside of PyCharm if I get it right ― and hopefully PyCharm will not shoot you in the foot when the syncing is taking place from a command-line, nor when the Jupyter server which PyCharm Professional is connecting to is triggering the sync.

hongyi-zhao commented 2 years ago

I'm not sure if anyone here has the same experience and can check this problem. I haven't used PyCharm for a long time since this issue was submitted.