perun.monitoring.monitor

Monitor module.

Attributes

log

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
class perun.monitoring.monitor.MonitorStatus(*args, **kwds)

Bases: enum.Enum

Represents the status of a monitor.

Attributes

SETUP: The monitor is being set up. RUNNING: The monitor is running. PROCESSING: The monitor is processing data. SCRIPT_ERROR: An error occurred in the monitor’s script. PERUN_ERROR: An error occurred in the Perun system. MPI_ERROR: An error occurred in the MPI system. FILE_NOT_FOUND: The required file was not found. SUCCESS: The monitor completed successfully.

SETUP
RUNNING
PROCESSING
SCRIPT_ERROR
PERUN_ERROR
SP_ERROR
MPI_ERROR
FILE_NOT_FOUND
SUCCESS
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)

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

Parameters

appApplication

The application to be monitored.

commComm

The communication object for inter-process communication.

l_sensors_configDict[str, Set[str]]

The configuration for local sensors.

backendsDict[str, Backend]

The backends for data collection.

configConfigParser

The configuration parser object.

Attributes

_appApplication

The application to be monitored.

_commComm

The communication object for inter-process communication.

_l_sensors_configDict[str, Tuple]

The configuration for local sensors.

_backendsDict[str, Backend]

The backends for data collection.

_configConfigParser

The configuration parser object.

statusMonitorStatus

The current status of the monitor.

_app
_comm
_backends
_l_assigned_sensors
_config
status
_reset_subprocess_handlers() None

Reset subprocess handlers.

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

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

Parameters

run_idstr

The ID of the run.

recordbool, optional

Whether to record data or not. Defaults to True.

Returns

Tuple[MonitorStatus, Optional[DataNode], Any]

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

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.

_run_python_app(run_id: str) Tuple[MonitorStatus, perun.data_model.data.DataNode | None, Any]
_run_binary_app(run_id: str) Tuple[MonitorStatus, perun.data_model.data.DataNode | None, Any]
_handle_failed_run() perun.data_model.data.DataNode | None
_process_single_run(run_id: str, starttime_ns: int, available_ranks: List[int] | None = None) perun.data_model.data.DataNode | None

Collect data from subprocess and pack it in a data node.

Parameters

run_idstr

The id to use for the data node.

starttime_nsint

Start time of the run.

Returns

Optional[DataNode]

If the rank spawned a subprocess, returns the data node with the data.

_close_subprocess() None

Close the subprocess.