"""Статические графики только из сохранённых фактических агрегатов.""" import json from pathlib import Path import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt ROOT = Path(__file__).resolve().parents[1] data = json.loads((ROOT / 'evidence/pipeline.json').read_text(encoding='utf-8')) points = ('before_publish', 'after_publish', 'before_effect', 'after_original', 'after_variants', 'after_commit') fig, ax = plt.subplots(figsize=(10, 4.5), layout='constrained') for index, point in enumerate(points): values = [row['seconds'] for row in data if row['scenario'] == point] ax.scatter([index] * len(values), values, s=45) ax.set_xticks(range(len(points)), points, rotation=15) ax.set_ylabel('Full scenario duration, seconds') ax.set_title('Actual crash scenarios: stop, upload, restart, verified downloads') ax.grid(axis='y', alpha=.25) fig.savefig(ROOT / 'evidence/faults.png', dpi=160) plt.close(fig) data = json.loads((ROOT / 'evidence/load-pipeline.json').read_text(encoding='utf-8')) fig, axes = plt.subplots(1, 2, figsize=(10, 4), layout='constrained') for index, profile in enumerate(sorted({row['profile'] for row in data})): rows = [row for row in data if row['profile'] == profile] for axis, metric in zip(axes, ('successful_rps', 'p95')): axis.scatter([index] * len(rows), [row[metric] for row in rows], label=profile) for axis, label in zip(axes, ('Completed images / second', 'Upload to ready p95, seconds')): axis.set_xticks(range(len({row['profile'] for row in data})), sorted({row['profile'] for row in data})) axis.set_ylabel(label) axis.grid(axis='y', alpha=.25) fig.suptitle('Closed-loop pipeline: 2 clients, 20 seconds, 3 repeats') fig.savefig(ROOT / 'evidence/load.png', dpi=160) plt.close(fig) print('Saved evidence/faults.png and evidence/load.png')