Compare commits

...

4 Commits

Author SHA1 Message Date
Guillaume Raffy a8b477978d now powermap draws redundant cables as dash lines.
fixes - Bug 4250 - incohérence des consommations affichées par powermap
2025-12-11 14:23:07 +01:00
Guillaume Raffy 8a2c46c377 cocluto v1.08
- fixed bug that caused `draw_machine_age_pyramid_graph` to fail when some cluster machines get  older than 20 years. Increased the age limit to 25 years, and added clipping to the graph to cope with some machines even older than this

fixes [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=4101]
2025-06-24 16:10:09 +02:00
Guillaume Raffy 8679ae2ca5 cocluto v 1.07
fixed logic error foudn when working on [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3979]
2024-11-15 16:41:41 +01:00
Guillaume Raffy 27493f2ed7 fixed logic error foudn when working on [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3979] 2024-11-15 16:40:23 +01:00
4 changed files with 33 additions and 24 deletions

View File

@ -501,25 +501,29 @@ def power_config_to_svg(power_config: PowerConfig, svg_file_path: Path, worst_ca
for con in power_config.connections:
# print(con.from_plug.machine.name, con.to_plug.machine.name)
if not con.is_redundancy_cable(): # don't display redundancy cables, as they might overlap and hide the main one
power_consumption = con.get_power_consumption(worst_case_scenario=worst_case_scenario)
amperes = power_consumption / 220.0
color = '/svg/green'
capacity = con.get_max_amperes()
penwidth_scaler = 0.25
if capacity is None:
max_amp = '? A'
color = '/svg/red'
penwidth = 100.0 * penwidth_scaler # make the problem clearly visible
else:
max_amp = str(capacity) + 'A'
color = cable_colorer.get_cable_color(con, worst_case_scenario=worst_case_scenario)
penwidth = capacity * penwidth_scaler
label = "%.1f/%s" % (amperes, max_amp)
# color='//%d' % int(9.0-amperes/capacity*8)
power_consumption = con.get_power_consumption(worst_case_scenario=worst_case_scenario)
amperes = power_consumption / 220.0
color = '/svg/green'
capacity = con.get_max_amperes()
penwidth_scaler = 0.25
if capacity is None:
max_amp = '? A'
color = '/svg/red'
penwidth = 100.0 * penwidth_scaler # make the problem clearly visible
else:
max_amp = str(capacity) + 'A'
color = cable_colorer.get_cable_color(con, worst_case_scenario=worst_case_scenario)
penwidth = capacity * penwidth_scaler
label = "%.1f/%s" % (amperes, max_amp)
# color='//%d' % int(9.0-amperes/capacity*8)
# graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color="%s:%s" % (color, wsc_color), label=label, penwidth="%s:%s" % (penwidth, penwidth))
graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color=color, label=label, penwidth=penwidth)
if con.is_redundancy_cable():
edge_style = 'dashed'
else:
edge_style = 'solid'
# graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color="%s:%s" % (color, wsc_color), label=label, penwidth="%s:%s" % (penwidth, penwidth))
graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color=color, label=label, penwidth=penwidth, style=edge_style)
for rack_id, rack in racks.items():
# sub = graph.add_subgraph(rack, name='cluster_%s' % rack_id, rank='same')
@ -534,3 +538,4 @@ def power_config_to_svg(power_config: PowerConfig, svg_file_path: Path, worst_ca
graph.layout(prog='dot')
graph.draw(svg_file_path)

View File

@ -253,7 +253,7 @@ class SqliteDb(ISqlDatabaseBackend):
# If set False, the returned connection may be shared across multiple threads. When using multiple threads with the same connection writing operations should be serialized by the user to avoid data corruption
# I hope it's safe here but I'm not 100% sure though. Anyway, if the database gets corrupt, it not a big deal since this memory resident database gets reconstructed from the sql file...
if sqlite_db_path != ':memory:' and not sqlite_db_path.exists():
if sqlite_db_path == ':memory:' or not sqlite_db_path.exists():
logging.debug('creating sqlite database in %s', sqlite_db_path)
self._con = sqlite3.connect(sqlite_db_path, check_same_thread=check_same_thread)
else:

View File

@ -315,7 +315,7 @@ def draw_machine_age_pyramid_graph(inventory):
:param Inventory inventory: the inventory database
"""
oldest_age = 20
oldest_age = 25
age_histogram = np.zeros(shape=(oldest_age))
rows = inventory.query("SELECT * FROM machines")
@ -328,7 +328,9 @@ def draw_machine_age_pyramid_graph(inventory):
if purchase_date is not None:
purchase_time = matplotlib.dates.date2num(purchase_date.date()) # noqa: F841
age = datetime.datetime.now() - purchase_date
age_histogram[age.days // 365] += 1
age_in_years = age.days // 365
if age_in_years < oldest_age:
age_histogram[age_in_years] += 1
# print(name, age)
fig, ax = plt.subplots()
@ -349,7 +351,7 @@ def draw_core_age_pyramid_graph(inventory):
:param Inventory inventory: the inventory database
"""
oldest_age = 20
oldest_age = 25
age_histogram = np.zeros(shape=(oldest_age))
rows = inventory.query("SELECT * FROM machines")
@ -362,7 +364,9 @@ def draw_core_age_pyramid_graph(inventory):
if purchase_date is not None:
purchase_time = matplotlib.dates.date2num(purchase_date.date()) # noqa: F841
age = datetime.datetime.now() - purchase_date
age_histogram[age.days // 365] += inventory.get_num_cores(name)
age_in_years = age.days // 365
if age_in_years < oldest_age:
age_histogram[age_in_years] += inventory.get_num_cores(name)
# print(name, age)
fig, ax = plt.subplots()

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup(
name='cocluto',
version=1.06,
version=1.08,
description='compute cluster utility tools',
url='https://git.ipr.univ-rennes1.fr/graffy/cocluto',
author='Guillaume Raffy',