2 min readfrom Machine Learning

repo2nb 0.2.0, convert a GitHub repo into a Kaggle/Colab notebook (dependency resolution, reverse mode, incremental sync) [P]

Our take

Introducing repo2nb 0.2.0, an open-source CLI designed to streamline your data workflow. This tool intelligently converts GitHub repositories into runnable Kaggle or Colab notebooks, automating dependency resolution—prioritizing Poetry, UV, and requirements.txt before falling back to an AST import scan. Key updates include reverse mode for repo reconstruction, incremental syncing for efficient updates, and a dedicated Colab target with authentication. Install via `pip install repo2nb` and explore the possibilities; we're particularly interested in validating the dependency resolution order.

The open-source tool repo2nb, recently updated to version 0.2.0, addresses a persistent pain point for anyone working with research code or tutorials: the tedious process of transforming a GitHub repository into a runnable notebook environment like Kaggle or Colab. It's a problem we’ve seen echoed in discussions about coding practices [What coding practices are you adopting for development today?] and the challenges of reproducing research, as highlighted in conversations around EMNLP rejections [Rejected at EMNLP with decent scores. What can be done next?]. The manual effort of dependency resolution, cell generation, and ensuring reproducibility can easily consume hours, diverting attention from the core insights within the code itself. repo2nb automates this, intelligently walking a repository’s file tree and constructing a notebook, handling dependencies with a thoughtful fallback system that prioritizes modern package management tools like Poetry and UV before resorting to a more exhaustive AST import scan. This smart approach streamlines the workflow and allows researchers and learners to focus on understanding and applying the code, not wrestling with its environment.

The incremental sync feature of this update is particularly noteworthy. Rather than requiring a complete re-generation of the notebook each time the underlying repository changes, it intelligently updates only the modified files, adding new cells for new files and adjusting existing ones. This not only saves time but also minimizes the potential for introducing errors during the conversion process. The addition of a Colab-specific target with its own authentication mechanism further broadens the tool's utility. Furthermore, the "reverse" mode, which reconstructs the original repository from a notebook, is a compelling addition—a clever way to validate the conversion process and provide a form of provenance tracking. This capability speaks to a broader trend towards increased transparency and reproducibility in scientific computing, enabling easier auditing and verification of results. The developers’ curiosity regarding the actual usage patterns of dependency resolution methods is also refreshing; it highlights a commitment to iterative improvement based on real-world application.

The significance of repo2nb extends beyond simply saving time. It lowers the barrier to entry for engaging with code shared by others, particularly within the academic and research communities. Reproducibility has become a core tenet of modern scientific practice, and tools like repo2nb directly contribute to this goal. The shift towards platforms like Kaggle and Colab for experimentation and collaboration necessitates a smoother transition from traditional Git-based workflows. By automating the notebook conversion process, repo2nb empowers users to quickly explore, adapt, and build upon existing codebases, fostering a more collaborative and efficient research ecosystem. The approach of prioritizing modern dependency management tools while providing a robust fallback demonstrates a practical understanding of the diverse ways developers structure their projects. This tool’s ability to derive a continuous score from categories is reminiscent of other efforts to increase efficiency in data analysis [Estimating from No Data: Deriving a Continuous Score from Categories], showing a wider interest in streamlining workflows.

Looking ahead, it will be interesting to see how repo2nb evolves to handle more complex repository structures and project types. The current version focuses primarily on code-centric repositories, but future iterations could incorporate support for data files, configuration management, and other project assets. The integration of more sophisticated dependency resolution techniques, potentially leveraging machine learning to predict optimal configurations, could further enhance its capabilities. Perhaps the most compelling question is whether tools like repo2nb will eventually become an integral part of the code sharing and collaboration process, seamlessly transforming repositories into interactive learning and experimentation environments.

repo2nb is an open-source CLI that converts a GitHub repo into a runnable Kaggle or Colab notebook: walks the file tree, resolves dependencies, and generates cells, instead of you doing that by hand for a repo you didn't write (a paper's code, a tutorial, someone else's experiment).

0.2.0 highlights:

  • Dependency resolution tries poetry export, then uv export, then requirements.txt, then falls back to an AST import scan if none of those exist. Output is always a plain %pip install cell regardless of which path it took, so poetry/uv are only ever needed locally at generation time, not on Kaggle/Colab.
  • Reverse mode (repo2nb reverse <notebook>) reconstructs the original repo from a generated notebook, using the per-cell path/hash metadata every generated cell now carries. Validates against directory traversal and won't write into a non-empty directory without --force.
  • Incremental sync (repo2nb sync <repo>) does one-directional (repo to notebook) updates: added files get new cells, edited files update in place, deleted files get removed. --dry-run previews the diff.
  • Added a Colab target with its own auth cell (google.colab.userdata.get) rather than reusing the Kaggle secrets flow.

Install: pip install repo2nb

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

Curious whether the dependency-resolution fallback order (poetry > uv > requirements.txt > import scan) matches what people actually run into, or if there's a common setup it'd get wrong.

Any feedback or opinions are much welcomed!

submitted by /u/PolarIceBear_
[link] [comments]

Read on the original site

Open the publisher's page for the full experience

View original article