From a31134798819601a740460c0ed0c19c453269fb8 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 17 Aug 2026 13:06:06 +0200 Subject: [PATCH 1/2] Downgrade ruff for now --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7259e5159f6..f7fa1e299ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.16.3 + rev: v0.16.2 hooks: - id: ruff-check types_or: [python, pyi, jupyter, toml] From 52f5f189e63bd45825a8d0b5a7e6566daad603e9 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 17 Aug 2026 13:23:16 +0200 Subject: [PATCH 2/2] Fix flaky snapshot documentation comparison Recapture the station snapshot immediately before the measurement run and raise a descriptive error containing a unified diff when snapshots differ. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../DataSet/Working with snapshots.ipynb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/examples/DataSet/Working with snapshots.ipynb b/docs/examples/DataSet/Working with snapshots.ipynb index 01ee99d42e3..49d42c62d4e 100644 --- a/docs/examples/DataSet/Working with snapshots.ipynb +++ b/docs/examples/DataSet/Working with snapshots.ipynb @@ -28,8 +28,9 @@ "outputs": [], "source": [ "import json # for converting JSON data into python 'dict'\n", + "from difflib import unified_diff\n", "from pathlib import Path\n", - "from pprint import pprint # for pretty-printing python variables like 'dict'\n", + "from pprint import pformat, pprint # for pretty-printing python variables like 'dict'\n", "\n", "from qcodes.dataset import (\n", " Measurement,\n", @@ -554,6 +555,8 @@ "metadata": {}, "outputs": [], "source": [ + "snapshot_of_station_before_run = station.snapshot()\n", + "\n", "with measurement.run() as data_saver:\n", " input_value = 111\n", " instr.input.set(input_value)\n", @@ -793,7 +796,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Note that the snapshot that we have just loaded from the dataset is almost the same as the snapshot that we directly obtained from the station above. One difference is that the snapshot loaded from the dataset has a top-level `station` field. It also has a top-level `parameters` field. If you do not trust me, have a look at the following `assert` statement for the proof." + "Note that the snapshot that we have just loaded from the dataset is almost the same as the snapshot that we directly obtained from the station immediately before the run. One difference is that the snapshot loaded from the dataset has a top-level `station` field. It also has a top-level `parameters` field. The following comparison raises an error with a unified diff if the station snapshots do not match." ] }, { @@ -802,7 +805,17 @@ "metadata": {}, "outputs": [], "source": [ - "assert snapshot_of_station == snapshot_of_run[\"station\"]" + "if snapshot_of_station_before_run != snapshot_of_run[\"station\"]:\n", + " snapshot_diff = \"\\n\".join(\n", + " unified_diff(\n", + " pformat(snapshot_of_station_before_run).splitlines(),\n", + " pformat(snapshot_of_run[\"station\"]).splitlines(),\n", + " fromfile=\"snapshot_of_station_before_run\",\n", + " tofile='snapshot_of_run[\"station\"]',\n", + " lineterm=\"\",\n", + " )\n", + " )\n", + " raise RuntimeError(f\"Station snapshots differ:\\n{snapshot_diff}\")" ] }, {