Skip to main content

Run any Jupyter notebook on Kaggle kernels instantly

Project description

kernel-run 🔥🚀

Instantly create and run a Kaggle kernel from any Jupyter notebook (local file or URL).

$ kernel-run path/to/notebook.ipynb
Kernel created successfully: https://www.kaggle.com/aakashns/kr-notebook/edit

$ kernel-run http://cs231n.stanford.edu/notebooks/pytorch_tutorial.ipynb
Kernel created successfully: https://www.kaggle.com/aakashns/kr-pytorch-tutorial/edit

kernel-run uploads the Jupyter notebook to a private kernel in your Kaggle account, and launches a browser window so you can start editing/executing the code immediately.

Installation

pip install kernel-run --upgrade

The above command install a command-line tool called kernel-run which can be invoked from the terminal/command prompt.

Note: To allow kaggle-run to upload the notebook to your Kaggle account, you need to download the Kaggle API credentials file kaggle.json. To download the kaggle.json file:

  1. Go to https://kaggle.com
  2. Log in and go to your account page
  3. Click the "Create New API Token" button in the "API" section
  4. Move the downloaded kaggle.json file to the folder ~/.kaggle/

CLI Usage & Options

Run the kernel-run command on your terminal/command prompt with a Jupyter notebook's path (or URL) as the argument:

$ kernel-run path/to/notebook.ipynb
Kernel created successfully: https://www.kaggle.com/aakashns/kr-notebook/edit

$ kernel-run http://cs231n.stanford.edu/notebooks/pytorch_tutorial.ipynb
Kernel created successfully: https://www.kaggle.com/aakashns/kr-pytorch-tutorial/edit

There are various options you can configure. Run kernel-run -h to see the options:

usage: kernel-run notebook_path_or_url [-h] [--public] [--new] [--no-browser] [--strip-output] [--prefix PREFIX]

positional arguments:
  notebook_path_or_url  Path/URL of the Jupyter notebook

optional arguments:
  -h, --help            show this help message and exit
  --public              Create a public kernel
  --new                 Create a new kernel, if a kernel with the same name exists
  --no-browser          Don't open a browser window automatically
  --strip-output        Clear output cells before uploading notebook (useful for large files)
  --prefix PREFIX       Prefix added to kernel title to easy identification (defaults to 'kr/')

Python API

You can also use the library form a Python script or Jupyter notebook. It can be imported as kernel_run.

from kernel_run import create_kernel

create_kernel()

The arguments to create_kernel are identical to the CLI options:

def create_kernel(path_or_url, public=False, no_browser=False, new=False,
                  strip_output=False, prefix=DEFAULT_PREFIX, creds_path=None):
    """Instantly create and run a Kaggle kernel from a Jupyter notebook (local file or URL)

    Arguments:
        path_or_url (string): Path/URL to the Jupyter notebook
        public (bool, optional): If true, creates a public kernel. A private kernel
            is created by default.
        no_browser (bool, optional): If true, does not attempt to automatically open
            a browser tab to edit the created Kernel
        new (bool, optional): If true, creates a new Kernel by adding a random
            5-letter string at the end of the title
        prefix (string, optional): A prefix added to the Kernel title, to indicate that
            the Kernel was created using kernel-run
        creds_path (string, optional): Path to the 'kaggle.json' credentials file
            (defaults to '~/.kaggle/kaggle.json')
        strip_output (bool, optional): Clear output cells before uploading notebook.
    """

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kernel-run-0.0.6.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kernel_run-0.0.6-py2-none-any.whl (8.3 kB view details)

Uploaded Python 2

File details

Details for the file kernel-run-0.0.6.tar.gz.

File metadata

  • Download URL: kernel-run-0.0.6.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for kernel-run-0.0.6.tar.gz
Algorithm Hash digest
SHA256 daef2029a888cf47943bb8701550d86b5ea40725e9be7693d552f0f8e682e056
MD5 d4473f7ff209bd6b2c689f59c2597824
BLAKE2b-256 5fc95ba64140a7b276c57489bc5a58eed962cfbed09c7dc6935bda199b7c5e17

See more details on using hashes here.

File details

Details for the file kernel_run-0.0.6-py2-none-any.whl.

File metadata

  • Download URL: kernel_run-0.0.6-py2-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for kernel_run-0.0.6-py2-none-any.whl
Algorithm Hash digest
SHA256 52b02021725c686ee47e09ec0b3ef30adc86b36edafaa779255cc3de3ce7c71e
MD5 d9e0fce2937204b1162369950399092e
BLAKE2b-256 e9f4f6d6cfd4628fe56c20b8a0fe2dadfc0bbccb339fe57119e8e5dce8d266d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page