Commit 97603503 authored by Maiterth, Matthias's avatar Maiterth, Matthias
Browse files

Fixed get_current_utilization to work with trace_quanta set to None again, if...

Fixed get_current_utilization to work with trace_quanta set to None again, if trace is an integer or float.

This was a regression, however should be fixed by introducing a trace type containing the information, what the trace is and not rely on the type only. This also would allow to introduce trace types that are e.g. a trace per node of a job. and traces that are timeseries compared to arrays.
parent d06d0ac1
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -648,6 +648,9 @@ def get_current_utilization(trace, job: Job):
    """Return utilization for a trace at the job's current running time.
       Note: this should move to a trace.py and a Trace class!
    """
    if (isinstance(trace, list) and trace) or \
       (isinstance(trace, np.ndarray) and trace.size != 0):

        if not job.trace_quanta:
            raise ValueError("job.trace_quanta is not set; cannot compute utilization.")

@@ -655,8 +658,6 @@ def get_current_utilization(trace, job: Job):
        if time_quanta_index < 0:
            time_quanta_index = 0

    if (isinstance(trace, list) and trace) or \
       (isinstance(trace, np.ndarray) and trace.size != 0):
        if time_quanta_index < len(trace):
            util = get_utilization(trace, time_quanta_index)
        else:
@@ -664,6 +665,7 @@ def get_current_utilization(trace, job: Job):
    elif isinstance(trace, (float, int)):
        util = trace
    else:
        raise ValueError(f"trace is of unexpected type: {type(trace)}.")
        util = 0.0

    return util