feat(api): split up status endpoint by job status
This commit is contained in:
parent
ea36082e43
commit
ccf8d51e08
|
@ -372,33 +372,10 @@ class DevicePoolExecutor:
|
||||||
job = JobCommand(key, device, fn, args, kwargs)
|
job = JobCommand(key, device, fn, args, kwargs)
|
||||||
self.pending_jobs.append(job)
|
self.pending_jobs.append(job)
|
||||||
|
|
||||||
def status(self) -> List[Tuple[str, int, bool, bool, bool, bool]]:
|
def status(self) -> Dict[str, List[Tuple[str, int, bool, bool, bool, bool]]]:
|
||||||
history = [
|
return {
|
||||||
(
|
"cancelled": [],
|
||||||
name,
|
"finished": [
|
||||||
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(
|
|
||||||
[
|
|
||||||
(
|
(
|
||||||
job.job,
|
job.job,
|
||||||
job.progress,
|
job.progress,
|
||||||
|
@ -408,9 +385,30 @@ class DevicePoolExecutor:
|
||||||
job.failed,
|
job.failed,
|
||||||
)
|
)
|
||||||
for job in self.finished_jobs
|
for job in self.finished_jobs
|
||||||
]
|
],
|
||||||
)
|
"pending": [
|
||||||
return history
|
(
|
||||||
|
job.name,
|
||||||
|
0,
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
False,
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
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):
|
def next_job(self, device: str):
|
||||||
for job in self.pending_jobs:
|
for job in self.pending_jobs:
|
||||||
|
|
Loading…
Reference in New Issue