From 8a2c46c377cc771088fbc724ce63a2780a2eb43a Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Tue, 24 Jun 2025 16:10:09 +0200 Subject: [PATCH] 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] --- cocluto/cluster_stats.py | 12 ++++++++---- setup.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cocluto/cluster_stats.py b/cocluto/cluster_stats.py index 41bd41d..72c4dfd 100644 --- a/cocluto/cluster_stats.py +++ b/cocluto/cluster_stats.py @@ -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() diff --git a/setup.py b/setup.py index 30a0429..6cfec4d 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='cocluto', - version=1.07, + version=1.08, description='compute cluster utility tools', url='https://git.ipr.univ-rennes1.fr/graffy/cocluto', author='Guillaume Raffy',