Skip to content

Commit c3de780

Browse files
committed
feat: integrate async status printers with the async scheduler
This enables the new async status printers to be used with the new async scheduler. The connections are via the callbacks (observer pattern) defined on the scheduler, with the status printing logic entirely independent from the scheduler logic otherwise. Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
1 parent 0e946e5 commit c3de780

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/dvsim/cli/run.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,18 @@
4444
from dvsim.launcher.slurm import SlurmLauncher
4545
from dvsim.logging import LOG_LEVELS, configure_logging, log
4646
from dvsim.runtime.registry import BackendType, backend_registry
47-
from dvsim.scheduler.async_status_printer import StatusPrinter
47+
from dvsim.scheduler.async_status_printer import (
48+
StatusPrinter,
49+
)
50+
from dvsim.scheduler.async_status_printer import (
51+
get_status_printer as get_async_status_printer,
52+
)
4853
from dvsim.scheduler.status_printer import get_status_printer
4954
from dvsim.utils import TS_FORMAT, TS_FORMAT_LONG, Timer, rm_path, run_cmd_with_timeout
5055

56+
# Set to 1 to enable experimental use of the new async scheduler (not yet fully integrated)
57+
EXPERIMENTAL_ENABLE_ASYNC_SCHEDULER = os.environ.get("EXPERIMENTAL_ENABLE_ASYNC_SCHEDULER", None)
58+
5159
# The different categories that can be passed to the --list argument.
5260
_LIST_CATEGORIES = ["build_modes", "run_modes", "tests", "regressions"]
5361

@@ -972,8 +980,13 @@ def main(argv: list[str] | None = None) -> None:
972980
# Now that we have printed the results from the scheduler, we close the
973981
# status printer, to ensure the status remains relevant in the UI context
974982
# (for applicable status printers).
975-
status_printer = get_status_printer(args.interactive)
976-
status_printer.exit()
983+
if EXPERIMENTAL_ENABLE_ASYNC_SCHEDULER:
984+
if not args.interactive:
985+
status_printer = get_async_status_printer()
986+
status_printer.exit()
987+
else:
988+
status_printer = get_status_printer(args.interactive)
989+
status_printer.exit()
977990

978991
else:
979992
log.error("Nothing to run!")

src/dvsim/flow/base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from dvsim.logging import log
2424
from dvsim.runtime.registry import backend_registry
2525
from dvsim.scheduler.async_core import Scheduler as AsyncScheduler
26+
from dvsim.scheduler.async_status_printer import create_status_printer
2627
from dvsim.scheduler.core import Scheduler
2728
from dvsim.scheduler.log_manager import LogManager
2829
from dvsim.utils import (
@@ -473,6 +474,15 @@ async def run_scheduler(self, jobs: list[JobSpec]) -> list[CompletedJobStatus]:
473474
# TODO: introduce a better prioritization function that accounts for timeout
474475
)
475476

477+
if not self.interactive:
478+
status_printer = create_status_printer(jobs)
479+
480+
# Add status printer hooks
481+
scheduler.add_run_start_callback(status_printer.start)
482+
scheduler.add_job_status_change_callback(status_printer.update_status)
483+
scheduler.add_run_end_callback(status_printer.stop)
484+
scheduler.add_kill_signal_callback(status_printer.pause)
485+
476486
# Add log manager hooks
477487
log_manager = LogManager()
478488
scheduler.add_job_status_change_callback(

0 commit comments

Comments
 (0)