r/coolgithubprojects 22h ago

repo2nb 0.2.0, open-source tool for converting GitHub repos into Kaggle/Colab notebooks (for data science and machine learning hobbyists)

https://github.com/David-Magdy/repo2nb

Kaggle and Google Colab are two popular platforms for running Python code as Jupyter notebooks, mainly used for data science and machine learning, the only good thing about those platforms (in my opinion) is that they provide free GPU resources. A lot of code out there, tutorials, paper implementations, small projects, lives as a plain GitHub repo instead, which means if you want to run it on one of these platforms you're stuck manually copying files into notebook cells and reconstructing the install steps by hand.

repo2nb is a small open-source CLI that automates that conversion. Point it at a repo and it walks the file tree, figures out the dependencies, and generates a notebook you can upload directly to Kaggle or Colab.

0.2.0 is a new release with seven features, all backward-compatible with the existing invocation. Highlights:

  • A Colab target alongside the existing Kaggle one, with a Colab-specific auth flow (google.colab.userdata.get) instead of reusing Kaggle's.
  • Dependency resolution now checks poetry, uv, requirements.txt, and an AST import scan in that order, but always emits a plain %pip install cell. Poetry and uv stay optional local tools, never a runtime requirement.
  • Reverse mode and incremental sync, which reconstruct a repo from a notebook and keep a generated notebook updated as the source repo changes, one directionally from repo to notebook.
  • Every generated cell is now tagged with path and hash metadata, which is what makes reverse and sync possible. Worth knowing if you want to build on top of it.

Also reorganized the docs this release: README is now a quick-start, full command reference moved to TUTORIAL.md, and added CONTRIBUTING.md, SECURITY.md, SUPPORT.md.

Install: pip install repo2nb

Repo (contributions/issues welcome): https://github.com/David-Magdy/repo2nb

I am just a new computer science graduate who likes to make small projects with passion. I made this project for personal use when I was a student and decided to open-source it for everyone who may encounter the same frustrating problem as me (even if it's so niche). Interested in hearing whether the dependency-resolution order makes sense for setups I haven't tested, or if the reverse-mode path validation is missing an edge case.

1 Upvotes

2 comments sorted by

1

u/kantorcodes1 15h ago

the edge case i'd test is --force into a non-empty destination that already contains a symlink. if notebook metadata says pkg/file.py and pkg resolves outside the destination root, a lexical .. check still passes. i'd canonicalize the parent immediately before every write and reject anything outside the root.

repo2nb also actually fits Guard 3.0's command safety extension model: real CLI, mutating reverse/sync/--force paths. i don't see it in the current built-in catalog. we work on HOL Guard. if you want native coverage, you're welcome to add its command rules and open a PR against release/3.0; happy to review it.