generated at
Jupyter Notebook
だいたい Colaboratory
環境づくりの話

Docker 実行環境
dockerhub のは更新されてない
使うのは quay.io/jupyter/scipy-notebook かなあ
datascience は Julia や R が必要なとき
scipy + tensorflow は quay.io/jupyter/tensorflow-notebook
ベース

quay.io/jupyter で su になりたい
docker exec -it -u root <container_id> bash


手元の vscode から繋いで copilot 使いたいやん
Remote Tunnel でつなぐ
cli だけスパッと入れるのはかっこいいけど arch の違い吸収させたいなら snapd 使うのが楽か...
ARCH=$(case $(uname -m) in x86_64) echo 'x64';; aarch64) echo 'arm64';; *) echo 'unsupported' && exit 1;; esac)
Remote Tunnel で繋がれる側のコンテナ、どう
interpreter path は jupyter の使う conda のもの
ロードパスは調べて追加する
python -c "import pandas; print(pandas.__file__.split('/pandas')[0])"
/opt/conda/lib/python3.11/site-packages
普通に ipynb 開いてセル実行した時に remote server 聞かれるので url 入れたら良い気がするな
手元にもモジュール入ってないと Pylance がだるいなあ、やはり devcontainer なのか...
devcontainer


VSCode 拡張のキーバインド
なんか Esc でセルから出る / Enter で入るが効かない
keybindings.json
// jupyter { "key": "escape", "command": "notebook.cell.quitEdit", "when": "inputFocus && notebookEditorFocused && !editorHasMultipleSelections && !editorHasSelection && !editorHoverVisible && !inlineChatFocused" }, { "key": "enter", "command": "notebook.cell.edit", "when": "notebookCellListFocused && notebookEditable && !editorHoverFocused && !inputFocus && !notebookOutputInputFocused" },

formatOnSave
settings.json
"notebook.formatOnSave.enabled": true, "notebook.defaultFormatter": "charliermarsh.ruff",

Ruff で notebook はゆるめる
以下みたいに書ける
pyproject.toml
[tool.ruff.lint.per-file-ignores] "__init__.py" = ["E402"] "**/{tests,docs,tools}/*" = ["E402"]

pyproject.toml
"**/*.ipynb" = ["I001", "E501"]

Terminal で見る
$ jupyter nbconvert --to=markdown --stdout notebook.ipynb