Skip to main content

kagglex

Execute local Python code, modules, and experiments seamlessly on Kaggle GPUs and TPUs.

Overview

kagglex enables machine learning practitioners and researchers to transparently package and dispatch local Python code, standalone scripts, or complete packages to Kaggle's cloud GPU and TPU environments without tedious manual uploading or notebook maintenance.

Features

  • Flexible project detection for standalone scripts, flat packages, or src/ layout projects
  • Pre-flight validation with local AST syntax checking and credential verification
  • Automatic ignore filtering powered by pathspec supporting .gitignore and .kaggleignore
  • Dual-tier packaging preventing bloated uploads and base64 truncation
  • Automated multi-GPU execution using torchrun
  • Secure Kaggle Secrets integration for WandB, HuggingFace, and custom credentials
  • Local experiment history repository for tracking past runs, statuses, and durations
  • Interactive REPL execution on active Kaggle notebooks via Jupyter proxy URL
  • Programmatic Python SDK alongside the kagglex CLI

Installation

Install via uv or pip:

uv pip install kagglex

CLI Usage

Run a Standalone Script

kagglex run --file train.py --gpu t4-2x --title "Pilot Training"

Run a Module with Multi-GPU

kagglex run "python -m mypkg.train --epochs 10" --gpu t4-2x --multi-gpu

Stream Remote Logs in Real-Time

kagglex run "python train.py" --stream

List Recent Runs

kagglex list

Check Status or Cancel a Run

kagglex status my-experiment
kagglex cancel my-experiment

Note: Kaggle's public API does not support programmatic session cancellation for running kernels. kagglex cancel marks the local run record as cancelled and provides the direct Kaggle URL to stop the session in the web interface.

Pull Downloaded Outputs

kagglex pull my-experiment --output-dir ./results --include-outputs "*.json" "checkpoints/*"

Push a Kaggle Dataset

kagglex dataset push --data-dir ./data/embeddings --title "Embeddings Dataset"

Auto-Dataset Payload Offloading

When your project files or local assets exceed the inline payload limit (5 MB), automatically stage and upload them as a private Kaggle dataset:

kagglex run --file train.py --auto-dataset

Inspect GPU and TPU Quota Usage

Track your rolling 7-day accelerator consumption against Kaggle's weekly quotas (30 GPU hours / 20 TPU hours):

kagglex quota --days 7

Because Kaggle's public API does not expose an endpoint to query remaining weekly quota balances, kagglex computes usage locally from run records in .kagglex/runs.json over a configurable rolling window (default: 7 days). Limit thresholds can be configured via --gpu-limit / --tpu-limit or in pyproject.toml.

Declarative Configuration

Define project defaults in pyproject.toml or kagglex.toml to avoid repetitive CLI arguments:

# pyproject.toml
[tool.kagglex]
gpu = "t4-2x"
multi_gpu = true
kaggle_secrets = ["WANDB_API_KEY", "HF_TOKEN"]
datasets = ["username/my-dataset"]
include_outputs = ["*.json", "checkpoints/*"]

[tool.kagglex.env]
WANDB_PROJECT = "my-experiment"

Then simply run:

kagglex run --file train.py

Interactive REPL on Running Kaggle Notebooks

When a notebook is already open in Kaggle, copy its proxy URL (Run -> Kaggle Jupyter Server -> Copy URL) and run commands with sub-second feedback:

# Verify connection
kagglex exec --url "https://kkb-production.jupyter-proxy.kaggle.net?token=..." --test

# Query remote GPU status
kagglex exec --url "https://kkb-production.jupyter-proxy.kaggle.net?token=..." --gpu-info

# Execute inline Python snippets
kagglex exec "import torch; print(torch.cuda.device_count())"

# Execute a local Python file remotely
kagglex exec --file evaluate.py

# List and transfer files
kagglex exec --list-files
kagglex exec --upload ./checkpoint.pt
kagglex exec --download run_results.json -o ./local_results.json

Alternatively, set the environment variable:

export KAGGLE_JUPYTER_URL="https://kkb-production.jupyter-proxy.kaggle.net?token=..."

Python SDK Usage

from kagglex import KaggleRunner, RunConfig

runner = KaggleRunner()
job = runner.run(
    command="python -m mypkg.train --batch-size 64",
    title="Fine Tuning Run",
    gpu="t4-2x",
    multi_gpu=True,
    wait=True,
)

print(f"Status: {job.status}")
job.pull_outputs(destination_dir="./results")

Metadata

Release files for kagglex 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kagglex 0.3.0
File Size Uploaded
kagglex-0.3.0.tar.gz 168.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kagglex 0.3.0
File Interpreter ABI Platform
kagglex-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 208.6 kB

Release files / kagglex-0.3.0.tar.gz

Download URL kagglex-0.3.0.tar.gz
Size 168.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8bf5c4d66bcc3fa8123aa7965392c7848cc6759c26385857d05f9b50376499e4
BLAKE2b-256 checksum
How to use checksums
cc3632c7714f34afd96411ad61708046e4f646cf221a41f8cdea7e563df27dc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release files / kagglex-0.3.0-py3-none-any.whl

Download URL kagglex-0.3.0-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6fc339294afcf4b4d4c4ed3dc93d58baa7b5b32a94452c8545d59390cab3e92
BLAKE2b-256 checksum
How to use checksums
4973d13df4780562fb8cd45da62167e4a22ae1d377c326029e7ad86e11d76a95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page