Autopep8 on GPUMonitor
@@ -5,6 +5,7 @@ import fabric
import invoke
from tensorhive.core_anew.utils.NvidiaSmiParser import NvidiaSmiParser
+
class GPUMonitor(Monitor):
base_command: str = 'nvidia-smi --query-gpu='
format_options: str = '--format=csv' # ,nounits
@@ -54,10 +55,6 @@ class GPUMonitor(Monitor):
gpus_info.append(gpu_info)
return gpus_info
-
-
-
-
@override
def update(self, connection_group):
query = ','.join(self.available_commands)
@@ -68,60 +65,8 @@ class GPUMonitor(Monitor):
for host, host_out in output.items():
if host_out.exit_code is 0:
- gpus_info = NvidiaSmiParser.gpus_info_from_stdout(host_out.stdout)
+ gpus_info = NvidiaSmiParser.gpus_info_from_stdout(
+ host_out.stdout)
self.gathered_data[host] = gpus_info
else:
self.gathered_data[host] = []
- # self.gathered_data[command] =
-
-
-
-
- # # TODO Parse this big response, split into dict
- # self.gathered_data[host] = {
- # command: {
- # 'result': list_of_stdout_lines,
- # 'exit_code': host_out.exit_code
- # }
- # }
-
-
-
- @override
- def OLD_update(self, connection_group) -> None:
- '''
- Attaches to given shell session,
- updates info about monitored resource,
- replaces old data (old state) with current
- '''
- # TODO Catch all errors
- # TODO Organize dict structure (see how fabric handles this)
- # FIXME Too many simplifications
- # DEBUG print(f'Benchmark with {len(connection_group)} nodes on {type(connection_group)}')
- #def run(command): return connection_group.run(command, hide=True)
- #with Pool(processes=4) as pool:
- # results = pool.map(run, self.available_commands.items(), 2)
-
- for command_key, command_str in self.available_commands.items():
- try:
- results = connection_group.run(command_str, hide=True)
- except fabric.exceptions.GroupException as e:
- results = e.result
- finally:
- for connection, result in results.items():
- if isinstance(result, fabric.runners.Result):
- self.gathered_data[connection.host] = {
- command_key: {
- 'result': result.stdout.strip('\n'),
- 'exit_code': result.exited
- }
- }
- elif isinstance(result, invoke.exceptions.UnexpectedExit):
- self.gathered_data[connection.host] = {
- command_key: {
- 'result': 'Execution error',
- 'exit_code': result.result.exited
- }
- }
-
-
