Create a package from a jupyter notebook
Project description
README
A tiny little package to create packages from jupyter notebooks
If you find yourself copy pasting functions between jupyter notebooks, this might help.
Typical Use Cases
This is very helpful when producing the same graph, running the same ETL, or executing the same ML pipeline on different datasets or different versions of the same dataset.
Make Packages from Jupyter Notebooks
In Python
You can run this in <your_notebook.ipynb> or anywhere else in the same directory
notebook_to_package("notebook_name.ipynb")
will create the needed files and directories [in the current directory] to produce a local package, which you can access by
import notebooks.src.<cleaned_notebook_name>
where cleaned_notebook_name
is all lower case and has spaces replaced with underscores. Please note if your notebook name has illegal characters for a python package, there will be an error.
I recommend importing your notebook as
an abbreviation.
Make sure to rerun the code if you want the package updated.
From the Command Line
Under the Hood: Package Directory Structure
With no consensus on directory structure for packages, I defaulted to a version of python.org's suggestion.
notebooks/
├── src/
│ └── <notebook_name>/
│ ├── __init__.py
│ └── <notebook_name>.py # what you'll be importing
├── bin/
│ └── <notebook_name>.py #executable
I realize the import statement is hefty, but I didn't want to handle collissions in a VO.
Skip Stuff
Aything you don't want included in the package you can put below a MARKDOWN cell including the text between the quotes
"# DO NOT ADD BELOW TO SCRIPT"
FAQs
Help! My code isn't updating!
Make sure that you've run your notebook and saved it. This package relies on jupyter notebook's nbconvert
under the hood, which looks to the most recent checkpoint of your notebook.
Help! Why can't jupyckage do more?!?!
If you're interested added functionality, please let me know and I'll look at adding it or happily work with you so you can contribute :)
Contact
Hi, I'm Kerstin Frailey. I whipped up this package quickly to make my life a bit easier. Hope it helps some other people out, too.
Here's my contact info:
- twitter @KEFrailey
- blog datascienceatwork.blog
- email frailey.work@gmail.com
- linkedin linkedin.com/in/kefrailey
Hope you have a nice day!
Project details
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
Hashes for jupyckage-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e850095c4d9f1e08ede2c4b65845aa49b7f65741474c1f727fb2608e0690260 |
|
MD5 | 0f581d2ac6c44ddff636a04e7a222d1c |
|
BLAKE2b-256 | 796fdd226f4e10c9cac8630d36bd0ab147eed20d9a0f725ec3fd31626eee7dfd |