tour

notebooks/tour.py

#0 jc.step

jellycell tour

Exercises the core jc.* API without external deps. Run with jellycell run notebooks/tour.py, then jellycell export tearsheet notebooks/tour.py to drop a curated summary into manuscripts/.

#1 jc.step

1. Config — a kind=setup cell

Setup cells surface their source in the tearsheet so parameters are obvious at a glance.

#2 config jc.setup ok 144 ms
USERS = 120
SESSIONS = 450
CONVERSIONS = 38
#3 jc.step

2. Load — simulate reading project inputs

Real projects would read from data/; we keep this demo dep-free by constructing a literal.

#4 raw jc.load ok 4 ms
raw = {"users": USERS, "sessions": SESSIONS, "conversions": CONVERSIONS}
print(f"loaded {len(raw)} metrics")
loaded 3 metrics
#5 jc.step

3. Transform with an explicit dep

#6 rate deps: raw ok 5 ms
conversion_rate = raw["conversions"] / raw["sessions"]
print(f"conversion rate: {conversion_rate:.2%}")
conversion rate: 8.44%
#7 jc.step

4. Persist a JSON summary via jc.save

The tearsheet auto-renders the saved JSON as a key/value table.

#8 summary deps: rate ok 6 ms
import jellycell.api as jc

summary = {
    "total_users": raw["users"],
    "total_sessions": raw["sessions"],
    "conversion_rate": round(conversion_rate, 4),
    "conversions": raw["conversions"],
}
jc.save(summary, "artifacts/summary.json")
PosixPath('/Users/blaise/Desktop/blaise-oss/jellycell/examples/demo/artifacts/summary.json')
#9 jc.step

5. Round-trip via jc.load

jc.load registers an implicit dep edge on the producing cell (name=summary). Edit the summary cell → this cell's cache invalidates automatically, no hand-written deps= needed.

#10 roundtrip ok 5 ms
reloaded = jc.load("artifacts/summary.json")
assert reloaded == summary
print(f"reloaded {len(reloaded)} keys: {sorted(reloaded)}")
reloaded 4 keys: ['conversion_rate', 'conversions', 'total_sessions', 'total_users']
#11 jc.step

6. Derived metric — exercises cache invalidation

Change CONVERSIONS in the setup cell and only the downstream subgraph (ratesummary → this cell) re-runs.

#12 derived deps: summary ok 5 ms
headline = f"{raw['conversions']} of {raw['sessions']} sessions converted"
jc.save({"headline": headline}, "artifacts/headline.json")
print(headline)
38 of 450 sessions converted