16 lines
639 B
Python
16 lines
639 B
Python
"""Bounded acceptance batches that share an actual build and runtime owner."""
|
|
import json
|
|
|
|
|
|
def module_batches(ids, contract, limit=32):
|
|
if not 1 <= limit <= 32:
|
|
raise ValueError("business batch limit must be between 1 and 32")
|
|
groups = {}
|
|
overrides = contract.get("buildOverrides", {})
|
|
for record_id in sorted(set(ids)):
|
|
build = overrides.get(record_id, contract.get("build", {}))
|
|
groups.setdefault(json.dumps(build, sort_keys=True), []).append(record_id)
|
|
for selected in groups.values():
|
|
for offset in range(0, len(selected), limit):
|
|
yield selected[offset:offset + limit]
|