Skip to content

Commit

Permalink
Run: Add 'priority' to returned fields
Browse files Browse the repository at this point in the history
Signed-off-by: Zack Cerza <[email protected]>
  • Loading branch information
zmc committed Aug 9, 2024
1 parent 2de3e87 commit a6712ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions paddles/models/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def __json__(self):
suite=self.suite,
machine_type=self.machine_type,
sha1=results['sha1'],
priority=self.priority,
)

@classmethod
Expand Down Expand Up @@ -211,6 +212,10 @@ def _updated(self):
def href(self):
return "%s/runs/%s/" % (conf.address, self.name),

@property
def priority(self):
return self.jobs[0].priority

def get_results(self):
jobs_status = [value[0] for value in self.jobs.values(Job.status)]
queued = jobs_status.count('queued')
Expand Down Expand Up @@ -270,6 +275,8 @@ def set_status(self, results=None):
# all passing => pass
elif results['pass'] == total:
new_status = 'finished pass'
elif results['queued']:
new_status = 'queued'
# this should not happen
else:
new_status = 'unknown'
Expand Down
6 changes: 6 additions & 0 deletions paddles/tests/models/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,9 @@ def test_run_results(self):
Job(dict(job_id=70+i, id=int(70+i) ,status=status), new_run)
stats_out[status] = count
assert new_run.get_results() == stats_in

def test_run_priority(self):
run_name = "run_priority"
new_run = Run(run_name)
Job(dict(job_id=1, id=1, status='queued', priority=99), new_run)
assert new_run.priority == 99

0 comments on commit a6712ba

Please sign in to comment.