Skip to content

Commit f10348f

Browse files
committed
refactor: pass event data into plotting functions
1 parent df6a7ff commit f10348f

File tree

3 files changed

+418
-0
lines changed

3 files changed

+418
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@ python src/run.py --help
3030
```
3131

3232
for a description of all available options.
33+
34+
Running:
35+
36+
```bash
37+
python src/run.py plot
38+
```
39+
40+
will generate the performance and version stream plots using the records stored
41+
in MongoDB.

src/run.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import click
3030
from api import parallel_fetch, ISSUES, DEFAULT_MAX_ERRORS
31+
from viz import load_event, plot_performance, plot_version_stream
3132

3233
DEFAULT_DAYS_WINDOW = 90
3334
DEFAULT_CHUNK_DAYS = 1
@@ -149,6 +150,23 @@ def get(event, start_date, end_date, days, chunk_days, jobs, max_errors, cached_
149150
click.echo(f"{datetime.now(timezone.utc):%Y-%m-%d %H:%M:%S} [Finished]")
150151

151152

153+
@cli.command()
154+
@click.option("-o", "--output-dir", type=click.Path(file_okay=False, dir_okay=True, writable=True), default=".")
155+
@click.option("--drop-cutoff", default=None, help="Ignore versions older than this")
156+
def plot(output_dir, drop_cutoff):
157+
"""Generate plots using records stored in MongoDB."""
158+
today = datetime.now().date().strftime("%Y%m%d")
159+
out_perf = os.path.join(output_dir, f"{today}_weekly.png")
160+
out_ver = os.path.join(output_dir, f"{today}_versionstream.png")
161+
162+
unique_started = load_event("started")
163+
unique_success = load_event("success")
164+
165+
plot_performance(unique_started, unique_success, drop_cutoff=drop_cutoff, out_file=out_perf)
166+
plot_version_stream(unique_started, unique_success, drop_cutoff=drop_cutoff, out_file=out_ver)
167+
click.echo(f"Saved plots to {output_dir}")
168+
169+
152170
if __name__ == "__main__":
153171
""" Install entry-point """
154172
cli()

0 commit comments

Comments
 (0)