perun.monitoring.monitor ======================== .. py:module:: perun.monitoring.monitor .. autoapi-nested-parse:: Monitor module. Attributes ---------- .. autoapisummary:: perun.monitoring.monitor.log perun.monitoring.monitor.PERUN_MP_START_METHOD Classes ------- .. autoapisummary:: perun.monitoring.monitor.MonitorStatus perun.monitoring.monitor.PerunMonitor Module Contents --------------- .. py:data:: log .. py:class:: MonitorStatus(*args, **kwds) Bases: :py:obj:`enum.Enum` Represents the status of a monitor. .. attribute:: SETUP :type: The monitor is being set up. .. attribute:: RUNNING :type: The monitor is running. .. attribute:: PROCESSING :type: The monitor is processing data. .. attribute:: SCRIPT_ERROR :type: An error occurred in the monitor's script. .. attribute:: PERUN_ERROR :type: An error occurred in the Perun system. .. attribute:: MPI_ERROR :type: An error occurred in the MPI system. .. attribute:: FILE_NOT_FOUND :type: The required file was not found. .. py:attribute:: SETUP .. py:attribute:: READY .. py:attribute:: RUNNING .. py:attribute:: PROCESSING .. py:attribute:: SCRIPT_ERROR .. py:attribute:: PERUN_ERROR .. py:attribute:: SP_ERROR .. py:attribute:: MPI_ERROR .. py:attribute:: FILE_NOT_FOUND .. py:attribute:: CLOSED .. py:data:: PERUN_MP_START_METHOD :type: str :value: 'spawn' .. py:class:: PerunMonitor(app: perun.monitoring.application.Application, comm: perun.comm.Comm, backends: dict[str, perun.backend.backend.Backend], l_assigned_sensors: dict[str, tuple], live_callback_inits: dict[str, Callable[[], Callable[[dict[str, perun.data_model.measurement_type.Number]], None]]], config: configparser.ConfigParser) The PerunMonitor class is responsible for monitoring the application and collecting data. :param app: The application to be monitored. :type app: Application :param comm: The communication object for inter-process communication. :type comm: Comm :param l_sensors_config: The configuration for local sensors. :type l_sensors_config: dict[str, set[str]] :param _backends: The backends for data collection. :type _backends: dict[str, Backend] :param config: The configuration parser object. :type config: ConfigParser .. attribute:: _app The application to be monitored. :type: Application .. attribute:: _comm The communication object for inter-process communication. :type: Comm .. attribute:: _l_sensors_config The configuration for local sensors. :type: dict[str, tuple] .. attribute:: _backends The backends for data collection. :type: dict[str, Backend] .. attribute:: _config The configuration parser object. :type: ConfigParser .. attribute:: status The current status of the monitor. :type: MonitorStatus .. py:attribute:: status .. py:attribute:: sp_ready_event :type: multiprocessing.synchronize.Event .. py:attribute:: start_event :type: multiprocessing.synchronize.Event .. py:attribute:: stop_event :type: multiprocessing.synchronize.Event .. py:attribute:: close_event :type: multiprocessing.synchronize.Event .. py:attribute:: queue :type: multiprocessing.Queue | None :value: None .. py:attribute:: perunSP :type: multiprocessing.Process | None :value: None .. py:method:: close() -> None Close the monitor. .. py:method:: 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. :param run_id: The ID of the run. :type run_id: str :param record: Whether to record data or not. Defaults to True. :type record: bool, optional :returns: A tuple containing the monitor status and the data node, and the application result. :rtype: tuple[MonitorStatus, DataNode | None, Any] :raises SystemExit: If the application exits using exit(), quit(), or sys.exit(). :raises Exception: If an error occurs in the monitored script. .. rubric:: 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.