import pathlib,json,time,subprocess,shutil,os root=pathlib.Path('/data/experiments/strata-practice-20261011') def own_strata_running(): for p in pathlib.Path('/proc').glob('[0-9]*/cmdline'): try: a=p.read_bytes().split(b'\0') if a[:3]==[b'python3',str(root/'harness.py').encode(),b'strata']:return True except OSError:pass return False while own_strata_running():time.sleep(5) data=json.loads((root/'strata-private-results.json').read_text());assert len(data)==60, 'Strata run incomplete' print('Strata: 60 cases finished; stop isolated worker',flush=True) subprocess.run(['docker','stop','strata-test'],check=True) state=pathlib.Path('/opt/athena-deck-dev/runtime/state/benchmark-practice-20261011');state.mkdir(exist_ok=True);os.chown(state,65534,65534) shutil.copy(root/'medium-loader.py',state/'medium-loader.py');os.chown(state/'medium-loader.py',65534,65534) for name in ['STOP','model-private.json']: try:(state/name).unlink() except FileNotFoundError:pass with (root/'medium-loader.out').open('w') as out: proc=subprocess.Popen(['docker','exec','-u','65534','athena-deck-dev','python3','/var/lib/deck/benchmark-practice-20261011/medium-loader.py'],stdout=out,stderr=subprocess.STDOUT) try: for _ in range(360): if (state/'model-private.json').exists():break if proc.poll() is not None:raise RuntimeError('Medium loader exited before readiness') time.sleep(1) else:raise TimeoutError('Medium did not become ready') shutil.copy(state/'model-private.json',root/'model-private.json');(root/'model-private.json').chmod(0o600) shutil.copy(state/'parameters-public.json',root/'medium-parameters.json') print('Medium: original profile ready; identical 60 cases',flush=True) pid=subprocess.check_output(['docker','inspect','--format','{{.State.Pid}}','athena-deck-dev'],text=True).strip() relay=subprocess.Popen(['python3',str(root/'bridge-forward.py')]) try: env=dict(os.environ,PRACTICE_BRIDGE_URL='http://172.17.0.1:18098') with (root/'medium-progress.out').open('w') as progress:subprocess.run(['nsenter','-t',pid,'-n','python3',str(root/'harness.py'),'medium'],check=True,stdout=progress,stderr=subprocess.STDOUT,env=env) finally:relay.terminate();relay.wait(timeout=5) finally: (state/'STOP').touch();proc.wait(timeout=60) print('Comparison finished; isolated Medium worker stopped',flush=True)