Access file using Databricks API
I ended up somewhat resolving the problem using the Databricks API to download and upload notebooks and other files to/from Databricks.
1. Read documentation for Databricks Workspace API
Databricks API Documentation
2. Generate API token and Get Notebook path
In the user interface do the following to generate an API Token and copy notebook path:
- Choose 'User Settings'
- Choose 'Generate New Token'
- In Databrick file explorer, "right click" and choose "Copy File Path"
3. Download a Notebook from Databricks
If you want to access a notebook file, you can download it using a curl-call. If you are located inside a Databricks notebook, you can simply make this call either using cell magic, %sh, or using a system call, os.system('insert command').
curl --header "Content-Type: application/json" --request GET --data '{"path":"{/Users/myuser@myorg.com/notebook_to_download}","format":"JUPYTER"}' https://{replace_with_your_databaricks}/api/2.0/workspace/export -H "Authorization: Bearer {my_token}" | jq -r .content | base64 --decode > my_downloaded_notebook.ipynb
4. Uploading a Notebook to Databricks
You can similarly upload a notebook from a machine using the following curl call:
curl -n -F format=JUPYTER -F path="{/Users/myuser@myorg.com/uploaded_notebook}" -F language=PYTHON -F content=@{/my/local/notebook.ipynb} https://{replace_with_your_databaricks}/api/2.0/workspace/import -H "Authorization: Bearer {my_token}"