forked from mtusi2026/mtusi2026lab2
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Run full track 2 pipeline (seed, benchmark, backup/restore)."""
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DB = 'postgresql://messenger:messenger_dev_only@postgres:5432/messenger'
|
|
EVIDENCE = ROOT / 'evidence' / 'track2'
|
|
EVIDENCE.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
def docker_python(script):
|
|
subprocess.run(
|
|
[
|
|
'docker', 'compose', 'run', '--rm',
|
|
'-e', 'DATABASE_URL=' + DB,
|
|
'-e', 'TRACK2_EVIDENCE_DIR=/evidence',
|
|
'-v', f'{ROOT / "scripts"}:/scripts:ro',
|
|
'-v', f'{EVIDENCE}:/evidence',
|
|
'api', 'python', f'/scripts/{script}',
|
|
],
|
|
cwd=ROOT,
|
|
check=True,
|
|
)
|
|
|
|
|
|
def main():
|
|
for name in ('track2_seed.py', 'track2_benchmark.py'):
|
|
print('===', name, '===')
|
|
docker_python(name)
|
|
print('=== track2_backup_restore.py ===')
|
|
subprocess.run([sys.executable, str(ROOT / 'scripts' / 'track2_backup_restore.py')], cwd=ROOT, check=True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|