Skip to content

shepsci/kaggle-skill / skills/kaggle

kaggle

Flagged

Unified Kaggle skill. Use when the user explicitly mentions Kaggle, kaggle.com, a Kaggle URL, Kaggle competitions, Kaggle datasets/models/notebooks, Kaggle forums/discussions/writeups, Kaggle benchmarks, hackathons hosted on Kaggle, Kaggle badges, or Kaggle account setup. Do not use for generic ML, GPU/TPU, notebook, dataset, benchmark, or data-science tasks unless the user clearly ties them to Kaggle.

FileKindSize
SKILL.mdskill md10.3 KB
modules/README.mdmarkdown2.3 KB
modules/badges/README.mdmarkdown1.6 KB
modules/badges/references/badge-catalog.mdmarkdown6.6 KB
modules/badges/scripts/badge_registry.pyscript8.5 KB
modules/badges/scripts/badge_tracker.pyscript4.1 KB
modules/badges/scripts/orchestrator.pyscript5.3 KB
modules/badges/scripts/phase_1_instant_api.pyscript24.0 KB
modules/badges/scripts/phase_2_competition.pyscript13.5 KB
modules/badges/scripts/phase_3_pipeline.pyscript11.7 KB
modules/badges/scripts/phase_4_browser.pyscript2.2 KB
modules/badges/scripts/phase_5_streaks.pyscript5.6 KB
modules/badges/scripts/templates/README_dataset.mdmarkdown573 B
modules/badges/scripts/templates/dataset-metadata.jsonconfig871 B
modules/badges/scripts/templates/kernel-metadata.jsonconfig412 B
modules/badges/scripts/templates/model-instance-metadata.jsonconfig253 B
modules/badges/scripts/templates/model-metadata.jsonconfig355 B
modules/badges/scripts/templates/python_notebook.ipynbother1.3 KB
modules/badges/scripts/templates/r_notebook.ipynbother1.1 KB
modules/badges/scripts/templates/submission_titanic.csvother2.8 KB
modules/badges/scripts/templates/utility_script.pyscript802 B
modules/badges/scripts/utils.pyscript3.9 KB
modules/benchmarks/README.mdmarkdown1.2 KB
modules/benchmarks/references/benchmark-endpoints.mdmarkdown1.6 KB
modules/benchmarks/references/benchmarks-cli.mdmarkdown4.4 KB
modules/competitions/README.mdmarkdown5.8 KB
modules/competitions/hackathons/README.mdmarkdown2.9 KB
modules/competitions/hackathons/references/episode-endpoints.mdmarkdown2.2 KB
modules/competitions/hackathons/references/hackathon-endpoints.mdmarkdown4.6 KB
modules/competitions/hackathons/scripts/fetch_writeup.pyexecutablescript10.5 KB
modules/competitions/hackathons/scripts/hackathon_overview.pyexecutablescript1.5 KB
modules/competitions/hackathons/scripts/list_writeups.pyexecutablescript9.9 KB
modules/competitions/references/competition-categories.mdmarkdown2.1 KB
modules/competitions/references/competition-operations.mdmarkdown5.7 KB
modules/competitions/references/competition-overview.mdmarkdown3.9 KB
modules/competitions/references/competition-research.mdmarkdown3.0 KB
modules/competitions/scripts/competition_brief.pyscript5.4 KB
modules/competitions/scripts/competition_details.pyscript8.2 KB
modules/competitions/scripts/competition_download.pyscript5.1 KB
modules/competitions/scripts/competition_episodes.pyscript9.2 KB
modules/competitions/scripts/competition_leaderboard.pyscript12.3 KB
modules/competitions/scripts/competition_ledger.pyscript3.3 KB
modules/competitions/scripts/competition_pages.pyexecutablescript1.7 KB
modules/competitions/scripts/competition_status.pyscript9.0 KB
modules/competitions/scripts/competition_submit.pyscript8.9 KB
modules/competitions/scripts/competition_validate.pyscript14.2 KB
modules/competitions/scripts/competition_watch.pyscript5.9 KB
modules/competitions/scripts/list_competitions.pyscript13.3 KB
modules/datasets/README.mdmarkdown2.1 KB
modules/datasets/references/kagglehub-datasets.mdmarkdown2.6 KB
modules/datasets/scripts/dataset_download.pyscript4.1 KB
modules/datasets/scripts/dataset_publish.pyscript5.5 KB
modules/discussions/README.mdmarkdown2.1 KB
modules/discussions/references/writeups.mdmarkdown5.8 KB
modules/discussions/scripts/forums.pyscript22.0 KB
modules/discussions/scripts/leaderboard_writeups.pyscript24.8 KB
modules/models/README.mdmarkdown2.6 KB
modules/models/references/kagglehub-models.mdmarkdown1.7 KB
modules/models/scripts/model_download.pyscript4.5 KB
modules/models/scripts/model_publish.pyscript8.7 KB
modules/notebooks/README.mdmarkdown2.6 KB
modules/notebooks/scripts/notebook_push.pyscript5.7 KB
modules/notebooks/scripts/notebook_run.pyscript2.8 KB
modules/notebooks/scripts/notebook_wait.pyscript3.7 KB
modules/references/README.mdmarkdown454 B
modules/references/cli-reference.mdmarkdown13.4 KB
modules/references/kaggle-knowledge.mdmarkdown7.6 KB
modules/references/mcp-reference.mdmarkdown18.9 KB
modules/setup/README.mdmarkdown3.0 KB
modules/setup/references/kaggle-setup.mdmarkdown6.7 KB
modules/setup/scripts/check_all_credentials.pyscript5.7 KB
modules/setup/scripts/doctor.pyscript10.2 KB
modules/setup/scripts/save_credentials.pyscript3.9 KB
scripts/kaggle_skill.pyscript11.5 KB
shared/__init__.pyscript0 B
shared/competition.pyscript20.0 KB
shared/credentials.pyscript9.6 KB
shared/hub.pyscript2.9 KB
shared/kaggle_cli.pyscript20.7 KB
shared/ledger.pyscript3.6 KB
shared/mcp_client.pyscript11.6 KB
shared/net.pyscript6.9 KB
shared/notebook.pyscript4.4 KB
shared/preflight.pyscript5.1 KB
shared/safe_extract.pyscript2.7 KB
shared/script.pyscript11.2 KB
shared/text.pyscript10.5 KB
shared/untrusted.pyscript7.6 KB

