From 7d920ace59a14e35f052180a804840fcf80023b5 Mon Sep 17 00:00:00 2001 From: Declan Valters Date: Tue, 24 Sep 2024 18:21:00 +0100 Subject: [PATCH] Slight test tweak for DT_FACTOR --- test/test_sacc2events.py | 6 +++++- utils/sacc2eventsfile.py | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/test_sacc2events.py b/test/test_sacc2events.py index 527945f..a9d0236 100644 --- a/test/test_sacc2events.py +++ b/test/test_sacc2events.py @@ -2,9 +2,11 @@ Unit tests for sacc2eventsfile.py """ import re +import pytest from utils.sacc2eventsfile import (convert_sacc_to_workload_row, - _get_dtime, _get_account) + _get_dtime, _get_account, DT_FACTOR) +@pytest.mark.skipif(DT_FACTOR != 1, reason="Skip if DT_FACTOR != 1") def test_convert_sacc_to_workload(): """Test""" @@ -33,6 +35,7 @@ def test_convert_sacc_to_workload(): # Assert #assert result == output_row + def test_get_dtime_first(): """Return the start time since simulator start for the job submission""" @@ -43,6 +46,7 @@ def test_get_dtime_first(): assert dtime == 0 +@pytest.mark.skipif(DT_FACTOR != 1, reason="Skip if DT_FACTOR set other than 1") def test_get_dtime_later(): """Return the start time since simulator start for the job submission""" diff --git a/utils/sacc2eventsfile.py b/utils/sacc2eventsfile.py index cfc1224..deaba71 100644 --- a/utils/sacc2eventsfile.py +++ b/utils/sacc2eventsfile.py @@ -15,6 +15,10 @@ UID_PREFIX = "user" UID_RANGE = 5 +# dt time in slurm sim can be too long if measured in seconds on real +# accounting data. +# Use this factor to divide through +DT_FACTOR = 1 def convert_sacc_to_workload_row(row: dict, first_submit_time: int) -> str: @@ -38,7 +42,10 @@ def convert_sacc_to_workload_row(row: dict, first_submit_time: int) -> str: def _get_dtime(submit_time, first_submit_time) -> int: dtime = int(submit_time) - int(first_submit_time) - return dtime + if DT_FACTOR > 1: + return dtime/DT_FACTOR + else: + return dtime def _get_sim_walltime(elapse: int): return int(elapse)/60