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

cannot open a jupytext notebook in nb7 #6914

Closed
parmentelat opened this issue Jun 12, 2023 · 11 comments · Fixed by #6946
Closed

cannot open a jupytext notebook in nb7 #6914

parmentelat opened this issue Jun 12, 2023 · 11 comments · Fixed by #6946
Labels
Milestone

Comments

@parmentelat
Copy link
Contributor

parmentelat commented Jun 12, 2023

Describe the bug

The jupytext extension does not work as expected in nb7

To Reproduce
Steps to reproduce the behavior:

  1. install jlab4 as released in pip
  2. install nb7 with pip install -U --pre notebook
  3. install jupytext with pip install jupytext
  4. install the jupytext labextension with
    pip install git+https://github.com/mwouts/jupyterlab-jupytext.git@jupyterlab4
  5. create a simple jupytext notebook named for instance foo-nb.md
  6. under jlab, check that you can open the notebook: right click → "Jupytext Notebook"
  7. perform the same operation from the regular notebook tree browser: the "Jupytext Notebook" option is present but does not open the file as a notebook, it shows a text editor instead

Expected behavior

  1. we should be able to open a jupytext notebook from the regular notebook file browser;
  2. (also when opening a URL like localhost:8888/notebooks/path/file.md we need this to open a notebook and not a text editor, but for that to work the former behaviour 1. must first work)

Screenshots

image

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS & linux
  • Browser [e.g. chrome, safari] - chrome
  • Version [e.g. 22]

Additional context

Please see also https://discourse.jupyter.org/t/generic-question-about-jlab4-and-nb7/19846

@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to issues that need triage label Jun 12, 2023
@jtpio
Copy link
Member

jtpio commented Jun 13, 2023

Thanks @parmentelat for reporting.

Steps to reproduce the behavior:

Looks like we also need to install jupytext with pip install jupytext? Not sure jupyterlab-jupytext installs jupytext automatically?

After following the instructions above and the additional pip install jupytext it seems like it's possible to open the markdown file with the notebook factory via the context menu:

jupytext-factory.mp4

But the behavior seems to be similar in JupyterLab right? By default double-clicking on the markdown file or opening it with the default "Open" context menu shows the markdown source:

jupytext-jupyterlab.mp4

@jtpio
Copy link
Member

jtpio commented Jun 13, 2023

Also this might be related to #6324.

@parmentelat
Copy link
Contributor Author

Looks like we also need to install jupytext with pip install jupytext? Not sure jupyterlab-jupytext installs jupytext automatically?

that is correct, I should have mentioned the pip install jupytext in the steps to reproduce, let me edit them accordingly

@parmentelat
Copy link
Contributor Author

so, I confirm the I had tried the 'Open with' menu when reporting this

however I must admit that I am juggling between many environments, switching between stable and unstable versions of many different components, this is a bit overwhelming and my envs are in shambles...
so I guess I must have screwed up somehow somewhere; plus, the branches may have changed meanwhile

I will restart from scratch when I have a chance, most likely since all worked well for you, I should be able to report that as a red herring

@jtpio
Copy link
Member

jtpio commented Jun 13, 2023

ok no problem, thank you so much for trying Notebook 7!

@parmentelat
Copy link
Contributor Author

all right, so I tried again with the bare minimum set of extensions

and I can still see almost the same behaviour:

  • using the Open button, or the Open withJupytext Notebook menu
    • I am getting an editor with the raw content
  • however, using the Open withNotebook menu
    • this time it does open a notebook

just to be sure it's not because of the input file, here's the notebook I am trying to open
https://raw.githubusercontent.com/parmentelat/jupyterlab-tpt/main/examples/test-nb.py

same behaviour with a .md here
https://raw.githubusercontent.com/parmentelat/jupyterlab-tpt/main/examples/sandbox-nb.md

here's console screenshots when using the "Jupytext Notebook" path

  • the notebook tab
    image

  • the spawned tab
    image


this recording ends a little early but the last attempt works fine
nb7-jupytext10

@parmentelat
Copy link
Contributor Author

also, probably relevant to this discussion, I must say that my environment includes the following, which is needed in the context of jlab to get the default action (e.g. double click) to open as a notebook

I might redo the experiment without that in place, if that sounds a useful test (although it should only help, in theory, no ?)

cat ~/.jupyter/labconfig/default_setting_overrides.json
{
  "@jupyterlab/docmanager-extension:plugin": {
      "defaultViewers": {
          "python": "Jupytext Notebook",
          "markdown": "Jupytext Notebook"
    }
  }
}

@jtpio jtpio added this to the 7.0 milestone Jun 14, 2023
@jtpio
Copy link
Member

jtpio commented Jun 15, 2023

Just checked and it seems like the default viewers are not respected in Notebook 7 while they are in JupyterLab:

default-viewers-jupytext.mp4

@jtpio
Copy link
Member

jtpio commented Jun 19, 2023

Closing as fixed by #6923

While investigating #6923, we noticed something that could also be an issue in JupyterLab (toolbar not rendering), which has been reported in mwouts/jupyterlab-jupytext#3 (comment).

Please feel free to re-open if you are still seeing issues, thanks!

@jtpio jtpio closed this as completed Jun 19, 2023
@parmentelat
Copy link
Contributor Author

parmentelat commented Jun 22, 2023

Hiya lads

I am currently struggling with a bug on our deployment when trying to use nb7
and it might be related to this issue

in a nutshell, I run something like this

jupyter lab  --NotebookApp.base_url=/some-container-dep-prefix/

and apparently when trying to open a jupytext notebook the app answers with a redirect to
/edit/the-path/to-the-notebook
while I really need it to redirect to
/some-container-dep-prefix/edit/the-path/to-the-notebook

I just came across this and don't yet have an easily reproducible sandbox,
but is it possible that a hasty change has just forgotten to take this base_url setting into account ?


admittedly the relationship with this issue is just a hunch on my side,
so please let me know if you'd rather deal with this in a separate issue instead

@jtpio
Copy link
Member

jtpio commented Jun 22, 2023

Thanks @parmentelat.

Yes it looks like an issue with the base URL.

FYI I submitted a fix for #6940 in #6941 which might be related.

This is available in 7.0.0rc1 if you would like to try it: https://github.com/jupyter/notebook/releases/tag/v7.0.0rc1

Otherwise yes a new issue to track this would be great, thanks!

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

Successfully merging a pull request may close this issue.

4 participants