disko2: Add jupyter notebook for experiments and debugging

This commit is contained in:
Felix Uhl committed 2024-11-27 23:18:58 +01:00
1 parent db57281c83
commit 59edac4aba
3 files changed
+101 -8

No files matched your search

+9 -8
View File
@@ -1,10 +1,11 @@
{
"recommendations": [
"mkhl.direnv",
"jnoortheen.nix-ide",
"ms-python.python",
"ms-python.debugpy",
"ms-python.mypy-type-checker",
"charliermarsh.ruff"
]
"recommendations": [
"mkhl.direnv",
"jnoortheen.nix-ide",
"ms-python.python",
"ms-python.debugpy",
"ms-python.mypy-type-checker",
"charliermarsh.ruff",
"ms-toolsai.jupyter"
]
}
+1
View File
@@ -99,6 +99,7 @@
(python3.withPackages (ps: [
ps.mypy # Static type checker
ps.pytest # Test runner
ps.ipykernel # Jupyter kernel for experimenting
# Actual runtime depedencies
ps.pydantic # Validation of nixos configuration
+91
View File
@@ -0,0 +1,91 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Experiments\n",
"\n",
"This notebook is very useful for debugging parts of disko without having to run\n",
"the entire CLI. You can import anything from `disko` or `disko_lib` and call\n",
"functions directly. With VSCode, you can also start a debugging session from\n",
"within a cell!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this cell to automatically reload modules on every execution.\n",
"# This avoids having to restart the kernel every time you make a change to a module.\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Examples\n",
"\n",
"These are some examples how you can use this notebook. Feel free to copy it and\n",
"create your own experiments. If you used a notebook to fix some bug, please\n",
"copy the code into a regression test and run it with pytest!"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Errors are printed above. The generated partial config is:\n",
"{\n",
" \"disko\": {\n",
" \"devices\": {\n",
" \"disk\": {\n"
]
}
],
"source": [
"from disko_lib.logging import dedent_start_lines\n",
"\n",
"lines = \"\"\"\n",
" Errors are printed above. The generated partial config is:\n",
" {\n",
" \"disko\": {\n",
" \"devices\": {\n",
" \"disk\": {\n",
"\"\"\"\n",
"\n",
"print(\"\\n\".join(dedent_start_lines(lines.splitlines()[1:])))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}