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/models/scripts/model_download.py

View on GitHub
#!/usr/bin/env python3
"""Download a Kaggle model.

    model_download.py owner/model/framework/variation            the latest version
    model_download.py owner/model/framework/variation/3 ./model
    model_download.py owner/model/framework/variation/3 --via cli

By default kagglehub does the download: the four-part handle fetches the
latest version, a fifth part names one, and the files are cached under
~/.cache/kagglehub. The folder you give must be new or empty, because
kagglehub deletes what is in a folder before it downloads into it.

--via cli uses the Kaggle CLI. It needs a credential and the version number as
the fifth part, and it leaves the archive as downloaded (.tar.gz): kaggle
2.2.4 extracts tar files without a path check. List the versions with
`kaggle models variations versions list owner/model/framework/variation`.

Exit status: 0 downloaded, 1 the download failed, 2 wrong arguments or no
credential, 5 refused because the folder is not empty, 127 the tool is not
installed.
"""

from __future__ import annotations

import argparse
import sys
from pathlib import Path

SKILL_ROOT = Path(__file__).resolve().parents[3]
sys.path.insert(0, str(SKILL_ROOT))

from shared import credentials, hub, kaggle_cli, script  # noqa: E402


def download_with_kagglehub(
    handle: str, file: str | None = None, folder: str | None = None, force: bool = False
) -> str:
    """Download a model, or one file of it. Returns the local path."""
    kagglehub = hub.load()
    kwargs: dict = {"force_download": force}
    if file:
        kwargs["path"] = file
    if folder:
        kwargs["output_dir"] = folder
    return kagglehub.model_download(handle, **kwargs)


def download_with_cli(handle: str, folder: str | None, force: bool = False) -> int:
    if script.is_handle(handle, 4):
        return script.fail(
            "with --via cli the handle needs a version: owner/model/framework/variation/3. "
            "Without --via cli the latest version is downloaded",
            script.EXIT_USAGE,
        )
    if not script.is_handle(handle, 5) or not handle.rsplit("/", 1)[-1].isdigit():
        return script.fail(
            "the handle is owner/model/framework/variation/version", script.EXIT_USAGE
        )
    if not kaggle_cli.installed():
        return script.missing_package("kaggle", "--via cli")
    if credentials.resolve() is None:
        return script.no_credential("the Kaggle CLI")
    target = Path(folder or Path("downloads") / handle.replace("/", "-"))
    target.mkdir(parents=True, exist_ok=True)
    cli_args = ["models", "variations", "versions", "download", handle, "--path", str(target)]
    cli_args += ["--quiet", *(["--force"] if force else [])]
    status = kaggle_cli.run_wrapped(cli_args, tool="models.download")
    if status != 0:
        return status
    kaggle_cli.print_folder(target)
    return script.EXIT_OK


def main(argv: list[str] | None = None) -> int:
    parser = argparse.ArgumentParser(
        description="Download a Kaggle model.",
        epilog="A public model needs no credential with kagglehub, the default.",
    )
    parser.add_argument("handle", help="owner/model/framework/variation, optionally /version")
    parser.add_argument("dir", nargs="?", help="Folder to download into")
    parser.add_argument("--output-dir", dest="dir_opt", help=argparse.SUPPRESS)
    parser.add_argument("--file", "--path", dest="file", metavar="NAME", help="Only this file")
    parser.add_argument("--force", action="store_true", help="Download again even if cached")
    parser.add_argument(
        "--via",
        choices=("kagglehub", "cli"),
        default="kagglehub",
        help="The tool that downloads (default: kagglehub)",
    )
    args = script.parse(parser, argv)
    folder = args.dir or args.dir_opt

    credentials.load_configured_env_file()
    if args.via == "cli":
        if args.file:
            return script.fail(
                "--file works with kagglehub only; the CLI downloads the whole version",
                script.EXIT_USAGE,
            )
        return download_with_cli(args.handle, folder, args.force)

    status = hub.check_output_dir(folder, args.file, args.force)
    if status:
        return status
    try:
        local_path = download_with_kagglehub(args.handle, args.file, folder, args.force)
    except Exception as exc:  # noqa: BLE001 - kagglehub raises many types; none should traceback
        return hub.fail("model_download", exc)
    print(f"Model downloaded to: {local_path}")
    return script.EXIT_OK


if __name__ == "__main__":
    sys.exit(main())
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