Skip to content

Commit

Permalink
Add number of unscheduled jobs to widget
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Sep 11, 2024
1 parent f28d467 commit 8abe632
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions adaptive_scheduler/_server_support/database_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ def n_done(self) -> int:
return 0
return self._db.count(lambda e: e.is_done)

def n_unscheduled(self) -> int:
"""Return the number of jobs that are not scheduled."""
if self._db is None:
return 0
return self._db.count(lambda e: not e.is_done and not e.is_pending)

def is_done(self) -> bool:
"""Return True if all jobs are done."""
return self.n_done() == len(self.fnames)
Expand Down
2 changes: 2 additions & 0 deletions adaptive_scheduler/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def _info_html(run_manager: RunManager) -> str:
n_done = sum(1 for job in dbm.as_dicts() if job["is_done"])
n_failed = len(dbm.failed)
n_failed_color = "red" if n_failed > 0 else "black"
n_unscheduled = len(dbm.learners) - n_running - n_pending - n_done

status = run_manager.status()
color = {
Expand All @@ -498,6 +499,7 @@ def _table_row(i: int, key: str, value: Any) -> str:
("# pending jobs", f'<font color="orange">{n_pending}</font>'),
("# finished jobs", f'<font color="green">{n_done}</font>'),
("# failed jobs", f'<font color="{n_failed_color}">{n_failed}</font>'),
("# unscheduled jobs", f'<font color="orange">{n_unscheduled}</font>'),
("elapsed time", timedelta(seconds=run_manager.elapsed_time())),
("total data size", _bytes_to_human_readable(data_size)),
]
Expand Down

0 comments on commit 8abe632

Please sign in to comment.