shepsci/kaggle-skill / skills/kaggle
kaggle
FlaggedUnified 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.
shared/hub.py
View on GitHub"""Shared setup for the scripts that call kagglehub.
kagglehub is a library, so the checks that CLI-backed commands get from
``kaggle_cli.py`` are done here: the environment is cleaned, the library's
log lines (which carry file names from the server) are switched off, an
output folder is never emptied by accident, and a failure is reported without
a traceback.
"""
from __future__ import annotations
import os
import sys
from pathlib import Path
from typing import Any
if __package__ in (None, ""):
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from shared import credentials, kaggle_cli, script, untrusted # noqa: E402
EXIT_FAILED = script.EXIT_FAILED
EXIT_REFUSED = script.EXIT_REFUSED
def load() -> Any:
"""Import kagglehub with a clean environment.
Exits with status 127 and the install command when it is not installed.
"""
credentials.load_configured_env_file()
kaggle_cli.scrub_process_env()
# At its default level kagglehub logs "Downloading to <path>" on standard
# output, with file names chosen by the uploader.
os.environ.setdefault("KAGGLEHUB_VERBOSITY", "error")
try:
import kagglehub # type: ignore
except ModuleNotFoundError:
script.missing_package("kagglehub", "this command; or add --via cli to use the Kaggle CLI")
raise SystemExit(script.EXIT_NOT_INSTALLED) from None
return kagglehub
def check_output_dir(output_dir: str | None, path: str | None, force: bool) -> int:
"""Refuse a download that would delete files in ``output_dir``.
kagglehub empties a non-empty output folder when it is asked to download
again, so ``--output-dir . --force`` would wipe the working directory.
Returns 0 when the download may go ahead.
"""
if not output_dir:
return 0
target = Path(output_dir)
if target.is_file():
print("error: --output-dir points to a file, not a folder", file=sys.stderr)
return 2
if path:
# One file: kagglehub replaces only that file, and only with --force.
if (target / path).exists() and not force:
print(
"error: that file is already in --output-dir; pass --force to replace it",
file=sys.stderr,
)
return EXIT_FAILED
return 0
if target.is_dir() and any(target.iterdir()):
print(
"error: --output-dir is not empty. kagglehub would delete what is in it, so the\n"
" download was not started. Choose a new or empty folder.",
file=sys.stderr,
)
return EXIT_REFUSED
return 0
def fail(action: str, exc: BaseException) -> int:
"""Report a kagglehub failure. The message can quote the server, so it is wrapped."""
print(f"error: {action} failed ({type(exc).__name__})", file=sys.stderr)
untrusted.emit_text(
str(exc) or "(no message)", source="kagglehub", tool=action, file=sys.stderr
)
return EXIT_FAILED
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 119k | Updated | Claude CodeCodex | Verified | Install |
| 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: 119k | Updated | Claude CodeCodex | Verified | Install |
| 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: 118k | Updated | Claude CodeCodex | Verified | Install |
| 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: 118k | Updated | Claude CodeCodex | Verified | Install |