perun.monitoring.monitor

Monitor module.

Attributes

Classes

MonitorStatus

Represents the status of a monitor.

PerunMonitor

The PerunMonitor class is responsible for monitoring the application and collecting data.

Module Contents

perun.monitoring.monitor.log[source]
class perun.monitoring.monitor.MonitorStatus(*args, **kwds)[source]

Bases: enum.Enum

Represents the status of a monitor.

SETUP
Type:

The monitor is being set up.

RUNNING
Type:

The monitor is running.

PROCESSING
Type:

The monitor is processing data.

SCRIPT_ERROR
Type:

An error occurred in the monitor’s script.

PERUN_ERROR
Type:

An error occurred in the Perun system.

MPI_ERROR
Type:

An error occurred in the MPI system.

FILE_NOT_FOUND
Type:

The required file was not found.

SETUP
READY
RUNNING
PROCESSING
SCRIPT_ERROR
PERUN_ERROR
SP_ERROR
MPI_ERROR
FILE_NOT_FOUND
CLOSED
perun.monitoring.monitor.PERUN_MP_START_METHOD: str = 'spawn'
class perun.monitoring.monitor.PerunMonitor(app: perun.monitoring.application.Application, comm: perun.comm.Comm, backends: Dict[str, perun.backend.backend.Backend], l_assigned_sensors: Dict[str, Tuple], config: configparser.ConfigParser)[source]

The PerunMonitor class is responsible for monitoring the application and collecting data.

Parameters:
  • app (Application) – The application to be monitored.

  • comm (Comm) – The communication object for inter-process communication.

  • l_sensors_config (Dict[str, Set[str]]) – The configuration for local sensors.

  • backends (Dict[str, Backend]) – The backends for data collection.

  • config (ConfigParser) – The configuration parser object.

_app

The application to be monitored.

Type:

Application

_comm

The communication object for inter-process communication.

Type:

Comm

_l_sensors_config

The configuration for local sensors.

Type:

Dict[str, Tuple]

_backends

The backends for data collection.

Type:

Dict[str, Backend]

_config

The configuration parser object.

Type:

ConfigParser

status

The current status of the monitor.

Type:

MonitorStatus

status
sp_ready_event: multiprocessing.synchronize.Event
start_event: multiprocessing.synchronize.Event
stop_event: multiprocessing.synchronize.Event
close_event: multiprocessing.synchronize.Event
queue: multiprocessing.Queue | None = None
perunSP: multiprocessing.Process | None = None
close() None[source]

Close the monitor.

run_application(run_id: str, record: bool = True) Tuple[MonitorStatus, perun.data_model.data.DataNode | None, Any][source]

Run the application and returns the monitor status and data node.

Parameters:
  • run_id (str) – The ID of the run.

  • record (bool, optional) – Whether to record data or not. Defaults to True.

Returns:

A tuple containing the monitor status and the data node, and the application result.

Return type:

Tuple[MonitorStatus, Optional[DataNode], Any]

Raises:
  • SystemExit – If the application exits using exit(), quit(), or sys.exit().

  • Exception – If an error occurs in the monitored script.

Notes

  • If record is True, the method performs the following steps:
    1. Gets the sensor configuration.

    2. If there are assigned devices, creates a subprocess to run the application.

    3. Starts the application and waits for it to be ready.

    4. Runs the application.

    5. Stops the application and retrieves the data.

  • If record is False, the method simply runs the application without recording data.