https://github.com/jancervenka/jupyter-inheritance
Inherit Jupyter Kernels
https://github.com/jancervenka/jupyter-inheritance
data-science jupyter jupyter-notebook python scientific-computing
Last synced: 3 months ago
JSON representation
Inherit Jupyter Kernels
- Host: GitHub
- URL: https://github.com/jancervenka/jupyter-inheritance
- Owner: jancervenka
- License: mit
- Created: 2022-01-30T14:31:33.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-30T14:47:15.000Z (over 4 years ago)
- Last Synced: 2025-04-12T19:19:26.122Z (over 1 year ago)
- Topics: data-science, jupyter, jupyter-notebook, python, scientific-computing
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jupyter Inheritance



_Inherit Jupyter Kernels_
You have a notebook `base.ipynb` with a cell
```python
import os
from datetime import datetime
class Test:
msg = "Hey!"
def add(x, y):
return x + y
test = Test()
now = datetime.now()
```
that has been executed. You can create a new notebook and run the following code:
```python
from jupyter_inheritance import inherit_from
inherit_from("base.ipynb")
assert add(1, 4) == 5
assert isinstance(test, Test)
print(test.msg)
print(now) # same value as `now` in `base.ipynb`!
print(os.listdir("."))
```
The `base.ipynb` content is not executed from scratch in the new notebook,
all the existing objects are copied directly from `base.ipynb` kernel. This
ensures that everything stays exactly the same (e.g. timestamps, random numbers,
responses from externals APIs).
You can even do mixins!
```python
from jupyter_inheritance import inherit_from
for notebook in ("base_1.ipynb", "base_2.ipynb"):
inherit_from(notebook)
```
## Installation
Just the usual
```bash
pip install jupyter-inheritance
```