Skip to content

Commit

Permalink
New Figure of Merit Metric (HEPCloud#496)
Browse files Browse the repository at this point in the history
New metric for figure of merit function and instrumentation of grid figure of merit in 'grid_figure_of_merit.py'

* Fixed duplicate allowed parameter in the FOM calculation metric
  • Loading branch information
skylerfoster67 authored Apr 29, 2024
1 parent fb4c3f9 commit af1003b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from decisionengine.framework.modules import Transform
from decisionengine.framework.modules.Transform import Parameter
from decisionengine_modules.util.figure_of_merit import figure_of_merit
from decisionengine_modules.util.figure_of_merit import figure_of_merit, FIGURE_OF_MERIT_CALCULATION

ATTR_ENTRYNAME = "EntryName"
ATTR_FOM = "Grid_Figure_Of_Merit"
Expand Down Expand Up @@ -37,14 +37,21 @@ def transform(self, datablock):
max_allowed = float(entry["GlideinConfigPerEntryMaxGlideins"])
max_idle = float(entry["GlideinConfigPerEntryMaxIdle"])
idle = float(entry["GlideinMonitorTotalStatusIdle"])
f = {
ATTR_ENTRYNAME: entry[ATTR_ENTRYNAME],
ATTR_FOM: figure_of_merit(
self.price_performance, running, max_allowed, idle, max_idle, self.logger
),
}

# Instrumentation
fom_value = figure_of_merit(self.price_performance, running, max_allowed, idle, max_idle, self.logger)
f = {ATTR_ENTRYNAME: entry[ATTR_ENTRYNAME], ATTR_FOM: fom_value}
foms.append(f)

# FOM Metric
FIGURE_OF_MERIT_CALCULATION.labels(
performance=self.price_performance,
running=running,
max_allowed=max_allowed,
idle=idle,
max_idle=max_idle,
).set(fom_value)

return {"Grid_Figure_Of_Merit": pandas.DataFrame(foms)}


Expand Down
15 changes: 12 additions & 3 deletions src/decisionengine_modules/util/figure_of_merit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@

import sys

from decisionengine.framework.util.metrics import Gauge

_INFINITY = sys.float_info.max

FIGURE_OF_MERIT_CALCULATION = Gauge(
"figure_of_merit_calculation",
"Figure of Merit Calculation",
["performance", "running", "max_allowed", "idle", "max_idle"],
)


def figure_of_merit(performance, running, allowed, idle=None, max_idle=None, logger=None):
def figure_of_merit(performance, running, max_allowed, idle=None, max_idle=None, logger=None):
try:
if running >= allowed or allowed == 0:
if running >= max_allowed or max_allowed == 0:
return _INFINITY
if idle is not None and max_idle is not None and idle >= max_idle:
return _INFINITY
return performance * float(running + 1) / allowed
fom_value = performance * float(running + 1) / max_allowed
return fom_value
except TypeError:
if logger is not None:
logger.exception("TypeError in figure_of_merit")
Expand Down

0 comments on commit af1003b

Please sign in to comment.