from ops import *
exec(compile(Path('/tmp/codex/ltb1021/2026-09-26_provider-scale_r01/prepare.py').read_text(),__file__,'exec'))
assert all(r['state']=='stopped' and not r.get('child_pid') and not r.get('cleanup_pending') for r in rows)
assert not inspect('contextra-ai-gateway-1')['State']['Running']
save('training-before.json',training())
shutil.copyfile('/workspace/contextra-runtime-config/metadata-active/compose.yaml',PRIVATE/'metadata-compose.before.yaml')
(PRIVATE/'metadata-compose.before.yaml').chmod(0o600)
save('hardware.json',dict(cpu=cmd(['lscpu','-J']),memory=Path('/proc/meminfo').read_text(),
 gpu=cmd(['nvidia-smi','--query-gpu=name,uuid,driver_version,memory.total','--format=csv,noheader']),
 kernel=cmd(['uname','-sr']),logical_cpus=os.cpu_count(),
 artifact=api('/api/v1/metadata/status')['artifacts']))
print('Baseline saved; channels stopped, Gateway stopped')
