Upload notebook with code, not extension

Is it possible to upload your current notebook without using the Jupyter extension, using a python command?
This is needed if you develop in, for example, in vscode.

And if so, would it be possible to upload .py files also?

You can create new notebook and upload a checkpoint to it via neptune-client.
See create_notebook and get_notebook methods in Project: https://docs.neptune.ai/neptune-client/docs/project.html#neptune.projects.Project.create_notebook

You can also upload any file to experiment’s artifacts via log_artifact method. See https://docs.neptune.ai/neptune-client/docs/experiment.html#neptune.experiments.Experiment.log_artifact


The create_notebook() works, but it is not uploaded/added to neptune until I do a add_checkpoint(‘filename.ipynb’).

If I do a notebook.get_name() after the create (w/o a add_checkpoint), JupyterLab gives an NotebookNotFound error, but it does show an ID in the error message.

If I then do a add_checkpoint and a get_name on the notebook, it returns an empty string.
From the neptune UI I can see the notebook is named with the full path (except the .ipynb extension) instead of only the filename.
Is it possible to give a name for a create_notebook and not the full path?

In the Notebook API add_checkpoint(), in the example it states:
notebook = project.create_notebook('file.ipynb')
But I guess this is a leftover from earlier code, as it doesn’t work.

You are right. Documentation is not up-to-date here. This API is not used very commonly.

Notebook’s name is always filename (without path) of the last checkpoint and you cannot change it until you upload a new checkpoint. This is the name you can see in UI. It’s done this way to be consistent with what you see in Jupyter Notebook UI.

However notebook.get_name() returns something different, which is a bug on our side. It returns a name of the last checkpoint which is not a filename. You can rename every checkpoint via UI.

Thank you for bringing this issue to my attention.

What exactly do you want to achieve?

When I use add_checkpoint(‘untitled.ipynb’), the notebook name that appears in the neptune UI, is ‘c:\folder1\folder2\untitled’, instead of just ‘untitled’.
When using the jupyterlab extension, it is correct with only the filename.

I would like to be able to upload notebooks, when I am not developing in JupyterLab (for example in VS Code). And i would like to have the same functionality as the JL extension (like setting project, name, description…).

I also noticed that using the add_checkpoint(), it uploads the currently saved notebook, while the JL extension seem to save first before uploading the notebook. So you have to manually save before every add_checkpoint().

Hey @debbes,

Thanks for all the feedback. It’s super-accurate and super-useful for us!

Indeed, right now preferred way of working with notebooks is via the Extension, hence user experience is better in JL with Neptune extension.

I will let the engineering team know about your ideas.