There are four tasks handled by the Post Processing Agent:
- Catalog raw data
- Reduce data
- Catalog reduced data
- Create reduction script
The four tasks each correspond to one ActiveMQ message broker queue that the Post Processing Agent subscribes to.
The user can configure the active post processors using the parameter "processors". The Post
Processing Agent subscribes to the queues for the registered post processors. The queue names are hard coded
in their respective post processor classes.
| Configuration parameter | Description | Default value |
|---|---|---|
"processors" |
List of post-processors to register | ["oncat_processor.ONCatProcessor", "oncat_reduced_processor.ONCatProcessor", "create_reduction_script_processor.CreateReductionScriptProcessor", "reduction_processor.ReductionProcessor"] |
The Post Processing Agent is an ActiveMQ client, which is started by running
python <installation folder>/queueProcessor.py
Upon startup, the Post Processing Agent creates a connection to the ActiveMQ message broker and subscribes to the required queues, as described in Tasks and queues.
| Configuration parameter | Description | Default value |
|---|---|---|
"brokers" |
List of tuples containing host name and port of ActiveMQ broker(s), for example: [("localhost", 61613)] |
|
"amq_user" |
Message broker username | |
"amq_pwd" |
Message broker password | |
"log_file" |
Path to the log file | post_processing.log |
"heart_beat" |
Topic the agent will send heartbeats to | /topic/SNS.COMMON.STATUS.AUTOREDUCE.0 |
"heartbeat_ping" |
Topic the agent will subscribe to for ping requests | /topic/SNS.COMMON.STATUS.PING |
"consumer_protocol" |
How the agent reads its queues: "stomp" or "amqp" (see Reading queues over AMQP) |
"stomp" |
"amqp_brokers" |
Host name and port of the broker(s) on the AMQP port, used when "consumer_protocol" is "amqp" |
port 5672 on each of "brokers" |
Over STOMP the broker always hands each subscription one message ahead, so a node busy with a long
reduction can sit on runs that an idle node could start. With "consumer_protocol": "amqp" the agent
holds no messages at all: when it's free it asks the next queue in turn for one message and runs it.
Heartbeats, pings and per-instrument queue discovery work the same way. Pings are also answered
while a job is running.
Only reading changes. PostProcessAdmin still sends its status messages over STOMP, and the
workflow manager doesn't need any changes. In this mode the agent runs one job at a time, which is
what the STOMP agent does in practice, so "max_procs" and "jobs_per_instrument" don't apply.
The workflow manager can route each instrument's runs to its own queue, so a flood of runs from one instrument doesn't hold up the others. Four queues are split this way:
| Shared queue | Per-instrument queue |
|---|---|
REDUCTION.DATA_READY |
REDUCTION.<INSTRUMENT>.DATA_READY |
REDUCTION.HIMEM.DATA_READY |
REDUCTION.HIMEM.<INSTRUMENT>.DATA_READY |
REDUCTION.EXPRESS.DATA_READY |
REDUCTION.EXPRESS.<INSTRUMENT>.DATA_READY |
REDUCTION_CATALOG.DATA_READY |
REDUCTION_CATALOG.<INSTRUMENT>.DATA_READY |
With "per_instrument_queues" on, the agent checks the broker's management API (Jolokia) on an
interval and subscribes to each per-instrument queue for the processors it runs, so new instruments
are picked up without a restart. Messages are passed to PostProcessAdmin with the shared queue name,
so they go to the same processor. The shared queues stay subscribed either way.
We use one subscription per queue with prefetching limited to one message per subscription, which
makes the broker take turns between the queues. A wildcard subscription like REDUCTION.*.DATA_READY doesn't work: it merges everything back
into one queue in arrival order and leaves a copy of every message in the per-instrument queue.
If the broker can't be reached, the agent logs the error and keeps its current subscriptions.
| Configuration parameter | Description | Default value |
|---|---|---|
"per_instrument_queues" |
Discover and subscribe to per-instrument queues | false |
"queue_discovery_interval_sec" |
Seconds between two queue discoveries | 60 |
"jolokia_urls" |
Jolokia URLs of the brokers, tried in order | http://<broker host>:8161/console/jolokia for each of "brokers" |
"jolokia_user" |
User with a management role on the broker | "amq_user" |
"jolokia_pwd" |
Password of "jolokia_user" |
"amq_pwd" |
When a message is published to on one of the queues:
Consumerchecks how many subprocesses are running for that instrument and either accepts or rejects the message.- If the message is accepted,
Consumerstarts a subprocess that runs the scriptPostProcessAdmin.py
| Configuration parameter | Description | Default value |
|---|---|---|
"jobs_per_instrument" |
If > 0, the maximum number of concurrent jobs per instrument | 2 |
"python_dir" |
Path to PostProcessorAdmin.py |
|
"start_script" |
Script runner | python |
"task_script" |
Script to pass the message payload to | PostProcessorAdmin.py |
"task_script_queue_arg" |
Flag passed to the task script before the message queue name | -q |
"task_script_data_arg" |
Flag passed to the task script before the message payload | -d |
"max_procs" |
Maximum number of concurrent processes | 5 |
"postprocess_error" |
If consuming the message fails (exception is raised), the message will be forwarded to this error topic | POSTPROCESS.ERROR |
The class PostProcessorAdmin routes the consumed message based on the queue name. See Tasks and queues.
| Configuration parameter | Description | Default value |
|---|---|---|
"brokers" |
List of tuples containing host name and port of ActiveMQ broker(s), for example: [("localhost", 61613)] |
|
"amq_user" |
Message broker username | |
"amq_pwd" |
Message broker password | |
"exceptions" |
List of exceptions (exception messages) that are not treated as errors |
This section describes the four tasks handled by the post processing agent: reduce data, create reduction script, catalog raw data and catalog reduced data.
The same reduction can be read from three queues, each with its own processor class, so that separate agents can serve them:
| Processor | Queue | Purpose |
|---|---|---|
reduction_processor.ReductionProcessor |
REDUCTION.DATA_READY |
Regular reduction |
reduction_processor.ReductionProcessorHighMemory |
REDUCTION.HIMEM.DATA_READY |
Reduction on a node with more memory |
reduction_processor.ReductionProcessorExpress |
REDUCTION.EXPRESS.DATA_READY |
Fast lane for instruments that temporarily need priority, served by a dedicated agent |
The workflow manager decides which queue a run goes to. An agent that should serve only one of
them lists only that processor in "processors".
| Configuration parameter | Description | Default value |
|---|---|---|
"reduction_started" |
Topic for status message | |
"reduction_complete" |
Topic for status message | |
"reduction_error" |
Topic for status message | |
"reduction_disabled" |
Topic for status message | |
"python_exec" |
Python executable used to run the reduction script | python |
Queue name: REDUCTION.DATA_READY.
{
"information": "mac83808.sns.gov",
"run_number": "30892",
"instrument": "EQSANS",
"ipts": "IPTS-10674",
"facility": "SNS",
"data_file": "/SNS/EQSANS/IPTS-10674/nexus/EQSANS_30892.nxs.h5"
}
| Configuration parameter | Description | Default value |
|---|---|---|
"service_status" |
Topic for status messages related to creating a reduction script | /topic/SNS.${instrument}.STATUS.POSTPROCESS |
Queue name: REDUCTION.CREATE_SCRIPT.
Example message using default parameters in the template:
{
'instrument': 'EQSANS',
'use_default': True
}
Example message with custom parameter values:
{
'instrument': 'SEQ',
'use_default': False,
'template_data': { dictionary of template arguments }
}
Queue name: CATALOG.ONCAT.DATA_READY.
Cataloging ingests the raw data file and any related files. For instruments that produce image files (currently VENUS), an additional image-cataloging substep batch-ingests the associated FITS/TIFF files.
The locations to catalog come from the image_filepath_metadata_paths metadata of the ingested
datafile. A location is either a single image file or a directory of images (_image_files_at()
handles both), and a single metadata path can report several locations: MCP TPX1 runs report both this
run's directory and the previous run's. Every candidate is filtered through matches_run_number(),
which matches the Run_<run_number> token the DAQ writes into every image file name. The token is
matched wherever it appears rather than only at the start, because its position varies by detector: most
write YYYYMMDD_Run_<run>_..., TPX3 prepends a second date (20250428_20260310_Run_15395_...), and some
2025 TPX1 data leads with Run_<run>_YYYYMMDD_.... Anchoring to the start would silently catalog nothing
for the detectors that deviate, which is why the token is matched by position-independent search.
The token must start the name or follow an underscore, and the run number must be followed by a non-digit, so that run 2482 does not claim the images of runs 24820-24829. Any non-digit ends the token rather than specifically an underscore, for the same reason. Duplicate locations are ingested only once.
This substep is gated per instrument: ONCatProcessor.catalog_images() runs only when the script
/<facility>/<instrument>/shared/autoreduce/catalog_<INSTRUMENT>.py exists, mirroring the
reduce_<INSTRUMENT>.py toggle used for autoreduction. The dev_instrument_shared configuration
parameter overrides the shared directory for local development and testing. See the README for the
operator-facing enable/disable instructions.
| Configuration parameter | Description | Default value |
|---|---|---|
"python_exec" |
Python executable used to run the ONCat ingest script | python |
Queue name: REDUCTION_CATALOG.DATA_READY.
| Configuration parameter | Description | Default value |
|---|---|---|
"python_exec" |
Python executable used to run the ONCat reduced ingest script | python |