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]
This commit is contained in:
Guillaume Raffy 2025-06-24 16:10:09 +02:00
parent 8679ae2ca5
commit 8a2c46c377
2 changed files with 9 additions and 5 deletions

View File

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

View File

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