Skip to main content

Convert a local code repository into a Kaggle-ready Jupyter notebook

Project description

repo2nb

repo2nb

repo2nb is an open-source Python CLI tool that converts a local code repository into a self-contained Jupyter notebook (.ipynb) designed natively to run on Kaggle's free GPU environment.

It reconstructs your entire repo in Kaggle's /kaggle/working directory using Python's %%writefile magic cells, and integrates git for version control so you can pull, test, and push fixes back to your remote repository without ever leaving the Kaggle interface.

Motivation

This is a tool I made for personal use first, then I wanted to publish it.

My motivation was that I wanted to securely run a training repo on Kaggle, but it was scattered across directories and Python files. It is extremely frustrating copying all of this into a notebook and debugging why it's giving an error.

I used to do workarounds like uploading the repo as a dataset and starting from there. It was exhausting and wasted a couple of minutes just to realize I missed an indented line! Attempting the same flow manually using git for authenticating myself, pushing, and pulling for simple microscopic changes, which was equally painful. repo2nb automates all of this seamlessly.

Heads Up: This project is intended for personal and academic projects. It is specifically designed for students and hobbyists like myself who want to quickly leverage free GPU compute without friction, rather than managing massive corporate repositories with hundreds of nested files!

Installation

pip install repo2nb

Usage

# Convert your local project to a Kaggle notebook
repo2nb ./my_project --output my_project_kaggle.ipynb

Then literally just upload the resulting .ipynb file to Kaggle!

Options

  • --output, -o: Specify the output notebook path. Defaults to <folder_name>.ipynb.
  • --omit-instructions: Omits the beginner-friendly warning cells and instructional git cheat sheets. Perfect for power users who already know the setup routine.
  • --ignore-extra: Provide extra file extensions to ignore entirely (e.g., --ignore-extra ".yaml .json"). These files will be completely omitted from the generated notebook.
  • --include: Force include specific file extensions that are usually skipped as binary/data (e.g., --include ".csv .json").

Features

  • Instant Rebuild: Automatically translates your local file tree into correctly ordered %%writefile blocks.
  • Git Integration: Injects pre-formatted shell cells for initializing Git, adding tokens, selecting branches, pulling, and pushing.
  • Smart Filtering: Automatically skips cached data, virtual environments (.venv), uv lock files, heavy binaries (.pt, .pkl, .jpg), and dataset files (.csv, .parquet) so your final notebook remains incredibly lightweight.
  • Visual Segregation: Creates unmissable structural phases isolating where the automatic repo build ends and where your actual coding workspace begins.
  • Built-in Git Cheat Sheet: Gives you immediate interactive access to git status, git rm -rf, and git mv blocks directly in the UI.

Important Conventions & Security

Security & Publishing: repo2nb uses Kaggle's native secrets manager to inject your GitHub token at runtime. Your token is never hardcoded, never visible in cell output, and the notebook remains safe to share publicly. Additionally, ensure that Kaggle's .virtual_documents directory is added to your .gitignore before pushing any changes to avoid leaking Kaggle's system files into your repo.

Run All Only Once: When you first start your Kaggle session, use "Run All" to bootstrap the directory structure and recreate the files. After the initial setup, run cells individually as needed. Using "Run All" again may overwrite any local manual code changes you have made that session!

Branch Management: The notebook's git hooks default to main. The generated code blocks remind you to swap "main" for your target branch name if you are pulling or committing to a different branch.

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

repo2nb-0.1.1.tar.gz (738.1 kB view details)

Uploaded Source

Built Distribution

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

repo2nb-0.1.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file repo2nb-0.1.1.tar.gz.

File metadata

  • Download URL: repo2nb-0.1.1.tar.gz
  • Upload date:
  • Size: 738.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for repo2nb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 43471938c2bc6d9586b0ee521c72c25075c3df4bbd6db9fab876da4c122cca79
MD5 1d477eb53a7758f4327675558502bd71
BLAKE2b-256 c38eb6522c3462d2e3d7a79a8616de1872a06c873a52bdf4af706581860a6844

See more details on using hashes here.

File details

Details for the file repo2nb-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: repo2nb-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for repo2nb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 991ccf1441c72dec192488f01830f76290b00132b4a49b2a17fef9d15fc5d746
MD5 9b924edc92a5330450997754a5014707
BLAKE2b-256 d2980f73d8b256d17fbb5eeff9bf1f8981dd5e788c85d4d0946396183665ef54

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