Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/cli/simulator.py
- This file was added.
# Copyright (C) 2021 The Software Heritage developers | |||||
# See the AUTHORS file at the top-level directory of this distribution | |||||
# License: GNU General Public License version 3, or any later version | |||||
# See top-level LICENSE file for more information | |||||
import time | |||||
import click | |||||
from . import cli | |||||
@cli.group("simulator") | |||||
def simulator(): | |||||
"""Scheduler simulator.""" | |||||
pass | |||||
@simulator.command("fill-test-data") | |||||
def fill_test_data_command(): | |||||
"""Fill the scheduler with test data for simulation purposes.""" | |||||
from swh.scheduler.simulator import fill_test_data | |||||
click.echo("Filling test data...") | |||||
start = time.monotonic() | |||||
fill_test_data() | |||||
runtime = time.monotonic() - start | |||||
click.echo(f"Completed in {runtime:.2f} seconds") | |||||
@simulator.command("run") | |||||
@click.option( | |||||
"--scheduler", | |||||
"-s", | |||||
type=click.Choice(["task_scheduler", "origin_scheduler"]), | |||||
default="origin_scheduler", | |||||
help="Scheduler to simulate", | |||||
) | |||||
douardda: unclear what this "scheduler" option actually refers to. Is 'task_scheduler' the current… | |||||
vlorentzAuthorUnsubmitted Done Inline Actionsyes. @olasd even named it legacy_scheduler originally, but we aren't going to deprecated it, so I don't think it's a good name vlorentz: yes. @olasd even named it legacy_scheduler originally, but we aren't going to deprecated it, so… | |||||
@click.option( | |||||
"--policy", | |||||
"-p", | |||||
type=click.Choice(["oldest_scheduled_first"]), | |||||
default="oldest_scheduled_first", | |||||
help="Scheduling policy to simulate (only for origin_scheduler)", | |||||
) | |||||
douarddaUnsubmitted Done Inline Actionshow does the "policy" option interact with the "scheduler" above? douardda: how does the "policy" option interact with the "scheduler" above? | |||||
@click.option("--runtime", "-t", type=float, help="Simulated runtime") | |||||
def run_command(scheduler, policy, runtime): | |||||
"""Run the scheduler simulator. | |||||
By default, the simulation runs forever. You can cap the simulated runtime | |||||
with the --runtime option, and you can always press Ctrl+C to interrupt the | |||||
running simulation. | |||||
""" | |||||
from swh.scheduler.simulator import run | |||||
policy = policy if scheduler == "origin_scheduler" else None | |||||
run(scheduler=scheduler, policy=policy, runtime=runtime) |
unclear what this "scheduler" option actually refers to. Is 'task_scheduler' the current ("legacy") one? And "origin_scheduler" the first simple implementation recently added?