docs(examples): runnable demos for cleaning memory replay and interactive HTML reports#149
Conversation
…tive HTML reports Two self-contained example scripts for the v1.1 flagship surfaces that had no example coverage yet: - examples/cleaning_memory_replay.py — learn_cleaning_memory / load_cleaning_memory round-trip: replay accepted decisions on new batches, show drift-blocked replay with the on-report explanation, and diff two learned memories. - examples/interactive_html_reports.py — the freshdata.render surface: to_html()/show() on CleanReport, Profile, CleanPlan and ExplainReport, plus ReportFrame results from compare_plans/infer_roles. Both follow the examples/ convention: synthetic inline data, no extra dependencies, runnable as plain scripts. Prepared with AI tooling assistance.
📝 WalkthroughWalkthroughAdds examples for learning and replaying cleaning decisions across data batches, handling dataset drift, comparing cleaning memories, and rendering freshdata reports as interactive HTML. ChangesCleaning memory replay
Interactive HTML reports
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Strix is installed on this repository, but we couldn't run this PR security review because this workspace's trial has ended. Add a card to resume code reviews here. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
examples/interactive_html_reports.py (2)
40-40: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
fd.planinstead offd.suggest_plan.Consider using
fd.plan(df)here to better represent the recommended API.fd.planis the intended front door that wrapssuggest_planand additionally provides execution and backend fallback details.
As per the relevant code snippets context,fd.planis a thin front door oversuggest_plan.♻️ Proposed refactor
- plan = fd.suggest_plan(df) + plan = fd.plan(df)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/interactive_html_reports.py` at line 40, Update the plan creation call in the interactive report flow to use the public fd.plan API instead of fd.suggest_plan, preserving the existing df argument and downstream handling.
56-59: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsistently capture and print the HTML report paths.
The preceding comment mentions that
infer_rolesalso renders as HTML via.show(). However,roles.show()is omitted, and the path forstrategy_diff.show()is not printed. Updating these lines will make this section consistent with the rest of the example script and demonstrate.show()for both operations.♻️ Proposed refactor
- strategy_diff.show() + diff_path = strategy_diff.show() + print(f"ComparePlans -> {diff_path}") roles = fd.infer_roles(df) print(roles) + roles_path = roles.show() + print(f"InferRoles -> {roles_path}")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/interactive_html_reports.py` around lines 56 - 59, Update the reporting section around strategy_diff.show() and infer_roles so both rendered reports call their show() methods and capture the returned HTML paths. Print each path consistently, including the path returned by strategy_diff.show(), then call roles.show() and print its path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@examples/interactive_html_reports.py`:
- Line 40: Update the plan creation call in the interactive report flow to use
the public fd.plan API instead of fd.suggest_plan, preserving the existing df
argument and downstream handling.
- Around line 56-59: Update the reporting section around strategy_diff.show()
and infer_roles so both rendered reports call their show() methods and capture
the returned HTML paths. Print each path consistently, including the path
returned by strategy_diff.show(), then call roles.show() and print its path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8c71d0e8-5def-4341-9a68-9ad3baf2c516
📒 Files selected for processing (2)
examples/cleaning_memory_replay.pyexamples/interactive_html_reports.py
Problem and motivation
The v1.1 flagship surfaces — cleaning memory (
fd.learn_cleaning_memory/fd.load_cleaning_memory) and the interactive HTML report layer (freshdata.render:to_html()/show()onCleanReport,Profile,CleanPlan,ExplainReport, plusReportFrame) — shipped in 1.1.0 with docs but no runnable examples. Every other headline feature has one underexamples/. These two scripts close that gap; they were written alongside the 1.1 work but never committed.What this PR adds
examples/cleaning_memory_replay.py— three-day replay story: learn a memory from a reviewedCleanReport, replay it on a matching batch (decisions markedmemory_influenced), show a drifted batch being blocked with an on-report explanation rather than silently replayed, and diff two learned memories.examples/interactive_html_reports.py—show()/to_html()across all four report objects plusReportFrameresults fromcompare_plans/infer_roles; self-contained HTML, no optional deps.Both follow the
examples/conventions: synthetic inline data, plain-script runnable, no new dependencies. No changelog entry (per convention, examples are only mentioned inside feature entries) and no README-table entry (the table indexes the numbered core walkthroughs only).Review scope: what was inspected and excluded
This PR is the outcome of a review of all unpushed local work in the primary clone (branch
feature/ai-copilot-jwd):mainand verified to run end-to-end against it.docs/superpowers/{specs,plans}/2026-07-16-production-readiness-*.md. These are agent-workflow planning documents (machine-specific absolute paths, session constraints, tooling directives);docs/superpowers/does not exist onmain, andmainalready carries the real outcome docdocs/production-readiness.md. Preserved locally on the original branch and a backup branch, not published.uv.lockin the old worktree;mainalready tracksuv.lock, the stray copy is just a side effect of the branch predating it. Nothing to commit.feature/ai-copilot-jwdare the already-merged PR AI Copilot (experimental): deterministic, privacy-first dataset analysis with explainable cleaning plans #112 history (main's copies of those files are newer); nothing to salvage.Validation
Run from a worktree of this branch (based on
main@ 8a15842):ruff check .python examples/cleaning_memory_replay.pypython examples/interactive_html_reports.pyReportFramerenderedpytest -m "not online and not large"--cov-fail-under=93(run log lost to tmp cleanup; CI will republish exact counts)python -m build && twine check dist/*mypy src/freshdatanumpy<2.5); diff touches no mypy-scoped filesRisks and compatibility
examples/); wheel contents are unchanged.crm_daily_memory.json;show()writes HTML to the OS temp dir) — same behavior class as existing examples like08_csv_automation.py.Prepared with AI tooling assistance.
Summary by CodeRabbit