Skip to content

Commit

Permalink
kernelci.runtime.lava: calculate job priority
Browse files Browse the repository at this point in the history
Add `_get_priority` to calculate job priority from
job definition priority and priority min and max
for lab configurations.
Update `get_params` to get job priority and set
it to runtime parameters.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia authored and nuclearcat committed Sep 23, 2024
1 parent d2d3214 commit 0327faf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions kernelci/runtime/lava.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,24 @@ def __init__(self, configs, **kwargs):
super().__init__(configs, **kwargs)
self._server = self._connect()

def _get_priority(self, job):
# Scale the job priority (from 0-100) within the available levels
# for the lab, or use the lowest by default.
priority = job.config.priority if job.config.priority else 20
if self.config.priority:
priority = int(priority * self.config.priority / 100)
elif (self.config.priority_max is not None and
self.config.priority_min is not None):
prio_range = self.config.priority_max - self.config.priority_min
prio_min = self.config.priority_min
priority = int((priority * prio_range / 100) + prio_min)
return priority

def get_params(self, job, api_config=None):
params = super().get_params(job, api_config)
if params:
params['notify'] = self.config.notify
params['priority'] = self._get_priority(job)
return params

def generate(self, job, params):
Expand Down

0 comments on commit 0327faf

Please sign in to comment.