modules/badges/scripts/phase_3_pipeline.py

View on GitHub
"""Phase 3: Pipeline badges (3 badges).

Earns badges that require KKB notebook execution and output:
  - Dataset Pipeline Creator (create dataset from notebook output)
  - Model Pipeline Creator (create model from notebook output)
  - R Markdown Coder (push and execute R Markdown on KKB)

These badges require notebooks to execute on Kaggle Kernel Backend (KKB),
so there is a polling/waiting step.
"""

import json
import time

from badge_tracker import set_status, should_attempt
from utils import (
    kernel_status,
    make_temp_dir,
    resource_name,
    run_kaggle_cli,
)


def _poll_kernel(username: str, kernel_slug: str, timeout: int = 600, interval: int = 30) -> bool:
    """Poll a kernel until it completes or times out."""
    full_slug = f"{username}/{kernel_slug}"
    elapsed = 0

    while elapsed < timeout:
        # Only the status word is read, so a slug that contains "complete" or
        # "error" cannot be mistaken for the status.
        status = kernel_status(full_slug)
        print(f"    [{elapsed}s] Status: {status or 'unknown'}")

        if status == "COMPLETE":
            return True
        if status == "ERROR" or status.startswith("CANCEL"):
            return False

        time.sleep(interval)
        elapsed += interval

    print(f"    [TIMEOUT] Kernel did not complete within {timeout}s")
    return False


