Basic usage#

In its simplest form, MENTO can be used at a PETRA-III beamline to launch a data processing job on a remote HPC (Maxwell) node, without needing to know how to connect to the HPC cluster Maxwell, or how to authenticate without having a scientific account for Maxwell, or indeed how job submissions work.

A remote analysis program can be started on data acquired at the beamline, by a Python script importing a MENTO module, creating a MENTO Trigger object and calling run() on it.

Example#

Here is a minimum working example:

from mento import Trigger

my_trigger = Trigger()  # default trigger will submit Slurm jobs on an HPC node

my_analysis = 'maxwell_program.exe'  # path to analysis program available on Maxwell

my_args = ['analysis', 'parameters', 'list', 'inputdatafile']  # arguments required by analysis program, including input data

my_trigger.run([my_analysis, my_args])  # connect to a remote machine with appropriate credentials and start the analysis job there

Note that paths to input data files and output directories can be specified as you see them at the beamline, and they will be automagically found in the remote core filesystem on Maxwell.

Paths to the analysis program on Maxwell, will of course need to refer to the ‘remote’ paths as seen from a Maxwell node, since MENTO cannot know about them from the beamline.

A dummy example of running MENTO to do live data analysis during data acquisition is shown here(downloadable Python script).

Using MENTO for online data analysis#

When using Maxwell to perform the data analysis, MENTO uses Maxwell’s Slurm system that manages access to the compute nodes and schedules processing jobs according to the permissions and resources granted to the user requesting the processing. Depending on the resources allocated to the user running MENTO, processing jobs may be queued on Maxwell, and run at a later time (or never).

Therefore, to have the data processing jobs run live at the same time as data acquisition during a beamtime, the recommendation is to request ‘online’ resources on Maxwell at the time of starting the beamtime. This is explained in detail in the DESY-IT/ASAP3 documentation for starting beamtimes.

Here is the short version: when starting your beamtime, use the following command to request an ‘online’ Maxwell compute node which MENTO will then use to run remote data processing jobs:

startBeamtime --beamtimeId 999999999 --beamline P9999 --online

(Replace the beamline and beamtime ID with your beamline and beamtime ID, of course).

If your data processing program needs a GPU, please also add --feature gpu to the startBeamtime command.

To request ‘online’ Maxwell resources for commissioning runs instead of user beamtimes, please use startComissioning with the same arguments as for startBeamtime (--online and --feature).

Customizations#

The MENTO trigger can be customized based on the beamline’s needs. An example:

Online results visualization#

For online visualization of results, we need to automatically run plotting programs locally.

This can be quickly achieved by created a customized trigger using

my_trigger = Trigger(TriggerMethod.LOCAL_BASH_SCRIPT).

Calling run() on this trigger would then launch a visualization program (either directly or wrapped inside a Bash script) locally.

Of course, the input arguments and the parameter list would also need to be appropriately modified.