Search code examples
pythonjupyter-notebookjupyterjupyter-lab

Creating new files with custom ContentsManager in Jupyter


I'm writing a custom ContentsManager manager for Jupyter Notebooks and gotten to creating new files.

Originally my file_exists function always returned True and I've gotten Cannot POST to files, use PUT instead error, same as this issue.

Following that I amended file_exists function to return False, however now Jupyter is stuck in the loop calling file_exists with:

/dir
/dir/Untitled.ipynb
/dir/Untitled1.ipynb
/dir/Untitled2.ipynb
...

My question is - what should I return from file_exists so that notebook creation goes along?

I though maybe get or save get called after file_exists but that doesn't seem to be the case.


Solution

  • exist - false

    exist_dir for dir - true

    exist_dir for file - false

    That's the ticket.