def _dataset_pipeline(username: str) -> bool:
    """Create a notebook that outputs a dataset, then create a dataset from that output.

    Earns: Dataset Pipeline Creator.
    """
    if not should_attempt("dataset_pipeline_creator"):
        return True

    set_status("dataset_pipeline_creator", "attempting")
    try:
        tmp = make_temp_dir("-ds-pipeline")
        nb_slug = resource_name("ds-pipeline-nb")

        # Create a notebook that generates a CSV output
        notebook_content = {
            "cells": [
                {
                    "cell_type": "code",
                    "execution_count": None,
                    "metadata": {},
                    "outputs": [],
                    "source": [
                        "import pandas as pd\n",
                        "\n",
                        "# Generate output data\n",
                        "data = pd.DataFrame({\n",
                        "    'x': range(1, 11),\n",
                        "    'y': [i**2 for i in range(1, 11)],\n",
                        "    'label': ['even' if i%2==0 else 'odd' for i in range(1, 11)]\n",
                        "})\n",
                        "\n",
                        "# Save to output\n",
                        "data.to_csv('output_data.csv', index=False)\n",
                        "print(f'Output shape: {data.shape}')\n",
                        "print(data.head())\n",
                    ],
                }
            ],
            "metadata": {
                "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"},
                "language_info": {"name": "python", "version": "3.10.0"},
            },
            "nbformat": 4,
            "nbformat_minor": 4,
        }
        (tmp / "notebook.ipynb").write_text(json.dumps(notebook_content, indent=2))

        metadata = {
            "id": f"{username}/{nb_slug}",
            "title": nb_slug,
            "code_file": "notebook.ipynb",
            "language": "python",
            "kernel_type": "notebook",
            "is_private": True,
            "enable_gpu": False,
            "enable_tpu": False,
            "enable_internet": False,
            "keywords": ["kaggle-badges", "pipeline", "dataset"],
            "dataset_sources": [],
            "kernel_sources": [],
            "competition_sources": [],
            "model_sources": [],
        }
        (tmp / "kernel-metadata.json").write_text(json.dumps(metadata, indent=2))

        # Push notebook to KKB
        run_kaggle_cli(["kernels", "push", "-p", str(tmp)])
        print(f"  [OK] Pipeline notebook pushed: {nb_slug}")
        print("  Waiting for KKB execution to complete...")

        # Poll for completion
        if not _poll_kernel(username, nb_slug):
            print("  [FAIL] Notebook execution failed or timed out")
            set_status("dataset_pipeline_creator", "failed", "KKB execution failed")
            return False

        # Download notebook output
        output_dir = make_temp_dir("-ds-pipeline-output")
        run_kaggle_cli(
            [
                "kernels",
                "output",
                f"{username}/{nb_slug}",
                "--path",
                str(output_dir),
            ]
        )

        # Create a dataset from the output
        ds_slug = resource_name("pipeline-dataset")
        ds_metadata = {
            "title": ds_slug,
            "id": f"{username}/{ds_slug}",
            "licenses": [{"name": "CC0-1.0"}],
            "keywords": ["kaggle-badges", "pipeline"],
            "resources": [{"path": "output_data.csv", "description": "Pipeline output"}],
            "description": f"Dataset created from notebook output ({nb_slug})",
        }
        (output_dir / "dataset-metadata.json").write_text(json.dumps(ds_metadata, indent=2))

        run_kaggle_cli(["datasets", "create", "-p", str(output_dir)])
        print(f"  [OK] Pipeline dataset created: {ds_slug}")
        set_status(
            "dataset_pipeline_creator", "earned", f"dataset={ds_slug} from notebook={nb_slug}"
        )
        return True

    except Exception as e:
        print(f"  [FAIL] Dataset pipeline: {e}")
        set_status("dataset_pipeline_creator", "failed", str(e))
        return False


