diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c568ac0..5853a6d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -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" + ] } \ No newline at end of file diff --git a/flake.nix b/flake.nix index 8893727..a45317c 100644 --- a/flake.nix +++ b/flake.nix @@ -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 diff --git a/src/experiments.ipynb b/src/experiments.ipynb new file mode 100644 index 0000000..0a93830 --- /dev/null +++ b/src/experiments.ipynb @@ -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 +}