Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/cli/simulator.py
Show All 11 Lines | |||||
@cli.group("simulator") | @cli.group("simulator") | ||||
def simulator(): | def simulator(): | ||||
"""Scheduler simulator.""" | """Scheduler simulator.""" | ||||
pass | pass | ||||
@simulator.command("fill-test-data") | @simulator.command("fill-test-data") | ||||
@click.option( | |||||
"--num-origins", | |||||
"-n", | |||||
type=int, | |||||
default=100000, | |||||
help="Number of listed origins to add", | |||||
) | |||||
@click.pass_context | @click.pass_context | ||||
def fill_test_data_command(ctx): | def fill_test_data_command(ctx, num_origins): | ||||
"""Fill the scheduler with test data for simulation purposes.""" | """Fill the scheduler with test data for simulation purposes.""" | ||||
from swh.scheduler.simulator import fill_test_data | from swh.scheduler.simulator import fill_test_data | ||||
click.echo("Filling test data...") | click.echo(f"Filling {num_origins:,} listed origins data...") | ||||
start = time.monotonic() | start = time.monotonic() | ||||
fill_test_data(ctx.obj["scheduler"]) | fill_test_data(ctx.obj["scheduler"], num_origins=num_origins) | ||||
runtime = time.monotonic() - start | runtime = time.monotonic() - start | ||||
click.echo(f"Completed in {runtime:.2f} seconds") | click.echo(f"Completed in {runtime:.2f} seconds") | ||||
@simulator.command("run") | @simulator.command("run") | ||||
@click.option( | @click.option( | ||||
"--scheduler", | "--scheduler", | ||||
"-s", | "-s", | ||||
Show All 33 Lines |