aitune.utils.monitoring.hardware_metrics.parent_receiver

View as Markdown

Parent receiver for hardware metrics.

Module Contents

Classes

NameDescription
ParentReceiverReceiver which gets metrics from queue and sends them to child process.

API

class aitune.utils.monitoring.hardware_metrics.parent_receiver.ParentReceiver(
queue: queue.Queue | multiprocessing.queues.Queue
)

Receiver which gets metrics from queue and sends them to child process.

Communication uses pickle to serialize and deserialize data and sends/receives data via a stdin/stdout pipe.

If the main process dies, the child process will dump the collected metrics to a CSV file. If the main process is still alive and requests the metrics back, the child process will send them as pandas DataFrame so that it takes less memory to send them back.

Parameters:

queue
Queue | multiprocessing.queues.Queue

The queue to send the metrics to.

keep_running
= threading.Event()
lock
= threading.Lock()
aitune.utils.monitoring.hardware_metrics.parent_receiver.ParentReceiver.get_metrics() -> pandas.DataFrame

Gets the metrics.

Returns: pd.DataFrame

The metrics as a pandas DataFrame.

Raises:

  • RuntimeError: If the receiver is not started.
aitune.utils.monitoring.hardware_metrics.parent_receiver.ParentReceiver.run()

Runs the receiver.

This method is run in a separate thread.

aitune.utils.monitoring.hardware_metrics.parent_receiver.ParentReceiver.snapshot(
path: pathlib.Path,
reset_metrics: bool = True
) -> None

Dumps currently collected metrics to a file.

Parameters:

path
Path

Path to write the CSV file.

reset_metrics
boolDefaults to True

If True, clears the accumulated metrics after writing.

Raises:

  • RuntimeError: If the receiver is not started.
aitune.utils.monitoring.hardware_metrics.parent_receiver.ParentReceiver.start()

Starts the receiver.

aitune.utils.monitoring.hardware_metrics.parent_receiver.ParentReceiver.stop()

Stops the receiver.