Member-only story

Notebooks as files

Hubert Dudek
2 min read3 days ago

--

Access for free via a friend’s link

Starting with Databricks Runtime 16.2, notebooks are treated like regular files and the workspace is a regular folder. You can open, move, or modify them like any other file. For developers, this means:

Programmatic Notebook Creation: Use Python’s file I/O to create new notebooks.
Logging to Local Files: Save logs right next to your notebooks.
Git Integration: remember about .gitignore to avoid the mess which you will make this way
Drag and Drop: Easily move notebooks in the workspace by dragging them around or doing any file operations you can imagine.

Below is a concise example that demonstrates:
- Creating a folder and placeholder notebook file programmatically.
- Setting up logging to a file.
- Generating a .gitignore to ignore logs and temp files.

# Step 1: Create /temp directory and a placeholder notebook file
import os

os.makedirs("temp", exist_ok=True)
placeholder_path = os.path.join("temp", "placeholder_notebook.py")
with open(placeholder_path, "w") as f:
f.write("# Placeholder notebook content\n")
f.write("print('Hello from the placeholder notebook!')\n")
print(f"Created notebook: {placeholder_path}")

# Step 2: Configure Logging and Write a Test Message
import logging

os.makedirs("logs", exist_ok=True)
log_path = os.path.join("logs", "app.log")

logger = logging.getLogger("my_logger")…

--

--

No responses yet