874b6f20c2
Основа — Horizon (MIT). История апстрима не переносится: этот репозиторий ведёт свою.
22 lines
779 B
Python
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("/", "-")
|