From /simplify codebase sweep (2026-06-10).
These modules lazy-import torch via lazy_import but import matplotlib.pyplot eagerly:
metrics/factory.py:9, metrics/visualizers.py:6 (pulled eagerly by metrics/__init__.py:53,61)
transparency/report.py:17, transparency/results.py:11
robustness/report.py:15, robustness/results.py:11
transparency/visualisers/base_visualiser.py:9
Because pipeline/phases/registry.py:25-28 imports all three phase modules, ANY import of the orchestrator (every CLI run, every raitap.run(), even from raitap.metrics import metrics_prediction_pair in the robustness/transparency phases) loads matplotlib unconditionally.
Cost: ~0.3-1s import time and tens of MB RSS added to every startup, including metrics-only tabular runs and programmatic embedders that disable reporting/visualisation.
Fix: same pattern already used for torch -- plt = lazy_import("matplotlib.pyplot") under the TYPE_CHECKING split, or move plt.close/figure code behind function-local imports. Mechanical, matches the project's existing lazy convention.
From /simplify codebase sweep (2026-06-10).
These modules lazy-import torch via
lazy_importbut importmatplotlib.pyploteagerly:metrics/factory.py:9,metrics/visualizers.py:6(pulled eagerly bymetrics/__init__.py:53,61)transparency/report.py:17,transparency/results.py:11robustness/report.py:15,robustness/results.py:11transparency/visualisers/base_visualiser.py:9Because
pipeline/phases/registry.py:25-28imports all three phase modules, ANY import of the orchestrator (every CLI run, everyraitap.run(), evenfrom raitap.metrics import metrics_prediction_pairin the robustness/transparency phases) loads matplotlib unconditionally.Cost: ~0.3-1s import time and tens of MB RSS added to every startup, including metrics-only tabular runs and programmatic embedders that disable reporting/visualisation.
Fix: same pattern already used for torch --
plt = lazy_import("matplotlib.pyplot")under theTYPE_CHECKINGsplit, or moveplt.close/figure code behind function-local imports. Mechanical, matches the project's existing lazy convention.