okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
53623e56f
main
1#!/usr/bin/env python3 2"""Build a server config: the current install config plus extra args/env. 3 4The same builder scripts/ab-run.sh uses inline, factored out so the report's own 5configs (the soak's, interleave500's B arm) can be reproduced from the script. 6 7Usage: 8build_cfg.py OUT [--arg NAME VALUE]... [--env NAME=VALUE]... 9""" 10import json 11import sys 12from pathlib import Path 13 14ROOT = Path (__file__ ).resolve ().parents [4 ] 15BASE = ROOT / 'strata-coder-iq1_m.json' 16 17 18def main (): 19out = sys .argv [1 ] 20extras = sys .argv [2 :] 21cfg = json .loads (BASE .read_text ()) 22args = list (cfg ['args' ]) 23env = dict (cfg .get ('env' )or {}) 24i = 0 25while i < len (extras ): 26if extras [i ]== '--env' : 27k ,_ ,v = extras [i + 1 ].partition ('=' ) 28env [k ]= v 29i += 2 30elif extras [i ]== '--arg' : 31args += [extras [i + 1 ],extras [i + 2 ]] 32i += 3 33else : 34raise SystemExit (f'unknown extra { extras [ i ]!r } ' ) 35cfg ['args' ]= args 36if env : 37cfg ['env' ]= env 38Path (out ).write_text (json .dumps (cfg ,indent = 2 )+ '\n' ) 39f' { out } : +args { extras } ' ) 40 41 42if __name__ == '__main__' : 43main ()