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

Store notebook title/name in metadata #91

Closed
mpacer opened this issue Mar 30, 2017 · 4 comments
Closed

Store notebook title/name in metadata #91

mpacer opened this issue Mar 30, 2017 · 4 comments

Comments

@mpacer
Copy link
Member

mpacer commented Mar 30, 2017

I'm working on a mechanism for passing a notebook along with a configuration file via a post request to an active notebook server.

In order to send everything as one big JSON blob, I've got top level fields like "config" and "notebook" which have JSON based config files and JSONified notebook. Unfortunately, if that were passed in, the notebook JSON doesn't have any notion of the name of the notebook from which it was derived.

Right now, the way that the notebook determines the name of the notebook is by examining the path of the notebook being converted. This is fine for the use case of converting a notebook via the browser with a custom configuration (since I can just get the name of the current notebook using the path as before). However, if someone wanted to pass a notebook via a post request originating from somewhere that is not the current notebook interface, there is no path(it's just a JSON blob) and therefore no name/title.

I could include a top level "name" feature as part of the API that needs to be specified, but that seems like a hacky solution rather than being able to extract the name directly from the notebook's json blob. I can even see there being a way to overwrite the name using an optional argument, but to make it required in order for the notebook to have a name at all (when in almost all cases notebooks do already have a name) seems a bit odd.

I was genuinely surprised that this wasn't already a part of the spec, so I figured I'd raise the possibility here.

I could see one problem arising if people were to edit the JSON directly and get the name out of sync with the file name. But my intuition is that in order to keep consistency with current behaviour whenever nbformat is run on a notebook with a file name (and not just a JSON blob) it would reassign the JSON name to be identical to the file name. Thus there is always a resolution method and the file system name always has priority in the case of a conflict.

@mpacer
Copy link
Member Author

mpacer commented Mar 30, 2017

It seems like #46 might be related. Do we not automatically create the document_info key and value for notebooks? It'd be nice to be able to assume that it's there.

@rgbkrk
Copy link
Member

rgbkrk commented Mar 30, 2017

Right now it's not automatically created, it was just specced out for the format.

Generally I don't think we can assume the title is there as we move from 4.x -> 4.y.

@takluyver
Copy link
Member

Very early versions of the notebook format did, but...

I could see one problem arising if people were to edit the JSON directly and get the name out of sync with the file name.

Or if they rename the file via any normal means, it won't update the name inside the file.

I think I'd give the new API an optional parameter to give a notebook name, and have a default (e.g. notebook if it's not supplied).

@rgbkrk
Copy link
Member

rgbkrk commented Jan 6, 2020

Title and author went in via #46

@rgbkrk rgbkrk closed this as completed Jan 6, 2020
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

No branches or pull requests

3 participants