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

Edit notebook metadata #6402

Closed
jtpio opened this issue Nov 3, 2021 · 24 comments · Fixed by #7099
Closed

Edit notebook metadata #6402

jtpio opened this issue Nov 3, 2021 · 24 comments · Fixed by #7099

Comments

@jtpio
Copy link
Member

jtpio commented Nov 3, 2021

Problem

In the classic notebook it's possible to edit the notebook metadata:

image

image

Proposed Solution

We add a new plugin to replicate that UX and let users edit notebook metadata in a dialog.

Additional context

In JupyterLab the notebook tools is in the right area:

image

@jtpio
Copy link
Member Author

jtpio commented Nov 3, 2021

Marking as a good first issue in case someone would like to take it, thanks!

@jtpio
Copy link
Member Author

jtpio commented Nov 3, 2021

The new plugin could go the notebook-extension package: https://github.com/jupyterlab/retrolab/blob/main/packages/notebook-extension/src/index.ts

That file already has some places showing how to retrieve the current notebook. which can serve as an example.

@jtpio jtpio transferred this issue from jupyterlab/retrolab Apr 27, 2022
@jtpio jtpio added this to the 7.0 milestone Apr 27, 2022
@jaivanti
Copy link

Hi! Can I try this one?

@kostyafarber
Copy link
Contributor

Just checking if anybody is still working on this

@jtpio
Copy link
Member Author

jtpio commented Nov 21, 2022

@kostyafarber I don't think anyone is still working on this so if you want to have a look that would be great, thanks!

In the meantime there has been some work on adding support for (hidden by default) left and right panels:

image

The notebook metadata can be edited there, but there could also be the popup like the classic notebook so it's easier to find.

@ShobhanSrivastava
Copy link

Hey @jtpio I would like to try and solve this issue, can you please assign it to me?

@jtpio
Copy link
Member Author

jtpio commented Dec 22, 2022

Thanks @ShobhanSrivastava.

I guess it could still make sense to implement the dialog to edit the notebook metadata to keep the same UX as with the classic notebook.

cc @brichet in case you have an input on this, since this might also be related to some upstream work in JupyterLab.

@brichet
Copy link
Contributor

brichet commented Jan 2, 2023

I think we should use the existing MetadataEditor from Notebooktools. It could be extended into a new object that is displayed in a Dialog.

For example, I started to extend the MetadataEditor for an unrelated purpose in JupyterLab here.

@jtpio
Copy link
Member Author

jtpio commented Jun 9, 2023

Maybe the simplest way for now would be to add a Edit Notebook Metadata command to the menu that would open the Notebook tools panel instead of a dialog.

@andrii-i andrii-i modified the milestones: 7.0, 7.0.x Jun 13, 2023
@LornaJoyce
Copy link

test

@abidkhan484
Copy link

Hi @jtpio I would like to try and solve the issue if it still persists.

@jtpio
Copy link
Member Author

jtpio commented Aug 29, 2023

Sure thanks @abidkhan484.

Feel free to open a Pr any time. Probably the suggestion from #6402 (comment) would be enough for now.

@abidkhan484
Copy link

Hi @jtpio I am new in open source contribution. I have read the contributing.md file.
Can you please guide me regarding these?

  1. What is the Git branch strategy that I should follow? From which branch I should create a new one?
  2. Is there any guidance on which part I may update? If I am not wrong, it's maybe on the front end (UI).
  3. Is there any other suggestion for me as a newcomer?

@jtpio
Copy link
Member Author

jtpio commented Aug 31, 2023

What is the Git branch strategy that I should follow? From which branch I should create a new one?

You would first need to fork the repository on GitHub:

image

Then you can create a new branch on your fork. Once ready, you can open a PR against the main branch of the jupyter/notebook repo.

Is there any guidance on which part I may update? If I am not wrong, it's maybe on the front end (UI).

Yes, it should be a frontend only change. If we stick to just adding the menu entry as suggested above, then it mostly means adding a new setting file here to add the entry to the menu: https://github.com/jupyter/notebook/tree/main/packages/notebook-extension/schema

Is there any other suggestion for me as a newcomer?

If you would like to, you could also use Gitpod as an alternative to setting up a development environment locally.

@Dilip-Jain
Copy link
Contributor

Hi,
It looks like the issue is still not resolved and I guess no one is working on it. I'd like to take this up and close it asap, only a month before it turns two! So, maybe, you can assign this to me.
Progress so far: I cloned the repo, only to realize the frontend code is no more within the notebook and shifted under jupyterlab. I understood I have to work on the frontend, specifically add an option under the Edit menu which on clicking will trigger same functionality as Right Sidebar option in View (probably, along with uncollapsing the Application tools too). Well, honestly, I am having a hard time understanding the code (jupyterlab, especially the structure). I started with project-wide searching 'Clear Outputs of All Cells' (just another option under Edit menu), to quickly understand the call-stack and it didn't help much. Maybe, you can help me out for it to get quicker, or else, I'll spend some time, sit focused, and try.

@jtpio
Copy link
Member Author

jtpio commented Oct 2, 2023

Thanks @Dilip-Jain for looking into this 👍

You can see the Notebook 7 application as a JupyterLab remix. This means the frontend reuses many JupyterLab plugins and extensions, and reassemble them in a different way to create this document-oriented notebook UI.

