repo2nb 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- repo2nb-0.1.0/.github/workflows/ci.yml +25 -0
- repo2nb-0.1.0/.github/workflows/publish.yml +23 -0
- repo2nb-0.1.0/.gitignore +65 -0
- repo2nb-0.1.0/.python-version +1 -0
- repo2nb-0.1.0/LICENSE +21 -0
- repo2nb-0.1.0/PKG-INFO +69 -0
- repo2nb-0.1.0/README.md +58 -0
- repo2nb-0.1.0/examples/sample_output.ipynb +1098 -0
- repo2nb-0.1.0/examples/sample_output_omit_instructions.ipynb +1060 -0
- repo2nb-0.1.0/logo.png +0 -0
- repo2nb-0.1.0/pyproject.toml +24 -0
- repo2nb-0.1.0/repo2nb/__init__.py +1 -0
- repo2nb-0.1.0/repo2nb/cli.py +22 -0
- repo2nb-0.1.0/repo2nb/converter.py +99 -0
- repo2nb-0.1.0/repo2nb/git.py +78 -0
- repo2nb-0.1.0/repo2nb/notebook.py +17 -0
- repo2nb-0.1.0/repo2nb/traversal.py +40 -0
- repo2nb-0.1.0/repo2nb/warnings.py +21 -0
- repo2nb-0.1.0/tests/test_converter.py +56 -0
- repo2nb-0.1.0/tests/test_git.py +24 -0
- repo2nb-0.1.0/tests/test_notebook.py +14 -0
- repo2nb-0.1.0/tests/test_traversal.py +36 -0
- repo2nb-0.1.0/uv.lock +1056 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["*"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint-and-test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v5
|
|
14
|
+
|
|
15
|
+
- name: Install uv
|
|
16
|
+
uses: astral-sh/setup-uv@v6
|
|
17
|
+
|
|
18
|
+
- name: Install dependencies
|
|
19
|
+
run: uv sync --all-extras --dev
|
|
20
|
+
|
|
21
|
+
- name: Lint with ruff
|
|
22
|
+
run: uv run ruff check .
|
|
23
|
+
|
|
24
|
+
- name: Run tests
|
|
25
|
+
run: uv run pytest tests/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v5
|
|
13
|
+
|
|
14
|
+
- name: Install uv
|
|
15
|
+
uses: astral-sh/setup-uv@v6
|
|
16
|
+
|
|
17
|
+
- name: Build
|
|
18
|
+
run: uv build
|
|
19
|
+
|
|
20
|
+
- name: Publish
|
|
21
|
+
run: uv publish
|
|
22
|
+
env:
|
|
23
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
repo2nb-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Jupyter Notebook
|
|
55
|
+
.ipynb_checkpoints
|
|
56
|
+
|
|
57
|
+
# Environments
|
|
58
|
+
.env
|
|
59
|
+
.venv
|
|
60
|
+
env/
|
|
61
|
+
venv/
|
|
62
|
+
ENV/
|
|
63
|
+
env.bak/
|
|
64
|
+
venv.bak/
|
|
65
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
repo2nb-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Magdy Nagib
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
repo2nb-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: repo2nb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Convert a local code repository into a Kaggle-ready Jupyter notebook
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Requires-Dist: click
|
|
9
|
+
Requires-Dist: nbformat
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# repo2nb
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
## Motivation
|
|
21
|
+
*This is a tool I made for personal use first, then I wanted to publish it.*
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
**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!
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install repo2nb
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Convert your local project to a Kaggle notebook
|
|
39
|
+
repo2nb ./my_project --output my_project_kaggle.ipynb
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then literally just upload the resulting `.ipynb` file to Kaggle!
|
|
43
|
+
|
|
44
|
+
### Options
|
|
45
|
+
|
|
46
|
+
- `--output`, `-o`: Specify the output notebook path. Defaults to `<folder_name>.ipynb`.
|
|
47
|
+
- `--omit-instructions`: Omits the beginner-friendly warning cells and instructional git cheat sheets. Perfect for power users who already know the setup routine.
|
|
48
|
+
- `--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.
|
|
49
|
+
- `--include`: Force include specific file extensions that are usually skipped as binary/data (e.g., `--include ".csv .json"`).
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- **Instant Rebuild**: Automatically translates your local file tree into correctly ordered `%%writefile` blocks.
|
|
54
|
+
- **Git Integration**: Injects pre-formatted shell cells for initializing Git, adding tokens, selecting branches, pulling, and pushing.
|
|
55
|
+
- **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.
|
|
56
|
+
- **Visual Segregation**: Creates unmissable structural phases isolating where the automatic repo build ends and where your actual coding workspace begins.
|
|
57
|
+
- **Built-in Git Cheat Sheet**: Gives you immediate interactive access to `git status`, `git rm -rf`, and `git mv` blocks directly in the UI.
|
|
58
|
+
|
|
59
|
+
## Important Conventions & Security
|
|
60
|
+
|
|
61
|
+
**Security & Publishing:**
|
|
62
|
+
The generated notebook contains a prompt to hook up your GitHub personal access token so you can sync edits back. **If you plan to make this notebook public, DO NOT hardcode your GitHub token!** Use **Kaggle Secrets** instead. 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.
|
|
63
|
+
|
|
64
|
+
**Run All Only Once:**
|
|
65
|
+
When you first start your Kaggle session, use **"Run All"** to bootstrap the directory structure and recreate the files.
|
|
66
|
+
**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!
|
|
67
|
+
|
|
68
|
+
**Branch Management:**
|
|
69
|
+
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.
|
repo2nb-0.1.0/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# repo2nb
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
## Motivation
|
|
10
|
+
*This is a tool I made for personal use first, then I wanted to publish it.*
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
**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!
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install repo2nb
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Convert your local project to a Kaggle notebook
|
|
28
|
+
repo2nb ./my_project --output my_project_kaggle.ipynb
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then literally just upload the resulting `.ipynb` file to Kaggle!
|
|
32
|
+
|
|
33
|
+
### Options
|
|
34
|
+
|
|
35
|
+
- `--output`, `-o`: Specify the output notebook path. Defaults to `<folder_name>.ipynb`.
|
|
36
|
+
- `--omit-instructions`: Omits the beginner-friendly warning cells and instructional git cheat sheets. Perfect for power users who already know the setup routine.
|
|
37
|
+
- `--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.
|
|
38
|
+
- `--include`: Force include specific file extensions that are usually skipped as binary/data (e.g., `--include ".csv .json"`).
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Instant Rebuild**: Automatically translates your local file tree into correctly ordered `%%writefile` blocks.
|
|
43
|
+
- **Git Integration**: Injects pre-formatted shell cells for initializing Git, adding tokens, selecting branches, pulling, and pushing.
|
|
44
|
+
- **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.
|
|
45
|
+
- **Visual Segregation**: Creates unmissable structural phases isolating where the automatic repo build ends and where your actual coding workspace begins.
|
|
46
|
+
- **Built-in Git Cheat Sheet**: Gives you immediate interactive access to `git status`, `git rm -rf`, and `git mv` blocks directly in the UI.
|
|
47
|
+
|
|
48
|
+
## Important Conventions & Security
|
|
49
|
+
|
|
50
|
+
**Security & Publishing:**
|
|
51
|
+
The generated notebook contains a prompt to hook up your GitHub personal access token so you can sync edits back. **If you plan to make this notebook public, DO NOT hardcode your GitHub token!** Use **Kaggle Secrets** instead. 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.
|
|
52
|
+
|
|
53
|
+
**Run All Only Once:**
|
|
54
|
+
When you first start your Kaggle session, use **"Run All"** to bootstrap the directory structure and recreate the files.
|
|
55
|
+
**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!
|
|
56
|
+
|
|
57
|
+
**Branch Management:**
|
|
58
|
+
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.
|