Skip to content

Commit

Permalink
feat(api): split up status endpoint by job status
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Mar 26, 2023
1 parent ea36082 commit ccf8d51
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions api/onnx_web/worker/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,20 +372,21 @@ def submit(
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(
[
def status(self) -> Dict[str, List[Tuple[str, int, bool, bool, bool, bool]]]:
return {
"cancelled": [],
"finished": [
(
job.job,
job.progress,
False,
job.finished,
job.cancelled,
job.failed,
)
for job in self.finished_jobs
],
"pending": [
(
job.name,
0,
Expand All @@ -395,22 +396,19 @@ def status(self) -> List[Tuple[str, int, bool, bool, bool, bool]]:
False,
)
for job in self.pending_jobs
]
)
history.extend(
[
],
"running": [
(
job.job,
name,
job.progress,
False,
job.finished,
job.cancelled,
job.failed,
)
for job in self.finished_jobs
]
)
return history
for name, job in self.running_jobs.items()
],
}

def next_job(self, device: str):
for job in self.pending_jobs:
Expand Down

0 comments on commit ccf8d51

Please sign in to comment.