Make agent-written reports drop-in ready for Kaggle Discussions - #16
Make agent-written reports drop-in ready for Kaggle Discussions#16daxiongshu wants to merge 3 commits into
Conversation
…e paste Kaggle's discussion editor renders standard Markdown plus GFM tables and `` sizing (confirmed via the official announcement at kaggle.com/product-feedback/82853), so a research-brief.md pastes in almost unchanged. The one thing that doesn't survive unmodified is a local `` reference: Kaggle fetches whatever the target resolves to, so it needs to already be a public URL serving raw image bytes, not a local path or an HTML share/viewer page. kaggle_markdown_export.py rewrites local (non-http, non-data) image targets to `<base-url>/<same-relative-path>` and leaves everything else untouched, then `--verify` fetches each resulting URL and checks for an image/* content-type - catching the exact share-page-vs-raw-link mistake (e.g. a GitHub blob URL returns 200 text/html, not the image). Experiment: ran it against the two existing rogii-wellbore brief.md files in daxiongshu/competition-brief-demo (already public), pointing --base-url at their real raw.githubusercontent.com paths. Both rewrote cleanly (2 and 4 image refs respectively) and --verify confirmed every resulting URL returns 200 image/png. Also confirmed the tool correctly fails a broken base URL (404) and a GitHub blob URL (200 text/html) rather than false-positive passing them. Documented the workflow in research-brief.md under a new "Sharing the brief as a Kaggle discussion post" section. Co-Authored-By: Claude <noreply@anthropic.com>
…ernel workflow Two gaps surfaced writing a top-kernel report: (1) the "make it paste-ready for Kaggle" image-rewrite step lived only in research-brief.md, invisible to an agent routed to kernels.md, so local image paths shipped unfixed; (2) there was no tooling to tell a real code change from an identical stochastic rerun, which per-version scores alone cannot reveal. - SKILL.md: add a cross-cutting "Making any report paste-ready for a Kaggle post" section (always loaded) + a troubleshooting row keyed on the symptom. - kernels.md: point the report-writing step at that section; document and surface version-diffing (real change vs identical rerun; fork-by-code-hash). - scripts/diff_kernel_versions.py: new one-shot tool that downloads a kernel's versions, diffs code (ipynb/py), and labels IDENTICAL rerun vs CHANGED with +/- line counts and a shared-SHA fork/rerun detector. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…andle the no-host case The paste-ready guidance leaned so hard on raw.githubusercontent.com that it read as "GitHub required", never enumerated host options, and — the real gap — said nothing about what to do when the user provides no public location at all. - State plainly that any public URL returning image/* bytes works (the export step hosts nothing); list working hosts (GitHub raw/Pages, S3/GCS/R2, any CDN) and non-working ones (GitHub blob pages, Drive/Dropbox share links, local paths). - Add the no-host path: don't silently ship local  paths and call it paste-ready; deliver the report with local paths, name the remaining hosting step, offer options (incl. Kaggle's manual drag-drop upload), then rewrite+verify. Applied to SKILL.md (canonical) and research-brief.md; docs only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
|
||
| # Matches `` / `` where `path` is NOT already an | ||
| # absolute http(s) or data URL - i.e. exactly the references that need rewriting. | ||
| LOCAL_IMAGE_RE = re.compile(r"!\[([^\]]*)\]\(\s*(?!(?:https?://|data:))([^)\s]+)(\s+=\S+)?\s*\)") |
There was a problem hiding this comment.
Nice addition, confirming the finished document is a useful safeguard. One edge case is that these regexes miss valid markdown links such as:

This could happen especially if created by agents. Can we cover these cases?
| for vnum in targets: | ||
| vmeta = by_num.get(vnum, {}) | ||
| try: | ||
| archive_kernel_version(kernel_ref, str(output_dir), vnum, | ||
| include_outputs=include_outputs, force=True) |
There was a problem hiding this comment.
This works for short version histories, but the number of Kaggle API requests grow O(N^2) because archive_kernel_version is called n times, and each time it will call resolve_kernel_versions one time, which calls _get_view_model (sending post request) n times. So that's O(N^2) requests where N is the number of versions.
An example is cdeotte/titanic-wcg-xgboost-0-84688, which has 43 versions. Comparing all 43 with this flow makes roughly 2,000 internal Kaggle API calls before retries, so it’s likely to encounter rate limits or long network block, and even worse if versions is in the hundreds.
One possible solution:
- remove the resolve_kernel_versions call inside archive_kernel_version, and archive_kernel_version assumes that that the
version_numberis valid. - use
resolve_kernel_versionsto enumerate the full set of valid kernel versions. - loop over each vnum in targets:
if vnum exists in the resolved version set, use the updatedarchive_kernel_versionfunction to download that kernel version. The version number validity check happens at this step, instead of insidearchive_kernel_version.
This should reduce the Kaggle requests to O(N). Hopefully this makes sense!
Two gaps surfaced while an agent wrote a top-kernel report meant to be pasted into a Kaggle Discussion:
Reports weren't actually drop-in ready. A locally-rendered report embeds
paths that Kaggle renders as broken images. The fix (kaggle_markdown_export.py, which rewrites local image links to public raw URLs and--verifys they return image bytes) lived only inresearch-brief.md— invisible to an agent routed tokernels.md, so it shipped local paths and called it done.Correct per-version scores still can't tell you why a score moved.
kernel_archive.pyalready returns the verified LB for each version — but kernels can be stochastic, so identical code posts different scores across versions.Changes
kaggle_markdown_export.py— rewrite local image links to a public base URL +--verifythey return image bytes.diff_kernel_versions.py— builds onkernel_archive.py: pulls each version's code, diffs it (.ipynb/.py), and labelsIDENTICAL rerunvsCHANGED (+n/−m)so a score move is attributable to an edit or to noise; also flags shared-SHA reruns/forks.SKILL.md— new always-loaded "drop-in ready for Kaggle" section + troubleshooting row.kernels.md— surface both scripts and document version-diffing / fork-by-code-hash.research-brief.md— the original export-step write-up.Docs only + two self-contained scripts; no changes to existing behavior.