def _model_pipeline(username: str) -> bool:
    """Create a notebook that outputs a model, then create a model from that output.

    Earns: Model Pipeline Creator.
    """
    if not should_attempt("model_pipeline_creator"):
        return True

    set_status("model_pipeline_creator", "attempting")
    try:
        tmp = make_temp_dir("-model-pipeline")
        nb_slug = resource_name("model-pipeline-nb")

        # Create a notebook that trains and saves a simple model
        notebook_content = {
            "cells": [
                {
                    "cell_type": "code",
                    "execution_count": None,
                    "metadata": {},
                    "outputs": [],
                    "source": [
                        "import json\n",
                        "\n",
                        "# Create a simple 'model' (just config/weights as JSON)\n",
                        "model = {\n",
                        "    'type': 'linear',\n",
                        "    'weights': [0.5, -0.3, 0.8],\n",
                        "    'bias': 0.1,\n",
                        "    'features': ['x1', 'x2', 'x3']\n",
                        "}\n",
                        "\n",
                        "with open('model.json', 'w') as f:\n",
                        "    json.dump(model, f, indent=2)\n",
                        "\n",
                        "print('Model saved to model.json')\n",
                        "print(json.dumps(model, indent=2))\n",
                    ],
                }
            ],
            "metadata": {
                "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"},
                "language_info": {"name": "python", "version": "3.10.0"},
            },
            "nbformat": 4,
            "nbformat_minor": 4,
        }
        (tmp / "notebook.ipynb").write_text(json.dumps(notebook_content, indent=2))

        metadata = {
            "id": f"{username}/{nb_slug}",
            "title": nb_slug,
            "code_file": "notebook.ipynb",
            "language": "python",
            "kernel_type": "notebook",
            "is_private": True,
            "enable_gpu": False,
            "enable_tpu": False,
            "enable_internet": False,
            "keywords": ["kaggle-badges", "pipeline", "model"],
            "dataset_sources": [],
            "kernel_sources": [],
            "competition_sources": [],
            "model_sources": [],
        }
        (tmp / "kernel-metadata.json").write_text(json.dumps(metadata, indent=2))

        # Push notebook
        run_kaggle_cli(["kernels", "push", "-p", str(tmp)])
        print(f"  [OK] Model pipeline notebook pushed: {nb_slug}")
        print("  Waiting for KKB execution to complete...")

        if not _poll_kernel(username, nb_slug):
            print("  [FAIL] Notebook execution failed or timed out")
            set_status("model_pipeline_creator", "failed", "KKB execution failed")
            return False

        # Download output
        output_dir = make_temp_dir("-model-pipeline-output")
        run_kaggle_cli(
            [
                "kernels",
                "output",
                f"{username}/{nb_slug}",
                "--path",
                str(output_dir),
            ]
        )

        # Create model from output
        model_slug = resource_name("pipeline-model")
        model_meta = {
            "ownerSlug": username,
            "title": model_slug,
            "slug": model_slug,
            "subtitle": f"Model from notebook pipeline ({nb_slug})",
            "isPrivate": True,
            "description": "Model created from notebook output via pipeline.",
            "publishTime": "",
            "provenanceSources": "",
        }
        (output_dir / "model-metadata.json").write_text(json.dumps(model_meta, indent=2))

        run_kaggle_cli(["models", "create", "-p", str(output_dir)])
        print(f"  [OK] Pipeline model created: {model_slug}")
        set_status(
            "model_pipeline_creator", "earned", f"model={model_slug} from notebook={nb_slug}"
        )
        return True

    except Exception as e:
        print(f"  [FAIL] Model pipeline: {e}")
        set_status("model_pipeline_creator", "failed", str(e))
        return False


def _r_markdown(username: str) -> bool:
    """Push an R Markdown document to earn R Markdown Coder."""
    if not should_attempt("r_markdown_coder"):
        return True

    set_status("r_markdown_coder", "attempting")
    try:
        tmp = make_temp_dir("-rmd")
        nb_slug = resource_name("r-markdown")

        rmd_content = """---
title: "Iris summary"
output: html_document
---

```{r}
library(datasets)
data(iris)
summary(iris)
```

```{r}
aggregate(. ~ Species, data = iris, FUN = mean)
```
"""
        (tmp / "script.Rmd").write_text(rmd_content)

        metadata = {
            "id": f"{username}/{nb_slug}",
            "title": nb_slug,
            "code_file": "script.Rmd",
            "language": "rmarkdown",
            "kernel_type": "script",
            "is_private": True,
            "enable_gpu": False,
            "enable_tpu": False,
            "enable_internet": False,
            "keywords": ["r", "rmarkdown", "data-analysis"],
            "dataset_sources": [],
            "kernel_sources": [],
            "competition_sources": [],
            "model_sources": [],
        }
        (tmp / "kernel-metadata.json").write_text(json.dumps(metadata, indent=2))

        run_kaggle_cli(["kernels", "push", "-p", str(tmp)])
        print(f"  [OK] R Markdown document pushed: {nb_slug}")
        set_status("r_markdown_coder", "earned", f"notebook={nb_slug}")
        return True

    except Exception as e:
        print(f"  [FAIL] R Markdown: {e}")
        set_status("r_markdown_coder", "failed", str(e))
        return False


def run(username: str) -> tuple[int, int]:
    """Run all Phase 3 badge actions. Returns (attempted, succeeded)."""
    actions = [
        ("Dataset pipeline", _dataset_pipeline),
        ("Model pipeline", _model_pipeline),
        ("R Markdown", _r_markdown),
    ]

    attempted = 0
    succeeded = 0

    for name, fn in actions:
        print(f"\n  --- {name} ---")
        attempted += 1
        if fn(username):
            succeeded += 1

    return attempted, succeeded
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall