Issue in calculation of elapsed_hours in the usage reports
Hi,
Due to this function, when elapsed_seconds is 0, elapsed_hours is None:
def elapsed_hours(self):
elapsed_seconds = self.elapsed_seconds()
if elapsed_seconds:
return elapsed_seconds / SECONDS_PER_HOUR
else:
return None
And when elapsed_hours is None, ram_megabyte_hours and cpu_hours are None too (due to these functions).
In such a usage report, the null value should be zeros:
{
"cpus": 1,
"name": "ruff_step",
"cpu_hours": null,
"exit_code": 0,
"start_time": "2025-07-04T11:39:28+00:00",
"finish_time": "2025-07-04T11:39:28+00:00",
"elapsed_hours": null,
"ram_megabytes": 268.435456,
"disk_megabytes": 0.003581,
"elapsed_seconds": 0,
"ram_megabyte_hours": null
},
Kind Regards,
Bernard
Thanks for reporting this issue. How can we reproduce this behaviour?
It happens when the execution starts and completes in the same second: the start and finish times have thus the same value.
It can be a small script that lists the contents of a folder, or even an execution of ruff, as in the above example, because it is really extremely fast.
But this is only true if the start and finish times are rounded somewhere because normally start_time, finish_time, delta, total_seconds, etc. should contain microseconds.