Launch and manage DAQ processes with slurm. 

Migrate .cnf to .py

Psbatch takes process configurations in Python format. You can convert any cnf file to .py file with cnf2py command:

cnf2py tmo_sc.cnf tmo_sc.py

Additionally, from the new configuration file in Python format, you can create one or more configuration file by inheritance. See "Inheriting configuration file" below for instructions.

Controlling DAQ processes

To start all daq processes in the configuration file, run

psbatch start tmo_sc.py

Alternatively, you can start selected processes by giving the command a list of unique IDs, for example

psbatch start tmo_sc.py timing_0,teb0,control,control_gui

For other types of control (stopping and restarting the DAQ), replace "start" subcommand with "stop" or "restart".

Viewing DAQ process status

To print out process status, run

psbatch status tmo_sc.py

Alternative, you can monitor process statuses in a separate terminal by running:

psbatch status tmo_sc.py --interactive

Subcommands and input arguments

(ps-4.6.3) monarin@drp-srcf-cmp035 tmp psbatch --help
                                                                                                                                     
 Usage: psbatch [OPTIONS] SUBCOMMAND CNF_FILE [UNIQUE_IDS]                                                                           
                                                                                                                                     
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    subcommand      TEXT          Available options: [start, stop, restart, status] [default: None] [required]                   │
│ *    cnf_file        TEXT          Configuration file with .py extension. [default: None] [required]                              │
│      unique_ids      [UNIQUE_IDS]  A comma separated string containing selected processes (e.g. timing0,teb0). [default: None]    │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --as-step        --no-as-step          Submit DAQ processes as slurm job steps. [default: no-as-step]                             │
│ --interactive    --no-interactive      Display results in a separate window for supported subcommands. [default: no-interactive]  │
│ --verbose        --no-verbose          Print out sbatch script(s) submitted by psbatch. [default: no-verbose]                     │
│ --help                                 Show this message and exit.                                                                │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Inheriting configuration file

You can use the following methods to create a new configuration file without copying text description in the original file. In the below example, we'd like to create a new tmo_sub.py which only select a few detectors, adding a new one, and rename some detectors.

Add required section

In the new file, make sure that you import the main configuration file (in this example, tmo_sc.py) and add a new helper class (Config).

tmo_sub.py
from tmo_sc import *
from psdaq.slurm.config import Config
config = Config(procmgr_config)

Select processes from the original file

You can select processes from the original file using their unique ID. These processes and their original details remain the same in the new file.

tmo_sub.py
config.select(['timing_0',
        'control',
        'control_gui',
        ])

Add new process

tmo_sub.py
config.add({host: 'drp-srcf-cmp030', id:'teb0', flags:'spu', cmd:teb_cmd})

Rename process

To rename processes (all of its details except the name remain the same), 

tmo_sub.py
config.rename(['timing_0', 'timing_1'], ['teb0', 'teb1'])

Note that the order is "current" to "new" in the list item. The above example renames timing_0 to timing_1 and teb0 to teb1. Note also that these processes must be present as part of the Config using select or add methods shown above.

  • No labels