style: auto-format from pre-push hooks
This commit is contained in:
+19
-13
@@ -66,8 +66,9 @@ def _report(attr: str, est, cold: bool = False) -> str:
|
||||
return "\n".join(L)
|
||||
|
||||
|
||||
def _gantt(sched: dict[int, list], makespan_min: float, max_jobs: int,
|
||||
width: int = 48) -> str:
|
||||
def _gantt(
|
||||
sched: dict[int, list], makespan_min: float, max_jobs: int, width: int = 48
|
||||
) -> str:
|
||||
"""Compact per-lane text Gantt for a computed schedule (issue #16).
|
||||
|
||||
One row per lane; lanes are grouped ``max_jobs`` to a physical node. A busy
|
||||
@@ -212,9 +213,14 @@ def _run_estimate(args, ap: argparse.ArgumentParser) -> int:
|
||||
makespan_min = 0.0
|
||||
if est.to_build and (args.timeline or args.json):
|
||||
makespan_min, sched = estimate_mod.schedule_for(
|
||||
closure, preds, nodes,
|
||||
cores=rec["cores_per_node"], machines=rec["nodes"],
|
||||
history=history, max_jobs=args.max_jobs, node_ram_gb=args.node_ram_gb,
|
||||
closure,
|
||||
preds,
|
||||
nodes,
|
||||
cores=rec["cores_per_node"],
|
||||
machines=rec["nodes"],
|
||||
history=history,
|
||||
max_jobs=args.max_jobs,
|
||||
node_ram_gb=args.node_ram_gb,
|
||||
)
|
||||
|
||||
if args.json:
|
||||
@@ -234,9 +240,7 @@ def _run_estimate(args, ap: argparse.ArgumentParser) -> int:
|
||||
payload["timeline"] = {
|
||||
"makespan_min": makespan_min,
|
||||
"assignments": {
|
||||
str(lane): [
|
||||
[costmodel.store_name(t), s, f] for t, s, f in items
|
||||
]
|
||||
str(lane): [[costmodel.store_name(t), s, f] for t, s, f in items]
|
||||
for lane, items in sched.items()
|
||||
},
|
||||
}
|
||||
@@ -294,16 +298,18 @@ def main(argv: list[str] | None = None) -> int:
|
||||
)
|
||||
ap.add_argument("installables", nargs="+", help="flake attrs / drvs to build")
|
||||
ap.add_argument(
|
||||
"--repeat", type=int, default=1,
|
||||
"--repeat",
|
||||
type=int,
|
||||
default=1,
|
||||
help="build N times and merge (median) to smooth noise",
|
||||
)
|
||||
ap.add_argument(
|
||||
"--nix-arg", action="append", default=[],
|
||||
"--nix-arg",
|
||||
action="append",
|
||||
default=[],
|
||||
help="extra arg passed through to nix (repeatable)",
|
||||
)
|
||||
ap.add_argument(
|
||||
"-o", "--output", help="write JSON here (default: stdout)"
|
||||
)
|
||||
ap.add_argument("-o", "--output", help="write JSON here (default: stdout)")
|
||||
args = ap.parse_args(argv[1:])
|
||||
if args.repeat < 1:
|
||||
ap.error("--repeat must be >= 1")
|
||||
|
||||
@@ -61,7 +61,7 @@ HEAVY: dict[str, tuple[float, float]] = {
|
||||
# (issue #15) — sum of co-resident jobs' RAM must fit the node budget.
|
||||
RAM_HEAVY: dict[str, float] = {
|
||||
"qtwebengine": 10.0,
|
||||
"chromium": 10.0, # LTO link phase is the peak
|
||||
"chromium": 10.0, # LTO link phase is the peak
|
||||
"webkitgtk": 8.0,
|
||||
"tensorflow": 8.0,
|
||||
"pytorch": 8.0,
|
||||
|
||||
@@ -84,8 +84,12 @@ def estimate(
|
||||
dur_c = _durations(nodes, closure, history, cores, max_jobs)
|
||||
for p in node_grid:
|
||||
grid[(p, cores)] = schedule.makespan(
|
||||
dur_c, preds, p, max_jobs=max_jobs,
|
||||
gb_per_job=gb_per_job, node_ram_gb=node_ram_gb,
|
||||
dur_c,
|
||||
preds,
|
||||
p,
|
||||
max_jobs=max_jobs,
|
||||
gb_per_job=gb_per_job,
|
||||
node_ram_gb=node_ram_gb,
|
||||
)
|
||||
|
||||
rec = _recommend(
|
||||
@@ -130,8 +134,13 @@ def schedule_for(
|
||||
else None
|
||||
)
|
||||
return schedule.makespan(
|
||||
dur, preds, machines, max_jobs=max_jobs,
|
||||
gb_per_job=gb_per_job, node_ram_gb=node_ram_gb, return_schedule=True,
|
||||
dur,
|
||||
preds,
|
||||
machines,
|
||||
max_jobs=max_jobs,
|
||||
gb_per_job=gb_per_job,
|
||||
node_ram_gb=node_ram_gb,
|
||||
return_schedule=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
+26
-12
@@ -103,8 +103,16 @@ def test_max_jobs_accepted_and_affects_output(stub_graph, capsys):
|
||||
def test_node_ram_gb_accepted(stub_graph, capsys):
|
||||
out = _run_json(
|
||||
capsys,
|
||||
[".#x", "--history", stub_graph, "--max-jobs", "4",
|
||||
"--node-ram-gb", "8", "--json"],
|
||||
[
|
||||
".#x",
|
||||
"--history",
|
||||
stub_graph,
|
||||
"--max-jobs",
|
||||
"4",
|
||||
"--node-ram-gb",
|
||||
"8",
|
||||
"--json",
|
||||
],
|
||||
)
|
||||
assert out["node_ram_gb"] == 8.0
|
||||
|
||||
@@ -117,9 +125,7 @@ def test_timeline_renders_report(stub_graph, capsys):
|
||||
|
||||
|
||||
def test_timeline_json_carries_assignments(stub_graph, capsys):
|
||||
out = _run_json(
|
||||
capsys, [".#x", "--history", stub_graph, "--timeline", "--json"]
|
||||
)
|
||||
out = _run_json(capsys, [".#x", "--history", stub_graph, "--timeline", "--json"])
|
||||
assert "timeline" in out
|
||||
tl = out["timeline"]
|
||||
assert tl["makespan_min"] > 0
|
||||
@@ -141,10 +147,20 @@ def test_provision_emits_yaml_to_stdout(stub_graph, capsys):
|
||||
|
||||
|
||||
def test_provision_custom_class_and_name(stub_graph, capsys):
|
||||
assert cli.main(
|
||||
[".#x", "--history", stub_graph,
|
||||
"--provision", "runner", "--provision-name", "my-builder"]
|
||||
) == 0
|
||||
assert (
|
||||
cli.main(
|
||||
[
|
||||
".#x",
|
||||
"--history",
|
||||
stub_graph,
|
||||
"--provision",
|
||||
"runner",
|
||||
"--provision-name",
|
||||
"my-builder",
|
||||
]
|
||||
)
|
||||
== 0
|
||||
)
|
||||
out = capsys.readouterr().out
|
||||
assert "class: runner" in out
|
||||
assert "name: my-builder" in out
|
||||
@@ -169,8 +185,6 @@ def test_mine_subcommand_writes_json(monkeypatch, capsys, tmp_path):
|
||||
|
||||
|
||||
def test_mine_subcommand_to_stdout(monkeypatch, capsys):
|
||||
monkeypatch.setattr(
|
||||
cli.miner, "mine_history", lambda inst, **kw: {"pkg": 1.5}
|
||||
)
|
||||
monkeypatch.setattr(cli.miner, "mine_history", lambda inst, **kw: {"pkg": 1.5})
|
||||
assert cli.main(["mine", ".#pkg"]) == 0
|
||||
assert json.loads(capsys.readouterr().out) == {"pkg": 1.5}
|
||||
|
||||
Reference in New Issue
Block a user