1
0
Fork 0

feat(api): split up status endpoint by job status

This commit is contained in:
Sean Sube 2023-03-26 11:57:00 -05:00
parent ea36082e43
commit ccf8d51e08
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
1 changed files with 28 additions and 30 deletions

View File

@ -372,33 +372,10 @@ class DevicePoolExecutor:
job = JobCommand(key, device, fn, args, kwargs)
self.pending_jobs.append(job)
def status(self) -> List[Tuple[str, int, bool, bool, bool, bool]]:
history = [
(
name,
job.progress,
False,
job.finished,
job.cancelled,
job.failed,
)
for name, job in self.running_jobs.items()
]
history.extend(
[
(
job.name,
0,
True,
False,
False,
False,
)
for job in self.pending_jobs
]
)
history.extend(
[
def status(self) -> Dict[str, List[Tuple[str, int, bool, bool, bool, bool]]]:
return {
"cancelled": [],
"finished": [
(
job.job,
job.progress,
@ -408,9 +385,30 @@ class DevicePoolExecutor:
job.failed,
)
for job in self.finished_jobs
]
],
"pending": [
(
job.name,
0,
True,
False,
False,
False,
)
return history
for job in self.pending_jobs
],
"running": [
(
name,
job.progress,
False,
job.finished,
job.cancelled,
job.failed,
)
for name, job in self.running_jobs.items()
],
}
def next_job(self, device: str):
for job in self.pending_jobs: