Skip to main content

Thumbnails of inputs

The Inputs page shows thumbnails of the inputs. Out of the box, QA-Board makes them for the image formats Pillow reads and for videos' first frames. For other formats, like raw sensor files, install a thumbnail decoder: a Python function, in a package installed with the backend, that reads your format.

Write a decoder​

It gets the input's absolute path and the size wanted, and returns a Pillow image, or None when it doesn't read that file:

my_site/thumbnails.py
from PIL import Image

def thumbnail(path, size):
if not path.endswith(".raw"):
return None # the next decoder tries
pixels = read_my_raw(path) # e.g. a numpy array, demosaiced and tone-mapped to 8 bits
return Image.fromarray(pixels) # can be bigger than size: QA-Board downscales it

Declare it with an entry point, in the qaboard.thumbnails group, in your site package or any package installed in the backend's image:

pyproject.toml
[project.entry-points."qaboard.thumbnails"]
raw = "my_site.thumbnails:thumbnail"

Restart the backend. Several decoders can be installed: they're tried in turn, then Pillow, then video frames.

How QA-Board calls it
  • Thumbnails are made once, at most 1024 pixels on their longest side: when the web app first shows them, or in the background for inputs added with qa inputs add. They're kept in the backend's data volume (QABOARD_THUMBNAILS_DIR, by default /var/qaboard/thumbnails), up to 10 GB (QABOARD_THUMBNAILS_MAX_GB), the least recently used removed first. A new version of the file, or a new decoder, makes them again. Files no decoder reads are remembered for a day.
  • Make it fast: the Inputs page asks for dozens at once. Read a downscaled version of the file if your format allows.
  • Each backend process decodes 4 thumbnails at a time (QABOARD_THUMBNAIL_DECODES); the others wait.
  • Without a writable folder (or with QABOARD_THUMBNAILS_DIR=off), thumbnails up to 256 pixels are cached in Redis for a day instead: give Redis a maxmemory with maxmemory-policy allkeys-lru. Bigger ones are made each time.
  • An exception counts as None, and is logged.
  • Only files users can read are decoded: the same check as for runs' files.

Files that come with inputs​

The input viewer lists the files that come with an input, and scripts get them (item.sidecars): by default <stem>.metadata.yaml and <stem>.yaml next to it. Add your formats' with QABOARD_INPUT_SIDECARS: patterns relative to the input's folder, by the input's suffix ("*" for all, replacing the default), with {stem} (the input's name without its suffix) and {name}:

QABOARD_INPUT_SIDECARS='{".raw": ["{stem}.imgprops", "{stem}/{stem}.cde"]}'

Set it in the backend's environment, and in your site package's defaults for qa and scripts. Prefer exact names: each costs one check, while a glob ({stem}.*) lists the folder.