Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Jupytext for JupyterLab #877

Merged
merged 7 commits into from
Nov 29, 2021
Merged

Enhance Jupytext for JupyterLab #877

merged 7 commits into from
Nov 29, 2021

Conversation

fcollonval
Copy link
Contributor

@fcollonval fcollonval commented Nov 19, 2021

  • Make ICommandPalette optional (support for RISE)
  • Support translation
  • Add new factory to open supported file directly with notebook view
    In JupyterLab, the default behavior is still to open the markdown file through the context menu. But that can be changed in the settings.

- Make `ICommandPalette` optional (support for RISE)
- Support translation
- Add new factory to open supported file directly with notebook view
@fcollonval
Copy link
Contributor Author

The initial needs for this PR is to make ICommandPalette optional for RISE within JupyterLab (damianavila/RISE#605).

I took that chance to add support for translation and improve a painful use case of opening directly md file with the notebook view.

This should
fix #271
fix #803

@mwouts
Copy link
Owner

mwouts commented Nov 21, 2021

Hello @fcollonval , thank you so much for this! I'll find some time this week to review and test this, but already I am looking forward to it, indeed some of the issues you address here have been there for a while!

@mwouts
Copy link
Owner

mwouts commented Nov 22, 2021

I gave a quick try to a local build tonight, and took a few notes of what worked as expected, and what did not:

  • The Jupytext FAQ is among the commands
  • The pairing commands are there
  • Double clicking on README.md opens the file as a notebook (not the case for me - it opened with the text editor - was it supposed to open with a notebook ?)
  • Clicking on a .md link within a .md notebook opens the link with the notebook editor (not the case for me - it opened with the markdown viewer)

@fcollonval what do you get for double click / links? Or maybe my local install did not work? (I used BUILD_JUPYTERLAB_EXTENSION=1 jupyter labextension develop . --overwrite, what do you use on your end?)

@fcollonval
Copy link
Contributor Author

This is strange. I just tried on Binder: https://mybinder.org/v2/gh/fcollonval/jupytext/main and md files open with the notebook viewer.

@mwouts
Copy link
Owner

mwouts commented Nov 23, 2021

This is strange. I just tried on Binder: https://mybinder.org/v2/gh/fcollonval/jupytext/main and md files open with the notebook viewer.

Thanks for the link, I do agree - I'll retry from scratch tonight. So we're good with the double click (I am eager to test with this combined with the configuration option). Re the md links in notebooks, I had the impression that (on the binder repo above) they open with the markdown viewer rather than the notebook viewer, does this means that we need to change another setting to open them with the notebook viewer?

@fcollonval
Copy link
Contributor Author

the md links in notebooks

This one is not working as expected; this should be fixed upstream (Xref jupyterlab/jupyterlab#7776). so that if the user defines another default viewer, it will be picked when open markdown link.

Add widgets opened by the new factory to the notebook factory so commands will work
@fcollonval
Copy link
Contributor Author

@mwouts I created the following screencast for the documentation to change the default viewer on JupyterLab. I'm a bit confused on where to put it.

jupyterlab_default_viewer

@mwouts
Copy link
Owner

mwouts commented Nov 25, 2021

Thanks for the screenshot, that is very helpful ! Maybe we can add the screenshot, together with a text version of the config file (so that the user can simply copy/paste), in docs/index.md, at the end of the Install section - what do you think ?

@fcollonval
Copy link
Contributor Author

I updated the doc and the binder configuration to change the default viewers.

I opened PRs upstream in JupyterLab that should simplify the code when JupyterLab 4 is out: jupyterlab/jupyterlab#11526 jupyterlab/jupyterlab#11540 jupyterlab/jupyterlab#11541

@mwouts
Copy link
Owner

mwouts commented Nov 29, 2021

Thank you @fcollonval , this is great! I plan to do another testing session tonight, and if all goes well I hope to ship a new version as well. Thank you so much for you work here!

@mwouts
Copy link
Owner

mwouts commented Nov 29, 2021

Well, developing the lab extension is obviously not so easy for me... I still cannot reproduce the new functionality locally 😢

Most probably I am not using the right approach to build the development version of the application? I have followed my notes but maybe they are outdated? Also I've tried

npm install   # install npm package dependencies
npm run build  # optional build step if using TypeScript, babel, etc.
jupyter labextension install  # install the current directory as an extension

from the development documentation, but that one complained about jupyterlab.schemaDir (the error was schemaDir is empty: "schema"), so I removed the value and the command worked, but I still did not get the new functionality....

Anyway I'll integrate your changes as I have seen it working on Binder... and if you have any advice on how to test locally then I am all ears!

@mwouts mwouts merged commit 39ee4f1 into mwouts:main Nov 29, 2021
@mwouts
Copy link
Owner

mwouts commented Nov 30, 2021

I've seen it working locally, finally! I just had to remove the two local versions of the extension...

(jupytext-dev) $ jupyter labextension list
JupyterLab v3.2.4
/home/marc/.local/share/jupyter/labextensions
        jupyterlab-jupytext v1.3.6 enabled OK (python, jupytext)
        @jupyter-widgets/jupyterlab-manager v3.0.1 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /home/marc/miniconda3/envs/jupytext-dev/share/jupyter/lab


   local extensions:
        jupyterlab-jupytext: /home/marc/GitHub/jupytext_fcollonval/packages/labextension

@fcollonval
Copy link
Contributor Author

Hey @mwouts

The logic I followed to install this package (including lab extension) in dev mode is:

conda create -y -n jupytext jupyterlab=3 nodejs
conda activate jupytext
cd <path>/<to>/<jupytext>
pip install -e .
cd packages/labextension
jlpm install
jlpm run build
cd ../..
jupyter labextension develop --overwrite .

The latest command will symlink the dev lab extension within the lab extensions folder.

@fcollonval
Copy link
Contributor Author

Jupytext strings are ready to be translated: https://crowdin.com/project/jupyterlab/content/files

@fcollonval
Copy link
Contributor Author

@mwouts FYI I created a gist to demonstrate JupyterLab + Jupytext with French translation: https://gist.github.com/fcollonval/527631f0193f8c4f801d68e1b90a5ba2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants