Skip to content

Session file

Every key a session file can hold. How to write a session file shows how to write one, split it over several files and read a failure.

The file is YAML. Its schema is published as session-file.schema.json.

Top-level keys

Every key is optional.

Key Type Default Holds
schema_version number 1.0 the format of the file; 1.0 is the only one
session text the name of the session class the name of the session
frontend qt the frontend of the session class the registered frontend to build on
strict true or false false whether a component that fails to build or to set up stops the session
mock true or false false whether devices connect to simulated backends, and no service is launched
metadata mapping empty anything to record with the session
services mapping empty the services devices talk to
devices mapping empty the devices, by name
presenters mapping empty the presenters, by name
views mapping empty the views, by name
stacks mapping empty the stacks, each a presenter with its views, by name
layout mapping the layout of the session class where the views start in the window
shortcuts mapping empty keys replacing what the components declare
providers mapping empty classes that share values with the components, by name
compute mapping or preset the defaults below the cores background calls may use
storage mapping the defaults below where files go, and the catalog
wiring mapping empty which signal reaches which slot
pairs list empty components linked to each other, two names each
hooks mapping empty the hook providers, by hook point
actions none menu commands of a Qt session; see Add menu actions
color_scheme system, light or dark system the colour scheme a Qt session starts with

A file given to Session.from_config must set session.

schema_version: 1.0
session: my-lab
frontend: qt
strict: false
mock: false
metadata:
  user: Ada
  setup: iSCAT
color_scheme: dark

Components

devices, presenters and views map the name of each component to its entry.

Key Type Default Holds
plugin_name text none the plugin whose manifest lists the class
plugin_id text none the id of the class in that manifest
service text none devices only: the service whose prefix the device gets
autoconnect true or false true devices only: whether the build connects the device
placement text or mapping the view's own views only: where the view goes in the window, as a word or mapping the frontend reads; see Override a view's default placement
title text the view's own, or its name views only: the text the window shows for the view; see Give a view a title
workers whole number, 1 or more the compute section's presenters and views asking for a ProcessExecutor: the worker processes of the component's process pool. A class that takes workers itself, by name or through **kwargs, and asks for no ProcessExecutor gets it as an argument, as a device does; one with a workers parameter that asks for a ProcessExecutor is refused
any other key an argument of the constructor

An entry for a component the session class declares leaves out plugin_name and plugin_id.

presenters:
  motor_ctrl:
    plugin_name: my-plugin
    plugin_id: motor
    step: 2.0

Stacks

stacks maps the name of each stack to its entry. The session builds the stack's presenter under that name and each view as <name>_<role>, and pairs the presenter with each view.

Key Type Default Holds
plugin_name text none the plugin whose manifest lists the stack
plugin_id text none the id of the stack in that manifest
a role, such as presenter or view mapping empty the keys of that half's entry, as under Components

A key that names no role of the stack is refused, and so is a half's name that another component already has. A half's keys replace those the stack class gives it, and a session class's Declare replaces both. An entry for a stack the session class declares leaves out plugin_name and plugin_id. A later file naming the same stack replaces its entry whole. A stack whose plugin can't be found counts as a component that failed to build, and so do the halves its entry names.

stacks:
  positioner:
    plugin_name: redsun
    plugin_id: positioner
    view:
      repeat_interval: 50

Services

services maps the name of each service to its entry, and holds one key of its own, transport.

Key Type Default Holds
transport channel-access, pv-access or sharedbox channel-access the way every service of the session talks to its devices

An entry:

Key Type Default Holds
plugin_name text none the plugin whose manifest lists the service
plugin_id text none the id of the service in that manifest
prefix text none the prefix given to each device naming the service
module text none the module to run; an entry without one is attached to
args list of text, or mapping empty the arguments after the module; a mapping gives --key value per option
ready text none the line the service prints once it serves
startup_timeout number 15.0 seconds the session waits for the ready line
stop_timeout number 10.0 seconds each step of stopping waits
address text none where an attached service answers, added to the address list of the transport

A mapping under args becomes arguments this way:

Value Arguments
text or number --key value
true --key
false or null none
list --key followed by each item
services:
  transport: pv-access
  camera_ioc:
    plugin_name: mylab
    plugin_id: camera-ioc
    prefix: "CAM:"
    args:
      exposure: 0.1
      simulate: true
  beamline:
    prefix: "BL01:"
    address: 10.0.0.5

Compute

compute is a mapping, or one preset word standing for {preset: <word>}. A session class may declare the same keys in its compute attribute; the file wins over the class, key by key.

