Harmonises Jupyter and Colab notebook environments for consistent paths, imports, and working directories
Project description
colocal
Colab or local — same behaviour, same results.
colocal is a lightweight utility that harmonises notebook environments across Google Colab and local Jupyter.
It automatically ensures your repository structure, imports, and working directory are consistent — so your notebooks run the same everywhere.
✨ Features
- Seamless dual support → Detects Colab vs Jupyter automatically.
- Clean imports → Adds your repository root to
sys.path. - Consistent working directory → Sets
cwdto the notebook’s folder, avoiding fragile../../paths. - Branch-aware in Colab → Parses the Colab badge, checks out the correct branch, and mirrors your local repo structure.
- Fallback support → If the notebook has no badge, you can specify the GitHub URL directly.
- Reproducibility → Run the same notebook in Colab or locally with identical results.
🚀 Usage
🟢 Running in Colab
If your notebook has a Colab badge that points to a Github repo like:
<a href="https://colab.research.google.com/github/org/repo/blob/main/notebooks/demo.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open in Colab"/>
</a>
just run:
import colocal
colocal.setup()
colocal will:
- Clone the correct repo and branch into
/content/ - Add it to
sys.path - Set the working directory to match the notebook’s location in the repo
🟡 No badge? Specify the repo manually
If the notebook doesn’t include a Colab badge, just provide the repository URL:
import colocal
colocal.setup("https://github.com/org/repo")
This clones the repo’s default branch, adds it to sys.path, and sets the working directory to the repo root.
⚪ Running locally
If you’re in a local Jupyter environment, colocal:
- Detects the current notebook’s location
- Finds the repository root (via
.git) - Adds it to
sys.path - Changes directory to the notebook’s folder
That’s it — your imports and paths are now consistent with the Colab version.
🧩 Return values
repo_root, branch, cwd = colocal.setup(...)
repo_root→ path to the repository rootbranch→ current branch name (if known)cwd→ current working directory after setup
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file colocal-2025.11.6.1340.tar.gz.
File metadata
- Download URL: colocal-2025.11.6.1340.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26632d00a47434a834ce3dbb4195c90a357bc8cff892c2295aebee058b2584fa
|
|
| MD5 |
9d0c24603fa9d92b89ec8197e40ddffb
|
|
| BLAKE2b-256 |
abeb271681deff5d74941bcb7a4312523eb4c45e8f055b047e34e72552887412
|
Provenance
The following attestation bundles were made for colocal-2025.11.6.1340.tar.gz:
Publisher:
publish.yml on project-ida/colocal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colocal-2025.11.6.1340.tar.gz -
Subject digest:
26632d00a47434a834ce3dbb4195c90a357bc8cff892c2295aebee058b2584fa - Sigstore transparency entry: 675997645
- Sigstore integration time:
-
Permalink:
project-ida/colocal@1e3bc846624c35993d7e6052a075c30d9d2735e2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/project-ida
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1e3bc846624c35993d7e6052a075c30d9d2735e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file colocal-2025.11.6.1340-py3-none-any.whl.
File metadata
- Download URL: colocal-2025.11.6.1340-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b91d653db03329de67fa7e3fe83dd6177d6ad1a00371e6137315bfb7eb345a4
|
|
| MD5 |
c0a9c95e15417124d62fe4083a594f74
|
|
| BLAKE2b-256 |
1fbca9c211f630491a6bb528d0462bf4c3726ae1745ca4fcd6edb8fa8e02a6a8
|
Provenance
The following attestation bundles were made for colocal-2025.11.6.1340-py3-none-any.whl:
Publisher:
publish.yml on project-ida/colocal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colocal-2025.11.6.1340-py3-none-any.whl -
Subject digest:
8b91d653db03329de67fa7e3fe83dd6177d6ad1a00371e6137315bfb7eb345a4 - Sigstore transparency entry: 675997648
- Sigstore integration time:
-
Permalink:
project-ida/colocal@1e3bc846624c35993d7e6052a075c30d9d2735e2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/project-ida
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1e3bc846624c35993d7e6052a075c30d9d2735e2 -
Trigger Event:
push
-
Statement type: