pyra.hardware¶
Functions related to the dashboard viewer.
- pyra.hardware.chart_data() dict [source]¶
Get chart data.
Get the data from the
dash_stats
dictionary, formatted for use withplotly
.- Returns:
- dict
A single key named ‘graphs’ contains a list of graphs. Each graph is formatted as a dictionary and ready to use with
plotly
.
See also
pyra.webapp.callback_dashboard
A callback called by javascript to get this data.
Examples
>>> chart_data() {'graphs': [{"data": [...], "layout": ..., "config": ..., {"data": ...]}
- pyra.hardware.chart_types()[source]¶
Get chart types.
Get the type of charts supported by the system.
- Returns:
- list
A list containing the types of charts supported.
Examples
>>> chart_types() ['cpu', 'memory', 'network']
>>> chart_types() ['cpu', 'gpu', 'memory', 'network']
- pyra.hardware.update()[source]¶
Update all dashboard stats.
This function updates the cpu and memory usage of this python process as well as subprocesses. Following that the system functions are called to update system cpu, gpu, memory, and network usage. Finally, the keys in the
dash_stats
dictionary are cleaned up to only hold 120 values. This function is called once per second, therefore there are 2 minutes worth of values in the dictionary.Examples
>>> update()
- pyra.hardware.update_cpu() float [source]¶
Update dashboard stats for system CPU usage.
This will append a new value to the
dash_stats['cpu'][system']
list.- Returns:
- float
The current system cpu percentage utilized.
Examples
>>> update_cpu()
- pyra.hardware.update_gpu()[source]¶
Update dashboard stats for system GPU usage.
This will create new keys for the
dash_stats
dictionary if required, and then append a new value to the appropriate list.AMD data is provided by pyamdgpuinfo on Linux, and by pyadl on non Linux systems. Nvidia data is provided by GPUtil.
Examples
>>> update_gpu()
- pyra.hardware.update_memory()[source]¶
Update dashboard stats for system memory usage.
This will append a new value to the
dash_stats['memory']['system']
list.- Returns:
- float
The current system memory percentage utilized.
Examples
>>> update_memory()
- pyra.hardware.update_network()[source]¶
Update dashboard stats for system network usage.
This will append a new values to the
dash_stats['network']['received']
anddash_stats['network']['sent']
lists.- Returns:
- tuple
A tuple of the received and sent values as a difference since the last update.
Examples
>>> update_network()