Files
horizon/tools/parity_shard.py
T
Ludovic MarieandClaude Opus 5.5 c9c53629d4 parity: run world_spawn in four shards
world_spawn starts a vanilla and a Horizon server for each of 60 seeds,
one at a time: 1,144-1,548 s on the CI runner, the parity job's longest
harness and its floor whenever a PR's changes reach it. With
PARITY_SHARDS = 4 each shard creates every fourth seed's worlds, in its
own build directory.

The shard helper datafix had moves to tools/parity_shard.py, which both
use. It stays out of lab.py, which every harness imports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 14:36:58 +02:00

22 lines
779 B
Python

"""A sharded harness's share of its cases.
A harness that declares PARITY_SHARDS = n runs as n entries in tools/parity.py, which sets PARITY_SHARD=i/n for
each. Outside the runner PARITY_SHARD is unset and a harness runs everything. Kept out of lab.py: every harness
imports lab.py, so a change there reruns them all.
"""
import os
def shard(items):
"""Every n-th item from the i-th, or all of them outside the runner."""
spec = os.environ.get("PARITY_SHARD")
if not spec:
return items
index, count = map(int, spec.split("/"))
return items[index - 1::count]
def label():
"""A directory name for this share ("2-4", or "all"): shards run at once and must not share outputs."""
return os.environ.get("PARITY_SHARD", "all").replace("/", "-")