Skip to content

Commit 08e45c0

Browse files
authored
Add number of unscheduled jobs to widget (#235)
* Add number of unscheduled jobs to widget * color
1 parent d1f5488 commit 08e45c0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

adaptive_scheduler/_server_support/database_manager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ def n_done(self) -> int:
229229
return 0
230230
return self._db.count(lambda e: e.is_done)
231231

232+
def n_unscheduled(self) -> int:
233+
"""Return the number of jobs that are not scheduled."""
234+
if self._db is None:
235+
return 0
236+
return self._db.count(lambda e: not e.is_done and not e.is_pending)
237+
232238
def is_done(self) -> bool:
233239
"""Return True if all jobs are done."""
234240
return self.n_done() == len(self.fnames)

adaptive_scheduler/widgets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ def _info_html(run_manager: RunManager) -> str:
474474
n_done = sum(1 for job in dbm.as_dicts() if job["is_done"])
475475
n_failed = len(dbm.failed)
476476
n_failed_color = "red" if n_failed > 0 else "black"
477+
n_unscheduled = len(dbm.learners) - n_running - n_pending - n_done
478+
n_unscheduled_color = "orange" if n_unscheduled > 0 else "black"
477479

478480
status = run_manager.status()
479481
color = {
@@ -498,6 +500,7 @@ def _table_row(i: int, key: str, value: Any) -> str:
498500
("# pending jobs", f'<font color="orange">{n_pending}</font>'),
499501
("# finished jobs", f'<font color="green">{n_done}</font>'),
500502
("# failed jobs", f'<font color="{n_failed_color}">{n_failed}</font>'),
503+
("# unscheduled jobs", f'<font color="{n_unscheduled_color}">{n_unscheduled}</font>'),
501504
("elapsed time", timedelta(seconds=run_manager.elapsed_time())),
502505
("total data size", _bytes_to_human_readable(data_size)),
503506
]

0 commit comments

Comments
 (0)