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

Support opening Jupytext notebooks as notebooks #63

Open
yjoer opened this issue Oct 8, 2024 · 2 comments
Open

Support opening Jupytext notebooks as notebooks #63

yjoer opened this issue Oct 8, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@yjoer
Copy link
Contributor

yjoer commented Oct 8, 2024

Is your feature request related to a problem? Please describe.

The current extension does not differentiate Python source files and Jupytext notebooks as they share the same .py extension. Therefore, it will open all files ending with .py in a text editor.

Describe the solution you'd like

Open Jupytext notebooks as notebooks.

Describe alternatives you've considered

I created a POC at https://github.com/yjoer/jupyterlab-quickopen/tree/poc-1. When we hit enter after selecting a path, the client sends a request to the server if it ends with .py. On the server, we will read the first line of the file to identify the file type. I have implemented the tests for the percent format with and without metadata. If it matches, the handler will return "notebook" as the widget name otherwise "default". This allows us to open a conventional Python file in a text editor.

2024-10-09_01-30-46.mp4

Additional context

N/A

@yjoer yjoer added the enhancement New feature or request label Oct 8, 2024
@jtpio
Copy link
Member

jtpio commented Oct 9, 2024

Thanks @yjoer for opening the issue 👍

I haven't looked too much into it yet, but maybe there is something to be done on the client side only, that would involve checking the preferred factory for a document before opening it here:

docManager.openOrReveal(PathExt.normalize(path));

@yjoer
Copy link
Contributor Author

yjoer commented Oct 9, 2024

The challenge is that the path alone does not help identify the appropriate widget. It could be opened in the text editor or notebook before looking at the content. I believe DocumentManager does not know the content given a path. Do we have some other ways to peek at the files?

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

No branches or pull requests

2 participants