How dune-daq/nanorc works
1. What this repository is
NanoRC is a Python control application for DUNE DAQ sessions. It is not a data-processing service itself; it is the orchestration layer that starts DAQ apps, drives their finite-state transitions, and coordinates configuration, run numbering, logging, and monitoring.
2. Primary entrypoints
The package exposes multiple runtime entrypoints: nanorc for normal use, nano04rc for the NP04 production environment, and nanotimingrc for timing sessions. These all share the same control core but differ in environment assumptions and defaults.
3. Control-plane core
The central architecture is a command-driven session controller built around a finite state machine. The FSM logic is in fsm.py, while core.py, cli.py, and common_commands.py wire the user-facing commands to state transitions such as boot, conf, start, stop, drain, and terminate. The session object and contextual state are managed through nano_context.py.
4. Application lifecycle and per-app state
Individual DAQ applications are modeled as nodes/stateful nodes, not just opaque processes. node.py, statefulnode.py, and appctrl.py represent the remote app and its lifecycle state, last command, liveness, and command responses. This is the layer that the status display and UI panels read from.
5. Process management boundary
NanoRC abstracts process launch behind process-manager implementations. The repo contains both SSH-based and Kubernetes-based managers (sshpm.py, k8spm.py). The SSH path starts apps on hosts via remote execution; the Kubernetes path creates pods in a namespace/session and relies on pod lifecycle and logs. This boundary is important: NanoRC controls apps, but does not own their internal runtime.
6. Configuration flow
Configuration is assembled before boot and then served to applications. cfgmgr.py, cfgsvr.py, confserver.py, and cfgsvr.py manage the configuration service side, while confdata/ contains local configuration metadata such as run number, run registry, and config-service descriptors. The README shows that boot files resolve environment variables and template tokens before launch, including app name, command factory URL, and config location.
7. Session services and run metadata
Run coordination is separated into dedicated support modules: runmgr.py handles run number and run/session bookkeeping, runinfo.py tracks run-related metadata, logbook.py integrates with logging/cataloging, and opmondash.py supports operational monitoring dashboards. This makes NanoRC the session coordinator across multiple external services rather than a single monolithic process.
8. Authentication and remote access
auth.py, credmgr.py, and rest.py indicate a boundary around authentication/credentials and REST communication. These are used to talk to remote app command endpoints and supporting services. In practice, the system relies on networked control channels, not shared-memory or in-process calls.
9. User interfaces
There are three interaction surfaces over the same control core: a terminal CLI, a terminal UI (tui.py with tui.css), and a web UI (webui.py plus webuidata/ templates/static assets). All three are front ends over the same session state and command execution path; they differ only in presentation and input method.
10. Boot/config generation and external tools
The tools/ directory contains helper utilities for configuration visualization, upload, retrieval, and operational monitoring. These are adjuncts to the main runtime, not separate services. The README also shows integration with external DUNE DAQ tooling such as fddaqconf_gen, and with external infrastructure such as /cvmfs, shared NFS, SSH hosts, Kubernetes, and the NP04 dashboard/Grafana stack.
11. Data flow at runtime
The normal flow is: load a boot/config description, resolve environment and host substitutions, launch apps via the selected process manager, wait for app responses on the configured listener, then drive FSM transitions across all apps in the session. Status and logs are then surfaced back to the user through the CLI/TUI/web UI, while the underlying apps continue to communicate over their own command and monitoring endpoints.
12. Testing and validation
The tests/ and integtests/ directories focus on command behavior, configuration handling, and Kubernetes support. The presence of integration tests for custom commands and k8s indicates that the repo’s critical seams are the process manager boundary and the command/config orchestration path, not algorithmic computation.
Main entry points: core.py Session core · cfgmgr.py Cfg mgr · nano_context.py Context · cfgsvr.py Cfg server
Components 32
Entry Points
Runtime launchers and user-facing front doors.
- nanorc · Main package entrypoint for normal session control.
src/nanorc/__main__.py - nano04rc · NP04-specific entrypoint with environment defaults.
src/nanorc/__main_np04__.py - nanotimingrc · Timing-session entrypoint variant.
src/nanorc/__main_timing__.py
Control Core
Session orchestration, commands, and finite-state control.
- Session core · Coordinates commands and session lifecycle.
src/nanorc/core.py - CLI · Command-line interface for session control.
src/nanorc/cli.py - Common cmds · Shared boot/conf/start/stop/terminate command handlers.
src/nanorc/common_commands.py - FSM · Finite-state transitions for the session.
src/nanorc/fsm.py - Context · Mutable session context and runtime state.
src/nanorc/nano_context.py
App Runtime
Per-application lifecycle and remote process boundaries.
- Node · Remote application representation and state container.
src/nanorc/node.py - Stateful node · State-tracking wrapper for app lifecycle.
src/nanorc/statefulnode.py - App control · App command execution, liveness, and responses.
src/nanorc/appctrl.py - SSH PM · Launches apps remotely over SSH.
src/nanorc/sshpm.py - K8s PM · Launches apps as Kubernetes pods.
src/nanorc/k8spm.py
Configuration
Configuration assembly and config-service integration.
- Cfg mgr · Builds and prepares configuration before boot.
src/nanorc/cfgmgr.py - Cfg server · Configuration service integration and serving.
src/nanorc/cfgsvr.py - Conf server · Configuration-server-facing logic.
src/nanorc/confserver.py - Conf data · Local run/config metadata and service descriptors.
src/nanorc/confdata/__init__.py
Session Services
Run metadata, logging, monitoring, credentials, and transport.
- Run mgr · Run numbering and session bookkeeping.
src/nanorc/runmgr.py - Run info · Run-related metadata and records.
src/nanorc/runinfo.py - Logbook · Logging and cataloging integration.
src/nanorc/logbook.py - OpMon dash · Operational monitoring dashboard integration.
src/nanorc/opmondash.py - Auth · Authentication and access handling.
src/nanorc/auth.py - Cred mgr · Credential management for remote access.
src/nanorc/credmgr.py - REST · REST communication layer for remote services.
src/nanorc/rest.py
User Interfaces
Terminal and web presentation layers over the same control core.
Tools
Auxiliary operational utilities.
- Draw conf · Configuration visualization helper.
src/nanorc/tools/drawconf.py - Get run conf · Retrieves run configuration data.
src/nanorc/tools/get_run_conf.py - Conf svc tool · Operational helper for config-service interaction.
src/nanorc/tools/nano_conf_svc.py - OpMon tool · Operational monitoring helper utility.
src/nanorc/tools/opmon.py - Upload conf · Uploads configuration artifacts.
src/nanorc/tools/upload_conf.py
Connections 33
- nanorc → Session core: starts · Main entrypoint initializes the session controller.
- nano04rc → Session core: starts · NP04 entrypoint reuses the same control core.
- nanotimingrc → Session core: starts · Timing entrypoint reuses the same control core.
- Session core → CLI: wires · Core binds command handling to the CLI.
- Session core → Common cmds: dispatches · Core routes user actions to shared commands.
- Common cmds → FSM: drives · Commands advance the session finite-state machine.
- Session core → Context: stores · Core reads and updates session context.
- Context → Run mgr: uses · Session context carries run/session bookkeeping.
- Context → Cfg mgr: uses · Context feeds configuration assembly and boot state.
- Cfg mgr → Cfg server: serves · Configuration manager connects to config-service logic.
- Cfg server → Conf server: backed by · Config service is exposed through confserver logic.
- Cfg mgr → Conf data: loads · Local config metadata informs config assembly.
- Session core → SSH PM: launches · Core selects the SSH process-manager path when needed.
- Session core → K8s PM: launches · Core selects the Kubernetes process-manager path when needed.
- SSH PM → Node: manages · SSH launcher creates and tracks app nodes.
- K8s PM → Stateful node: manages · Kubernetes launcher tracks node lifecycle state.
- Node → App control: controls · App nodes encapsulate remote command control.
- Stateful node → App control: controls · Stateful node wraps app control and responses.
- Session core → Run info: records · Session lifecycle updates run metadata.
- Session core → Logbook: logs · Core emits run/session activity to the logbook boundary.
- Session core → OpMon dash: publishes · Core exposes operational state to monitoring.
- Session core → Auth: authenticates · Core gates remote and service access through auth.
- Auth → Cred mgr: uses · Authentication relies on managed credentials.
- REST → App control: transports · REST layer carries remote app command traffic.
- TUI → Session core: fronts · Terminal UI presents the same session control path.
- Web UI → Session core: fronts · Web UI presents the same session control path.
- TUI → Node view: renders · TUI uses node rendering for status display.
- Web UI → Node view: renders · Web UI uses node rendering for status display.
- Draw conf → Cfg mgr: inspects · Tooling helps visualize configuration assembly.
- Get run conf → Run mgr: reads · Utility fetches run configuration details.
- Conf svc tool → Cfg server: talks to · Operational helper interacts with config service.
- OpMon tool → OpMon dash: talks to · Tooling supports operational monitoring integration.
- Upload conf → Cfg mgr: uploads · Utility supports configuration publication.