Google Dataproc Jupyter notebook thinks its in root

Viewed 174

All notebooks on the Google Dataproc return the root, /, when running !pwd or os.getcwd(). They are actually located in deeper locations on the filesystem, ex: /jupyter/users. This problem seems to be specific to the Google Dataproc. Any ideas to get the location?

I've tried changing the command that starts the jupyter server but then the notebooks just think that path is where they are located.

/opt/conda/miniconda3/bin/jupyter notebook /root/ &> /var/log/jupyter_notebook.log

Now all files think they are located in /root/

Untitled notebook is not located at root

1 Answers

Adding these in /etc/jupyter/jupyter_notebook_config.py solved the issue for me:

c.NotebookApp.contents_manager_class = 'notebook.services.contents.filemanager.FileContentsManager'
c.NotebookApp.notebook_dir = '/jupyter/notebooks'
c.FileContentsManager.root_dir = '/jupyter/notebooks'

Works when your notebook files are served from /jupyter/notebooks

Related