Skip to content

Commit d2b7985

Browse files
fix(ci): create outputs/ and images/ if missing
1 parent 5003e9e commit d2b7985

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

scripts/run_once.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22
import matplotlib.pyplot as plt
33

44
ROOT = pathlib.Path(__file__).resolve().parents[1]
5+
6+
# ✅ Ensure folders exist on fresh CI runners
7+
(ROOT / 'outputs').mkdir(parents=True, exist_ok=True)
8+
(ROOT / 'images').mkdir(parents=True, exist_ok=True)
9+
510
con = duckdb.connect(database=str(ROOT / 'analytics.duckdb'))
611

7-
for rel in ['models/staging/stg_events.sql','models/marts/mart_sessions.sql','models/marts/mart_funnel.sql','models/marts/mart_retention.sql']:
12+
# Build models
13+
for rel in [
14+
'models/staging/stg_events.sql',
15+
'models/marts/mart_sessions.sql',
16+
'models/marts/mart_funnel.sql',
17+
'models/marts/mart_retention.sql'
18+
]:
819
con.execute((ROOT / rel).read_text())
920

1021
# Export marts to CSVs
@@ -19,8 +30,11 @@
1930
stages = ['visits','signups','activations','purchases']
2031
vals = [row[s] for s in stages]
2132
plt.figure(figsize=(6,4))
22-
plt.bar(stages, vals); plt.title('Funnel (Last Day)')
23-
plt.tight_layout(); plt.savefig(ROOT / 'images' / 'funnel_last_day.png', dpi=150); plt.close()
33+
plt.bar(stages, vals)
34+
plt.title('Funnel (Last Day)')
35+
plt.tight_layout()
36+
plt.savefig(ROOT / 'images' / 'funnel_last_day.png', dpi=150)
37+
plt.close()
2438

2539
# Average 7-day retention curve
2640
ret = con.execute("""
@@ -34,7 +48,10 @@
3448
if not ret.empty:
3549
plt.figure(figsize=(6,4))
3650
plt.plot(ret['day_num'], ret['avg_retention'])
37-
plt.title('7-Day Retention (Average)'); plt.xlabel('Day'); plt.ylabel('Retention')
38-
plt.tight_layout(); plt.savefig(ROOT / 'images' / 'retention_curve.png', dpi=150); plt.close()
51+
plt.title('7-Day Retention (Average)')
52+
plt.xlabel('Day'); plt.ylabel('Retention')
53+
plt.tight_layout()
54+
plt.savefig(ROOT / 'images' / 'retention_curve.png', dpi=150)
55+
plt.close()
3956

4057
print('Built models → outputs/*.csv and images/*.png')

0 commit comments

Comments
 (0)