Skip to content

feat: add Reporter class for generating metric figures from CSVs - #35

Merged
lordlabakdas merged 7 commits into
mainfrom
pyshark
Jun 6, 2026
Merged

lordlabakdas merged 7 commits into
mainfrom
pyshark

Conversation

@lordlabakdas

Copy link
Copy Markdown
Owner

Summary

  • Add Reporter class to pcapprocessor/report.py that reads tab-separated metric CSVs produced by MetricsWriter and generates one PNG/SVG figure per requested metric
  • Figures overlay all protocols on a single axes with seaborn styling and confidence interval error bars (confInt/2 as half-width)
  • Expose Reporter via pcapprocessor/__init__.py and as a runnable CLI (python -m pcapprocessor.report --csvs ... --metrics ... --output ... --format)

Test Plan

  • _load_csv returns correct column arrays and raises FileNotFoundError for missing files
  • _plot_metric creates PNG/SVG output, raises ValueError for unknown metrics, uses metric name in filename
  • plot() creates one file per metric, auto-creates output directory, handles multiple protocols
  • Reporter importable from package top level
  • CLI exits 0 on success (paths printed to stdout), exits 1 on bad metric (error to stderr)
  • 66 tests passing across the full project suite

🤖 Generated with Claude Code

lordlabakdas and others added 7 commits June 5, 2026 21:31
tcptrace is unmaintained. Replace the subprocess shell-out with
pyshark.FileCapture, which wraps Wireshark's actively-maintained
dissectors and exposes tcp.analysis.ack_rtt, tcp.analysis.retransmission,
and per-stream packet grouping natively in Python.

_FlowAccumulator tracks tx_packets, unique_bytes, rexmt_packets,
timestamps, and RTT samples per flow direction. _dominant_flow()
picks the flow with the most unique bytes. The 12-element metrics
list is preserved unchanged for downstream compatibility.

Update test_trace.py: replace exe_comm mocks with SimpleNamespace
fake packets and pyshark.FileCapture mocks. Add _FlowAccumulator
unit tests. 56 tests, 99% coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…or bars

Adds _plot_metric method that creates matplotlib figures with seaborn styling,
plots metrics with confidence interval error bars, and saves to configured output
directory. Includes validation of metric columns and lazy imports of plot libraries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements Reporter.plot() to iterate over metrics and CSVs, adds a
__main__ CLI for generating PNG/SVG metric figures from the command line,
and exports Reporter from the pcapprocessor package __init__.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lordlabakdas
lordlabakdas merged commit ee96a97 into main Jun 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant