just fixed pylint warnings and errors

This commit is contained in:
Guillaume Raffy 2021-01-21 16:14:29 +00:00
parent 160bc22c3d
commit 82816e5193
2 changed files with 45 additions and 44 deletions

View File

@ -95,7 +95,6 @@ class Machine(object):
return self.name == 'edf' or re.match('^ups[0-9]*$', self.name)
class Plug(object):
"""
represents a power plug (input or output) of a device
@ -131,20 +130,21 @@ class Plug(object):
# apply incoming connection amperes limitation
capacity = add_capacity_constraints(capacity, in_con.get_max_amperes())
if debug:
print(str(self)+ 'after incoming connection amperes limitation, capacity = ' + str(capacity))
print(str(self) + 'after incoming connection amperes limitation, capacity = ' + str(capacity))
else:
# apply the machine containing this plug's amperes limitation
capacity = add_capacity_constraints(capacity, self.machine.get_max_amperes())
if debug:
print(str(self)+'apply the machine containing this plug s amperes limitation, capacity = ' + str(capacity))
print(str(self) + 'apply the machine containing this plug s amperes limitation, capacity = ' + str(capacity))
# apply this plug's amperes limitation
capacity = add_capacity_constraints(capacity, self.current_capacity_constraint)
if debug:
print(str(self)+'after apply this plug s amperes limitation, capacity = ' + str(capacity), self.current_capacity_constraint)
print(str(self) + 'after apply this plug s amperes limitation, capacity = ' + str(capacity), self.current_capacity_constraint)
return capacity
class Connection(object):
"""
a power cable connecting an input power plug to an output power plug
@ -217,6 +217,7 @@ class Connection(object):
power_consumption = to_machine.get_power_consumption(worst_case_scenario) / num_input_cables
return power_consumption
class PowerConfig(object):
"""
the description of how machines are connected together (in terms of electric power)
@ -289,7 +290,6 @@ class PowerConfig(object):
if power_consumption is not None:
machine.power_consumption = power_consumption
def get_connection_to(self, to_plug):
for connection in self.connections:
if connection.to_plug == to_plug:
@ -321,6 +321,7 @@ class PowerConfig(object):
s += str(c) + '\n'
return s
class CableColorer(object):
def get_cable_color(self, cable, worst_case_scenario):
@ -329,6 +330,7 @@ class CableColorer(object):
"""
raise NotImplementedError
class SimpleColorer(CableColorer):
def get_cable_color(self, cable, worst_case_scenario):
@ -349,6 +351,7 @@ class SimpleColorer(CableColorer):
color = '/svg/green'
return color
class RampColorer(CableColorer):
@staticmethod
@ -384,6 +387,7 @@ class RampColorer(CableColorer):
color = '/svg/red' # draw overloaded cables in red
return color
def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
"""
creates a svg diagram representing the input power configuration
@ -402,7 +406,6 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
graph.edge_attr['fontsize'] = 10 # default : 14 pt
graph.edge_attr['len'] = 1.5 # default : 1.0
# graph.add_node('a')
# graph.add_node('b')
# graph.add_edge(u'a',u'b',color='blue')
@ -438,7 +441,6 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
</tr>\
</table>>' % (machine.name, machine_total_power_consumption)
if False:
x = 0.0
for rack in racks.itervalues():
@ -481,10 +483,9 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
sub.graph_attr['label'] = rack_id
# sub.graph_attr['rank']='same'
# assert False
#graph.layout(prog='twopi')
# graph.layout(prog='twopi')
with open('./toto.dot', 'w') as f:
f.write(graph.string())
graph.layout(prog='dot')
graph.draw(svg_file_path)

View File

@ -1,6 +1,6 @@
# encoding: utf-8
import datetime
#from Lib import SimpaDbUtil
# from Lib import SimpaDbUtil
import SimpaDbUtil
@ -48,7 +48,7 @@ class Inventory(object):
def machine_name_to_machine_spec_id(self, machine_name):
try:
machine_spec_id = self._sql_reader.get_table_attr('machines', 'name', machine_name, 'machine_spec_id')
except SimpaDbUtil.TableAttrNotFound as e: # @UnusedVariable
except SimpaDbUtil.TableAttrNotFound as e: # noqa: F841 @UnusedVariable
raise MachineSpecIdNotFound(machine_name)
if machine_spec_id == '':
raise MachineSpecIdNotFound(machine_name)
@ -59,7 +59,7 @@ class Inventory(object):
def machine_spec_id_to_power_consumption(self, machine_spec_id):
try:
power_consumption = float(self._sql_reader.get_table_attr('machine_spec_to_power_consumption', 'machine_spec_id', machine_spec_id, 'power_consumption'))
except SimpaDbUtil.TableAttrNotFound as e: # @UnusedVariable
except SimpaDbUtil.TableAttrNotFound as e: # noqa: F841 @UnusedVariable
# some passive machines such as pdus are not detailed in the machine_spec_to_power_consumption because they don't consume power
power_consumption = 0.0
return power_consumption
@ -105,7 +105,7 @@ class Inventory(object):
except MachineSpecIdNotFound:
# some machines are not actual machines (eg edf, ups1pdu)
pass
#except PlugTypeNotFound:
# except PlugTypeNotFound:
# some plugs are just plain connections, with no actual plug types
# pass
if plug_type is not None:
@ -163,7 +163,7 @@ class Inventory(object):
def get_computer_dflops(self, computer_name):
# print(computer_serial_number)
num_cpus = int(self._sql_reader.get_table_attr( 'computer_to_cpu', 'computer_id', computer_name, 'num_cpu'))
num_cpus = int(self._sql_reader.get_table_attr('computer_to_cpu', 'computer_id', computer_name, 'num_cpu'))
cpu_model = self._sql_reader.get_table_attr('computer_to_cpu', 'computer_id', computer_name, 'cpu_model')
flops = num_cpus * self.get_cpu_dflops(cpu_model)
return flops