So most of the commands are inherited from JupyterLab. You can do a text search on the JupyterLab repo to find some hints: https://github.com/jupyterlab/jupyterlab. The documentation also lists the available in JupyterLab: https://jupyterlab.readthedocs.io/en/latest/user/commands.html#commands-list. Although in the case of Notebook 7 only a subset of the commands are available.

One way to start on this issue would be to have a look at how existing commands can be added as menu items to the Notebook 7 interface. For example the application extension uses the settings system to re-order the menu entries:

"jupyter.lab.menus": {
"main": [
{
"id": "jp-mainmenu-file",
"items": [
{
"command": "application:rename",
"rank": 4.5
},
{
"command": "notebook:trust",
"rank": 20
},
{
"type": "separator",
"rank": 30
},
{
"command": "filemenu:close-and-cleanup",
"rank": 40
},
{
"command": "application:close",
"disabled": true
}
]
},
{
"id": "jp-mainmenu-view",
"items": [
{
"type": "submenu",
"disabled": true,
"submenu": {
"id": "jp-mainmenu-view-appearance"
}
}
]
},
{
"id": "jp-mainmenu-run",
"items": [
{
"type": "separator",
"rank": 1000
},
{
"type": "submenu",
"rank": 1010,
"submenu": {
"id": "jp-runmenu-change-cell-type",
"label": "Cell Type",
"items": [
{
"command": "notebook:change-cell-to-code",
"rank": 0
},
{
"command": "notebook:change-cell-to-markdown",
"rank": 0
},
{
"command": "notebook:change-cell-to-raw",
"rank": 0
}
]
}
}
]
}
]
},

@jtpio
Copy link
Member Author

jtpio commented Oct 2, 2023

As a side note it would indeed be useful to expand the existing contributing guide to explain how Notebook 7 reuses JupyterLab plugins and extensions: https://jupyter-notebook.readthedocs.io/en/latest/contributing.html

@joaovml
Copy link

joaovml commented Oct 8, 2023

Hello everyone, I'm working on this issue on and off for a while for a college class. I've managed to change some stuff around in the menus.json file and thought I was almost done, just needed to add an option with a command to show the Notebook Tools panel as suggested. The thing is, when I run ctrl+shift+c and the command palette pops us, there's the "Show Notebook Tools" command easily, but I cannot find it in the commands page. Can I have any guidance? Thanks

Dilip-Jain added a commit to Dilip-Jain/notebook that referenced this issue Oct 9, 2023
Edit Notebook Metadata plugin added under Edit Menu for functionality similar to classic-notebook.
Clicking on the option under the menu opens up the Notebook Tools widget in the right sidebar and expands the Additional Tools (which contains the Notebook Metadata editor) collapsible section (default: collapsed).
@Dilip-Jain
Copy link
Contributor

Hi @joaovml, what you are looking for is an application command application:toggle-right-area with arguments, particularly, side (right), title (Show Notebook Tools), and id (notebook-tools) passed as args.

Unfortunately, I didn't know you were working on the issue, and since the issue was inactive for quite a long duration, I picked it up last week and started working on it. I just created a pull request and realized you too were working on this.

Dilip-Jain added a commit to Dilip-Jain/notebook that referenced this issue Oct 9, 2023
@joaovml
Copy link

joaovml commented Oct 10, 2023

Hi @Dilip-Jain ! No problem, I hadn't mentioned anything here. Your solution will be great in helping me understand a bit better how the code works and hopefully I'll be able to contribute somewhere else.

@Dilip-Jain
Copy link
Contributor

Good luck @joaovml

@Dilip-Jain
Copy link
Contributor

Hey @jtpio,
if you can please check the pull request I made to close this issue.
Although, it is missing some "prettiness" and failing some other test cases, it totally works as expected. Help!

@stevearmstrong-dev
Copy link

Hi is there anyone still working on this?
Would like to delve into this

@Dilip-Jain
Copy link
Contributor

Hey @W0474997SteveArmstrong, I have already created a pull request for this enhancement. The only task left is adding the menu entry via the settings defined in the schema folder dropping the dependency on IMainMenu in the plugin.
Not sure why, but I am unable to achieve this shift. I'll try, you can too, and feel free to push to my fork.

jtpio added a commit that referenced this issue Feb 7, 2024
* Added Edit Notebook Metadata Option (#6402)

Edit Notebook Metadata plugin added under Edit Menu for functionality similar to classic-notebook.
Clicking on the option under the menu opens up the Notebook Tools widget in the right sidebar and expands the Additional Tools (which contains the Notebook Metadata editor) collapsible section (default: collapsed).

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added Edit Notebook Metadata Option (#6402)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Prettier Code for passing Test Lint check

* Prettier Code for passing Test Lint check

* adding the edit-notebook-metadata entry via schema

adding the menu entry via the settings defined in the schema folder dropping the dependency on IMainMenu in the plugin

* adding the edit-notebook-metadata entry via schema

adding the menu entry via the settings defined in the schema folder dropping the dependency on IMainMenu in the plugin

* adding the edit-notebook-metadata entry via schema

* adding the edit-notebook-metadata entry via schema

* adding the edit-notebook-metadata entry via schema

* fix menu item

* Add to the command palette

* Update Playwright Snapshots

* Update Playwright Snapshots

* fix snapshots

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Tuloup <jeremy.tuloup@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.