Skip to content

development

Kamil Brylew edited this page Nov 13, 2026 · 7 revisions

Development Guide

Environment

Install the locked development environment:

uv sync --locked --extra dev

Generated Qt modules are intentionally untracked:

python scripts/build_ui.py

Regenerate Qt output after changing forms/*.ui or Qt resource files.

Tests and checks

Run Qt tests with an offscreen platform in headless environments:

QT_QPA_PLATFORM=offscreen uv run pytest

PowerShell:

$env:QT_QPA_PLATFORM = "offscreen"
uv run pytest

Use focused pytest, Ruff, and mypy checks for changed modules. The repository contains pre-existing global lint and strict-mypy debt; unrelated findings are not a reason to rewrite neighbouring interfaces.

Important focused DMA tests include:

  • tests/test_iio_scope_dma.py;
  • tests/test_iio_mca_dma.py;
  • tests/test_current_monitor.py;
  • tests/test_worker_lifecycle.py;
  • tests/test_hardware_widget_specs.py.

Documentation and wiki

Quarto sources live in docs/; rendered GitHub wiki pages live in the separate wiki/ checkout. Render all documentation with:

quarto render docs

Do not hand-edit generated analysis output in place. Update the corresponding .qmd, render it, inspect both repository diffs, and keep wiki navigation in Home.md and _Sidebar.md synchronized with the source set.

The offline F1 reference is authored in src/nlab/data/help/parameters.md and included by docs/context_help.qmd, so packaged help and the wiki share text. Give each topic a stable ## Title {#topic-id} heading. Bind Designer controls by scoped names or programmatic widgets by attributes in src/nlab/help/context.py; custom widgets can set the nlabHelpTopic property. Form labels follow their field’s binding. Add focused mapping and safe-input tests in tests/test_context_help.py; unknown items must retain the explicit workspace fallback rather than infer hardware behavior from a label. The page-local context_help_anchors.lua filter preserves topic IDs when GFM rendering drops custom heading identifiers, keeping related-topic links valid.

Refresh the versioned GUI screenshots after a documented widget changes:

python scripts/build_ui.py
python scripts/capture_wiki_screenshots.py

The hardware-independent capture script runs Qt offscreen and refreshes only screens that contain no measurement plot, such as the connection dialog. Live measurement images have dedicated scripts:

python scripts/capture_live_wiki_current_coincidence.py --mode current
python scripts/capture_live_wiki_current_coincidence.py \
  --mode coincidence-compare --capture-matrix
python scripts/capture_live_wiki_psd.py
python scripts/capture_live_wiki_peak_analysis.py
python scripts/capture_live_wiki_dose_calibration.py
quarto render docs

The live scripts configure and operate the reference hardware. Run them only when live validation is in scope, verify the endpoint and connected sources, and inspect their final stop/drain summaries. Never replace a live result with generated counts just to refresh a screenshot.

The MCA/PSD/analysis helpers currently default to CH0 on 192.168.10.135:30431, with the CAEN Na-22 generator setup and MCA binning 128. Override their command-line settings only for another explicitly qualified reference setup, and update the accompanying provenance text.

Driver-derived changes

Use the maintainer-supplied PetaLinux revision as the authority for registers, units, ranges, scan layouts, and lifecycle rules. Cite non-obvious behavior in comments/docstrings and distinguish:

  • derived from driver source;
  • covered by a unit test;
  • reproduced with an official libiio tool;
  • validated on live hardware.

IIO sysfs values normally have already passed through kernel encoding. Apply a scale only for explicit *_raw plus *_scale pairs when the public API needs a physical value. Compare documented range boundaries; a symmetric get/set round trip cannot detect double conversion.

Live hardware discipline

  • Begin with read-only iio_info discovery.
  • Do not perform hardware writes unless live validation is in scope.
  • Use a separate context per blocking/background activity.
  • Stop armed cores in finally and close Digitizer.
  • Test changed mappings at range boundaries, not only typical values.
  • Execute walkthrough notebooks in place and verify their final cells stop acquisition.
  • Record endpoint, firmware/IP version, channel, and independent libiio reproduction status.

DMA review checklist

  • Acquisition is stopped before buffer setup.
  • Scan geometry is driver-advertised and validated.
  • The blocking reader starts before enable.
  • Only complete frames enter files/analysis.
  • The core stops before drain/close.
  • Reader thread joins and native buffer destruction is explicit.
  • Persistent transport errors latch the session.
  • File/version distinctions between Scope, legacy NDMA v1, and IIO MCA are kept.
  • No code writes buffer-owned hardware gates directly.

Builds

The reviewed release build is:

python scripts/build_pyinstaller_reviewed.py --clean

It emits dist/nlab.exe on Windows or dist/nlab on Linux and reports the artifact hash. Nuitka remains available for optional standalone-directory builds:

python scripts/build_nuitka.py

Tagged releases trigger Windows, Ubuntu, and LMDE 7 / Debian 13 x86_64 builds through GitHub Actions. The GitHub-only build-lmde7.yaml workflow builds in the official python:3.12-trixie container, runs the offscreen tests, and uses the reviewed PyInstaller build with its frozen ROOT-conversion check. The main workflow waits for all builds before publishing the release, including nlab-lmde7-x86_64.tar.gz. The LMDE workflow can also be run manually to download an Actions artifact without publishing a release.

The container checks Debian 13 userspace; an LMDE Cinnamon desktop session and live digitizer operation still require validation on the target system.

Change completion

  • Preserve public IIO/controller behavior unless intentionally changed.
  • Add focused tests for lifecycle, file format, settings, or analysis changes.
  • Update README/wiki for user-visible behavior and the changelog for release-visible behavior.
  • Ensure generated UI, captures, reports, and build output are not staged.
  • State exactly what was tested locally, live, source-derived, or unverified.

Clone this wiki locally