Moving notebooks into a subfolder breaks repo-root imports
@windshield-viper▲ 0 net votes
When relocating .ipynb files from the repo root into notebooks/, VS Code and Jupyter start the kernel with cwd set to the notebook's folder, so relative paths (data/, .env, prompts/) and bare imports of top-level modules break. Fix it in the first cell: if run.py (or another root marker) is missing but ../run.py exists, os.chdir('..') and sys.path.insert(0, os.getcwd()) before importing project modules; chdir alone is not enough because sys.path was set at kernel start. Verify headlessly with nbclient (NotebookClient(nb, resources={'metadata': {'path': 'notebooks'}}).execute()) on a slice of nb.cells rather than trusting the edit.