Adjust naming in GPUMonitoringBehaviour
@@ -8,7 +8,7 @@ from pssh.exceptions import Timeout, UnknownHostException, ConnectionErrorExcept
class GPUMonitoringBehaviour(MonitoringBehaviour):
_base_command = 'nvidia-smi --query-gpu='
_format_options = '--format=csv'
- _available_commands = [
+ _available_queries = [
'name',
'uuid',
'fan.speed',
@@ -21,23 +21,29 @@ class GPUMonitoringBehaviour(MonitoringBehaviour):
'power.draw'
]
+ @override
+ def update(self, group_connection) -> Dict:
+ output = self._execute_with_all_queries(group_connection) # type: Dict
+ result = self._format_result(output) # type: Dict
+ return result
+
@property
- def available_commands(self) -> List:
- return self._available_commands
+ def available_queries(self) -> List:
+ return self._available_queries
- def _execute_all_commands(self, group_connection) -> Dict:
+ def _execute_with_all_queries(self, group_connection) -> Dict:
'''
Merges all commands into a single nvidia-smi query
and executes them on all hosts within connection group
'''
# Example: nvidia-smi --query-gpu=temperature.gpu,utilization.gpu,utilization.memory --format=csv
- query = ','.join(self.available_commands)
+ query = ','.join(self.available_queries)
command = '{base_command}{query} {format_options}'.format(
base_command=self._base_command, query=query, format_options=self._format_options
) # type: str
- # stop_on_errors=False means that single host failure does not raise an exception
- # it only it to the output
+ # stop_on_errors=False means that single host failure does not raise an exception,
+ # instead simply adds them to the output.
output = group_connection.run_command(command, stop_on_errors=False)
group_connection.join(output)
return output
@@ -71,9 +77,3 @@ class GPUMonitoringBehaviour(MonitoringBehaviour):
message = 'Unknown failure'
formatted_data[host] = message
return formatted_data
-
- @override
- def update(self, group_connection) -> Dict:
- output = self._execute_all_commands(group_connection) # type: Dict
- result = self._format_result(output) # type: Dict
- return result
