How yohanchatelain/pytracer works
Project type and purpose
• Pytracer is an open-source Python developer tool (CLI application with a web GUI) for instrumenting Python code, collecting numerical trace data, computing statistics, and visualizing results via a Plotly/Dash dashboard.
File structure highlights
• Top level: CI configs (.github/), Docker definitions (docker/), CLI entry points (pytracer/__main__.py), tests, requirements/setup.
• pytracer/core: core tracing, I/O (reader/writer/exporter), statistics, wrapper/filter layers.
• pytracer/callgraph: call graph data structures, layout and styling, assets for graph visualization.
• pytracer/gui: Dash/Flask server, HTML/CSS/JS assets, callbacks, layout definitions.
• pytracer/module: instrumentation hooks, parser for Python bytecode modules.
• pytracer/data/config: JSON and exclusion filter files for tracer configuration.
• Scripts and tests directories for utilities and test coverage.
System components and interactions
a. CLI Front End
• Delegates to corresponding module (pytracer.trace, pytracer.parse, etc.)
b. Trace Engine
• Loads configuration (config.json)
• Instruments target Python functions via wrapper/filter modules
• Executes target application under stochastic arithmetic (via external “fuzzy” runtime)
• Emits raw traces to cache directory as Pickle files
c. Parse Engine
• Scans cache directory for Pickle traces
• Reads them through core/inout/reader
• Aggregates numerical differences using statistics module (cnh or general)
• Writes aggregated data and generated callgraph to HDF5 and Pickle via core/inout/exporter
d. Callgraph Generator
• Builds a call graph structure from traces (pytracer/callgraph/core)
• Lays out nodes/edges (layout, layout_style)
• Exposes serialized graph to visualization layer
e. Visualization Server
• Flask/Dash application (pytracer/gui/app)
• Loads aggregated HDF5 data and callgraph
• Provides interactive dashboard (HTML/CSS/JS assets, callbacks)
• Serves on specified host/port for browser interaction
f. Auxiliary services
• Configuration Manager reads JSON and exclusion lists
• Logging and caching subsystems (pytracer/cache, pytracer/utils/log)
• Testing harness (conftest.py, pytest.ini) for CI
Architectural patterns and principles
• Modular “command” pattern separating CLI subcommands
• Layered I/O abstraction (reader → core processing → exporter)
• Pluggable instrumentation via wrapper/filter
• MVC-like separation in GUI: model (HDF5 + callgraph), view (Dash layouts/assets), controller (callbacks)
• Config-driven behavior for inclusion/exclusion