Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run: Add 'priority' to returned fields #128

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 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,11 @@ def _updated(self):
def href(self):
return "%s/runs/%s/" % (conf.address, self.name),

@property
def priority(self):
if self.jobs.count():
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
4 changes: 2 additions & 2 deletions paddles/tests/controllers/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def test_pause_queue(self):
response = self.app.put_json('/queue/', dict(
queue="test_queue3",
paused_by="tester",
pause_duration=10,
pause_duration=1,
))
assert response.status_code == 200
response = self.app.get('/queue/?machine_type=test_queue3')
assert response.json[0]['paused'] is True
time.sleep(10)
time.sleep(1)
response = self.app.get('/queue/?machine_type=test_queue3')
assert response.json[0]['paused'] is False

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
Loading