Jupytext: Open Rmd files as notebooks in Jupyter Lab

Created on 29 Jun 2018  路  10Comments  路  Source: mwouts/jupytext

The RmdFileContentsManager is active in Jupyter Lab (and saves the edited notebook to the desired alternative extensions), but .Rmd files still open as text.

Cf. also https://github.com/jupyterlab/jupyterlab/issues/3896

Most helpful comment

I confirm this is merged into master and will be part of the next milestone release.

All 10 comments

I cannot exclude that the issue is with jupyter lab. I've provided a minimal example with the issue at https://github.com/jupyterlab/jupyterlab/issues/4924

Fixed in the latest development version of jupyter.
There is now a 'Notebook' entry in the 'Open With' context menu for such notebooks.

Thanks @grst for your development. Is is correct that the patch will be available starting with Jupyter Lab 0.35?

People are asking on twitter how to install the dev version of JupyterLab: instructions are here, but installation may not be straightforward!

@grst So, it's actually on master branch now?
https://github.com/jupyterlab/jupyterlab/pull/5247

I confirm this is merged into master and will be part of the next milestone release.

I install Jupyter using conda. Jupytext works as expected using the notebook format. In the lab format jupytext creates synced files as expected, but doesn't render .md or .Rmd files as notebooks. I'm sure you already know that. The version of jupyterlab conda installs for me is 0.35.1. Pip gives me jupytext 0.8.1. Is there a way I could install the master branch with the currently working jupytext without messing up conda? I usually don't like mixing conda and non-conda except for pip.

BTW, jupytext does not seem to have a "version" flag.

(base) balter@spectre:~$ jupytext -v
usage: jupytext [-h]
                [--to {notebook,rmarkdown,markdown,python,R,julia,c++,scheme,ipynb,md,Rmd,R,py,jl,cpp,ss,md:markdown,Rmd:rmarkdown,R:spin,py:light,R:light,jl:light,cpp:light,ss:light,py:percent,R:percent
,jl:percent,cpp:percent,ss:percent,py:sphinx,py:sphinx-rst2md}]
                [--from {notebook,rmarkdown,markdown,python,R,julia,c++,scheme,ipynb,md,Rmd,R,py,jl,cpp,ss,md:markdown,Rmd:rmarkdown,R:spin,py:light,R:light,jl:light,cpp:light,ss:light,py:percent,R:perce
nt,jl:percent,cpp:percent,ss:percent,py:sphinx,py:sphinx-rst2md}]
                [-o OUTPUT] [--update] [--test]
                [notebooks [notebooks ...]]
jupytext: error: unrecognized arguments: -v
(base) balter@spectre:~$ jupytext --version
usage: jupytext [-h]
                [--to {notebook,rmarkdown,markdown,python,R,julia,c++,scheme,ipynb,md,Rmd,R,py,jl,cpp,ss,md:markdown,Rmd:rmarkdown,R:spin,py:light,R:light,jl:light,cpp:light,ss:light,py:percent,R:percent
,jl:percent,cpp:percent,ss:percent,py:sphinx,py:sphinx-rst2md}]
                [--from {notebook,rmarkdown,markdown,python,R,julia,c++,scheme,ipynb,md,Rmd,R,py,jl,cpp,ss,md:markdown,Rmd:rmarkdown,R:spin,py:light,R:light,jl:light,cpp:light,ss:light,py:percent,R:perce
nt,jl:percent,cpp:percent,ss:percent,py:sphinx,py:sphinx-rst2md}]
                [-o OUTPUT] [--update] [--test]
                [notebooks [notebooks ...]]
jupytext: error: unrecognized arguments: --version

@abalter , as you found out this is indeed documented at #78. Opening text notebooks in Jupyter Lab requires Jupyter Lab 0.35 or later (it's good to know that Jupyter Lab 0.35.1 is out, I will update the readme!), and then a right click on the file, thanks to @grst 's contribution to Jupyter Lab:

image

Thanks for pointing that out! I did not pick up that that was an official part of current jupytext. The right-click method works for me (most of the time).

My preference would be something less hidden such as one of the following:

  • When opening a *md file you get a dialog asking how you want to open it.
  • A way to toggle back and forth between views with a drop down like changing kernels.

I'll take a loot at @grst's PR and see if I can figure out how to add that code.

Hello. Thank you for the wonderful work on JupyText.

There is a configuration option (in configuration file for example) to open .Rmd as notebooks by default?

Hello @albham , sorry we don't know how to do that in Jupyter Lab yet. For now you have to either use Jupyter Notebook, or to use the right-click approach. If you want to get updates on the subject, I suggest that you subscribe to #271 (that one is for .md files, but obviously when we find out how to do .md files, we'll do .Rmd files as well).

Was this page helpful?
0 / 5 - 0 ratings