Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for opening a document with a different factory#6315

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jtpio merged 3 commits intojupyter:mainfromjtpio:factories
Mar 21, 2022

Conversation

@jtpio
Copy link
Member

@jtpiojtpio commentedMar 18, 2022
edited
Loading

First steps towardsjupyterlab/retrolab#290.

For example when opening a JSON file with different factories:

open-factory-edit.mp4

This is also useful so folks can open notebooks with the text editor too:

open-factory-notebook.mp4

TODO

  • Basic support for custom factories when opening a document
  • Should this work for arbitrary widgets, like the settings editor? Decide whether to do this in this PR or as follow-up -> deferring to another PR / issue, see this comment for a proof of concept:Add support for opening a document with a different factory #6315 (comment)
  • Should the?factory= URL parameter be removed from the URL after the document is opened? -> keeping it when it is notdefault, so the page can be reloaded and the document renders the same

@jtpiojtpio added this to the7.0 milestoneMar 18, 2022
@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branchjtpio/notebook/factories

@jtpiojtpio changed the titleAdd support for opening a document with a factoryAdd support for opening a document with a different factoryMar 18, 2022
@jtpio
Copy link
MemberAuthor

Should the ?factory= URL parameter be removed from the URL after the document is opened?

Keeping it could be useful, so it can be copy pasted and sent to other people (or bookmarked). But some folks used to the classic notebook might wonder what this actually means.

@jtpio
Copy link
MemberAuthor

Should this work for arbitrary widgets, like the settings editor?

Probably this one could have special treatment.

Right now theNotebookShell only allows one widget to be added to themain area:

if(this._main.widgets.length>0){
// do not add the widget if there is already one
return;
}

An alternative could be to add it to the tree / dashboard page:

image

@jtpio
Copy link
MemberAuthor

An alternative could be to add it to the tree / dashboard page:

Some proof of concept to explore this:

tree-setting-editor.mp4

Posting here for visibility, but should probably be explored more in another PR.

@fcollonval
Copy link
Collaborator

Thanks a lot for starting@jtpio.

I got a call yesterday with@parmentelat about using Jupytext in notebook v7 (something we cannot overlook). Starting fromv1.13.2, Jupytext uses the document factory to display files with the notebook editor. So we definitely should check this PR works with Jupytext.

cc@mwouts

mwouts and parmentelat reacted with thumbs up emoji

@jtpio
Copy link
MemberAuthor

Thanks@fcollonval for the heads up. I think it should work with the Jupytext Notebook factory. Maybe we'll need to make sure it properly opens with the/notebook URL.

I installedjupytext withpip install jupytext locally and the server and lab extensions seem to be properly installed.

$ jupyter server extension listConfig dir: PREFIX/etc/jupyter    jupyterlab enabled    - Validating jupyterlab...      jupyterlab 4.0.0a22 OK    jupytext enabled    - Validating jupytext...      jupytext 1.13.7 OK    notebook_shim enabled    - Validating notebook_shim...      notebook_shim  OK
$ jupyter labextension listJupyterLab v4.0.0a22PREFIX/share/jupyter/labextensions        jupyterlab-jupytext v1.3.8 enabled  X (python, jupytext)        @jupyter-notebook/lab-extension v7.0.0-alpha.1 enabled OK

The lab extension loads fine. However thejupytext server extension seems to be failing on startup: with

[W 2022-03-19 17:15:02.569 ServerApp] jupytext | extension failed loading with message: name 'build_jupytext_contents_manager_class' is not defined

@jtpio
Copy link
MemberAuthor

jtpio commentedMar 19, 2022
edited
Loading

Ah looks like it tries to importLargeFileManager fromnotebook.services.contents.largefilemanager here:

https://github.com/mwouts/jupytext/blob/d25c0c640ca0b2c1fb0e15b99be81bb82d2fe5ab/jupytext/contentsmanager.py#L573-L581

Which could be related since these are not available in Notebook v7... (but could be shimmed?)

Does jupytext work with Jupyter Server / JupyterLab only? Or does it expect the classic notebook server (via thenotebook package) to be available too?

@jtpio
Copy link
MemberAuthor

Ah looks like it tries to importLargeFileManager fromnotebook.services.contents.largefilemanager here:

This looks good when running with the fix proposed inmwouts/jupytext#933:

jupytext-factory.mp4

Just need to open it under/notebooks to match the behavior of the classic notebook v6.

fcollonval and parmentelat reacted with hooray emojifcollonval and parmentelat reacted with heart emoji

@fcollonval
Copy link
Collaborator

fcollonval commentedMar 20, 2022
edited
Loading

Thanks a lot for testing it with Jupytext.

Just need to open it under/notebooks to match the behavior of the classic notebook v6.

How do you plan to support that case? I think we will be able to supported it out of the box by applyingjupyterlab/jupyterlab#11540 in Jupytext.

@jtpio
Copy link
MemberAuthor

I think we will be able to supported it out of the box by applyingjupyterlab/jupyterlab#11540 in Jupytext.

Maybe only theNotebook factory should open in/notebooks then? Looks like this would indeed work out of the box with this PR?

@jtpiojtpio marked this pull request as ready for reviewMarch 21, 2022 09:55
@jtpio
Copy link
MemberAuthor

Documents now open with their default factory, for example when double-clicking on the item in the file browser.

When opened with a different factory,?factory= is kept in the URL so the browser tab can be reloaded and the document renders the same:

default-factory.mp4

This also means that some files like JSON now open with the JSON viewer instead of the text editor by default. This differs from the behavior of the classic notebook and could maybe be customized via the settings if needed. Opening with the default JSON viewer by default is however useful because it's coherent with the behavior in JupyterLab.

@jtpio
Copy link
MemberAuthor

cc@fcollonval if you would like to have a look.

Happy to get this in and iterate further. We can also make a new alpha release if that can ease development of third-party extensions likejupytext.

fcollonval reacted with thumbs up emoji

Copy link
Collaborator

@fcollonvalfcollonval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks a lot for this one.

@parmentelat
Copy link
Contributor

indeed@jtpio many thanks !

@jtpiojtpio mentioned this pull requestMar 21, 2022
5 tasks
@jtpio
Copy link
MemberAuthor

Thanks@fcollonval and@parmentelat!

Let's get this in then, and I'll start a new release right after.

@jtpiojtpio merged commit9be03f5 intojupyter:mainMar 21, 2022
@jtpiojtpio deleted the factories branchMarch 21, 2022 15:05
@fcollonval
Copy link
Collaborator

Maybe only theNotebook factory should open in/notebooks then?

Looking into this briefly, the trouble for jupytext are actually for file types already defined in core (like .py or .md). I was thinking to use theRouter to deal with path like/notebooks/not/a-ipynb-file.ext URL to redirect to the/edit/not/a-ipynb-file.ext?factory=Jupytext%20Notebook if the extension is supported by Jupytext. What do you think@jtpio ?

@jtpio
Copy link
MemberAuthor

Thanks@fcollonval let's track this in#6324.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

1 more reviewer

@fcollonvalfcollonvalfcollonval approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.0

Development

Successfully merging this pull request may close these issues.

3 participants

@jtpio@fcollonval@parmentelat

[8]ページ先頭

©2009-2025 Movatter.jp