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

Create language specific Text notebooks #1157

Closed
mahendrapaipuri opened this issue Nov 10, 2023 · 5 comments · Fixed by #1163
Closed

Create language specific Text notebooks #1157

mahendrapaipuri opened this issue Nov 10, 2023 · 5 comments · Fixed by #1163
Milestone

Comments

@mahendrapaipuri
Copy link
Contributor

#1154 will add ability to create text notebooks from JupyterLab interface. However, we are making a strong assumption that these text notebooks are based on Python kernel. So, when user creates a Text notebook with Percent format, it will always create a file with .py extension.

We should be able to create text notebook for any arbitrary kernel (see comment) and so we should be able to create file with arbitrary file extensions. However, it is a bit tricky now as we choose kernel only after creating a file.

  • One solution would be to have different launcher icons for different kernels and then it will be user's responsibility to choose correct kernel. This would duplicate the launcher icons though in the launcher.
  • Another solution would be to have a input modal dialog when user clicks a text notebook launcher icon and then user chooses text notebook target kernel and based on this input we create a file with correct extension.
@mwouts
Copy link
Owner

mwouts commented Nov 12, 2023

Hi @mahendrapaipuri , seeing this screenshot in the docs:
image
made me think that maybe we could simply have a R:percent format for the people that wish to create R-percent notebooks?

Two more remarks/questions

  • Maybe we could iterate through the available kernels to determine which languages should be made available by default
  • Is it possible to use an icon that would correspond to the file extension? E.g. .py, .R or .md?

@mahendrapaipuri
Copy link
Contributor Author

Maybe we could iterate through the available kernels to determine which languages should be made available by default

If I understand you correctly, your suggestion is that we add formats programatically by iterating through available kernels. That solution is orthogonal to configuring formats via Settings, right?! I mean, the formats will be added automatically based on available kernels and those formats will not appear in the Settings. And users will not have a way to disable those automatically added formats. Does it make sense?

An option here is to add another Settings parameter like "Detect formats automatically" and we add the format icons based on available kernels if users choose this setting. This option should take precedence over configuring formats manually. And not using this setting, users will be able to add formats manually as in the screenshot in the above comment. What do you think?

Is it possible to use an icon that would correspond to the file extension?

Yes, should be possible.

made me think that maybe we could simply have a R:percent format for the people that wish to create R-percent notebooks?

Yes, this is a simpler solution. Users will have to do this only once given that their JUPYTER_CONFIG_DIR is persisted.

When are you aiming to make 1.16.0 release? It would be nice to sort this out before the release!

@parmentelat
Copy link
Contributor

Hey there
It's my understanding too that json settings and programmatically building UI contents are mutually exclusive, at least I ran into this issue when tweaking MainMenu in another context
Personally I would argue to keep it simple for a first iteration of this feature, but this is because I am way less comfortable with extensions than @mahendrapaipuri :)
In any case I cannot thank you enough:), and am very sorry to not being able to help more as I am currently afk for a couple of weeks..

@mwouts
Copy link
Owner

mwouts commented Nov 13, 2023

Hi @mahendrapaipuri , @parmentelat , thank you for your inputs!

Yes, I see what you mean! Then my preference, if that makes sense/if that's feasible, would be to keep the setting pages as is, but then programmatically replace auto: with every extension for which a kernel exists in both auto:percent and auto:light. I am a big fan of default settings that are useful to everyone (i.e. settings that you don't need to know of!)

Re the icon, that would be great! Also maybe we might need to include the language or at least the extension in the entry if we have e.g. both 'Python percent notebook' and 'R percent notebook' in the launcher.

When are you aiming to make 1.16.0 release? It would be nice to sort this out before the release!

Oh I think the test reorganization (#1136) might be ready by the end of this week, we can release any time after that, so I'd say one or two weeks. I do agree with you that it would be very nice to include the current issue in the release, and I'd be happy to give you more time if you'd like to propose something!

@mahendrapaipuri
Copy link
Contributor Author

mahendrapaipuri commented Nov 13, 2023

Yes, I see what you mean! Then my preference, if that makes sense/if that's feasible, would be to keep the setting pages as is, but then programmatically replace auto: with every extension for which a kernel exists in both auto:percent and auto:light

I can see two options here

  • Users will have to use extension (like py:light, R:light) in the format in Settings rather than auto:light. This is more clear as users know which formats they have exactly. It will be like in the screenshot but instead of auto:{light,percent}, it will be more explicit like py:{light,percent}. If user still uses auto:, we will replace it by py: by default because we know Python kernel is always there.
  • If we want to keep using auto:light and programatically create different extension files, we should use a input modal dialog. When user clicks the launcher icon, an input dialog appears (similar to the one that asks to choose kernel) and users choose which extension (py, R,...) file they would like create and then we programatically replace auto with that extension and create a file. This way one launcher icon can create several file formats. But there will be two input modals, one for choosing file extension and one for choosing kernel, which sort of disturbs the UX.

Personally, I feel the first option would be more clear for users and we can document in the Settings page that auto will be replaced by py by default. Let me know what you both think.

Re the icon, that would be great! Also maybe we might need to include the language or at least the extension in the entry if we have e.g. both 'Python percent notebook' and 'R percent notebook' in the launcher.

Agree and this should not be an issue.

I'd be happy to give you more time if you'd like to propose something!

I will give it a go this weekend. It should not be very complicated (unless I am missing something). Let's see and try to fix it before the release.

@mwouts mwouts added this to the 1.16.0 milestone Nov 23, 2023
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 a pull request may close this issue.

3 participants