Key Type Default Holds
preset latency, balanced or throughput balanced how the compute cores are split between threads and native libraries
cores whole number, 1 or more the physical cores less reserve the most compute cores to use
reserve whole number, 0 or more 1 physical cores kept free for the window's thread
switch_interval_ms number above 0 none the interpreter's thread switch interval, in milliseconds; absent, it is left alone
processes whole number, 1 or more the compute cores shared between the process pools, at least 1 and on Windows at most 61 each the worker processes of each component's process pool
priority low, normal or high normal the priority of every worker process; high needs root or CAP_SYS_NICE on Linux and macOS

reserve lowers the compute cores by its count; the session pins no thread to a core. A preset splits the compute cores C between the threads of the pool and the threads each call's native libraries may start:

Preset Pool threads Native threads per call
latency 1 C
balanced max(2, C // 4) C // pool threads, at least 1
throughput C 1

The preset sizes the thread pool only. Each component asking for a ProcessExecutor gets a process pool of its own, whose worker processes run their native libraries on one thread; a component's workers key wins over processes. Windows runs at most 61 worker processes in one pool, so there a larger workers or processes gets 61 and the build logs a warning.

compute:
  preset: latency
  cores: 6

The section changes nothing in a session whose components ask for no executor.

Storage

Key Type Default Holds
base_dir path the user data folder the root the session writes under
max_digits whole number 5 the width of the counter in file names
catalog mapping none the catalog of runs; absent, the session keeps none
catalog.readable list of paths empty folders the catalog may read besides those of the session
storage:
  base_dir: "D:/experiments/2026-09"
  max_digits: 5
  catalog:
    readable: [/data/camera]

Wiring

wiring maps a signal to a slot, or to a list of slots. Both are written component.port.

wiring:
  motor_ctrl.sig_moved: motor_widget.refresh

Pairs

pairs lists two components by name. Each signal of one reaches each slot of the other that names it in its signal, both ways. A pairing that connects nothing is refused, and one naming a component that failed to build is skipped with a warning.

pairs:
  - [motor_ctrl, motor_widget]

Layout

layout sets where the views start in the window. It replaces the layout the session class returns from window_layout(), and a later file's layout replaces an earlier one whole.

layout:
  regions:
    center: {tabs: [image, plot]}
    left: {tabs: [stage, lights], current: stage}
    right: {column: [plans, {tabs: [progress, files]}], sizes: [1, 2]}
    bottom: log
  sizes: {left: 0.2, right: 0.3, bottom: 0.15}
  hidden: [log]
Key Type Default Holds
regions mapping empty what fills each region of the window; the Qt frontend has center, left, right, top and bottom
sizes mapping empty the share of the window each region takes, between 0 and 1: of its width for left and right, of its height for top and bottom
hidden list empty the views that start hidden

A region holds a view's name, or one of these mappings:

Key Type Default Holds
row list required views side by side, left to right
column list required views stacked, top to bottom
sizes list equal shares with row or column: one positive weight per child
tabs list required the names of views sharing one space as tabs
current text the first tab with tabs: the view shown on top

A view the layout leaves out goes where its placement asks. A name no view answers to is logged and left out, and refused when strict is set.

Shortcuts

shortcuts gives commands other keys than the components declare. A command is named <component>.<method>, after the component's name in the session and the method its shortcut runs.

shortcuts:
  acquisition_view.run_plan: Ctrl+Shift+R
  acquisition_view.stop_plan: [Ctrl+., Escape]
  positioner_view.step_down: null
Key Type Default Holds
<component>.<method> text, a list of two, or null the component's key the key, two keys, or null for none

A key is written as the frontend reads it; for Qt, Ctrl is the Command key on macOS. A key two commands ask for in the same place stays with the first, and the change is logged, or refused when strict is set.

Hooks

hooks maps a hook point to an entry, or to a list of entries at a point that takes several providers. An entry is a mapping with the keys below, or the short name of a provider redsun ships, written alone. Hook points says which points take several, and in what order they run.

Key Type Default Holds
provider text required the class of the provider, as module:ClassName, or the short name of a provider redsun ships
kwargs mapping empty the arguments the provider is made with

The providers redsun ships, by short name:

Name Hook point Provider
napari configure_application NapariStyle, napari's look, dark or light as the colour scheme reads
qlementine configure_application QlementineStyle, qlementine's look, dark or light as the colour scheme reads; needs the qlementine-pyqt or qlementine-pyside extra
hooks:
  configure_application: napari