Modular Notebooks
Project description
Welcome to the Machine!
datamachine is a powerful Python package that allows you to execute cloud Python notebooks with parameters and import cloud notebooks as modules. With datamachine, you can reference notebooks from various sources such as local files, Colab links, Github links, and HTTP links, and execute or import them with ease. You can also assign codes to files or links and store them in a library, which is a collection of codes and their corresponding links. Libraries are stored in JSON format with a dictionary of notebooks to their links.
Features
-
Execute cloud notebooks with parameters: With datamachine, you can execute cloud notebooks with parameters, which is particularly useful when you want to run a notebook multiple times with different inputs.
-
Import cloud notebooks as modules: Importing cloud notebooks as modules is a breeze with datamachine. You can import notebooks from various sources such as local files, Colab links, Github links, and HTTP links.
-
Library and Index: datamachine supports library and index features, making it easier to organize your code. You can store collections of code and their corresponding links in a library and index them for easy access.
-
JSON support: All libraries and indexes are stored in JSON format, making it easy to read, write, and share with others.
Installation
To install datamachine, run the following command:
%pip install datamachine
Usage
Once you have installed datamachine, you can use it to execute and import notebooks.
Executing a Notebook
To execute a notebook with parameters, use the execute_notebook
function:
import datamachine as dm
dm.execute_notebook(
"execute.ipynb", html="output.html",
params={"EIN": "200549531","TYPE": "summary"},
)
This function executes the notebook located at "execute.ipynb"
with the parameter "EIN"
set to "200549531"
. The output is saved in an HTML file named "output.html"
.
In order to receive the EIN parameter in the executed notebook, simply invoke
the execute_params
function with a passed dictionary containing the parameter.
This function provides the test values when you're directly running the notebook,
and uses the passed values when invoked via execute_notebook
.
import datamachine as dm
params = dm.execute_params({"EIN": "454547709","TYPE": "detail"})
EIN = params["EIN"]
Importing a Notebook as a Module
To import a notebook as a module, use the import_notebook
function:
import datamachine as dm
nbo = dm.import_notebook("./module.ipynb")
This command imports the notebook located at "./module.ipynb"
as a module named "nbo"
.
Conclusion
datamachine is a powerful tool for anyone who works with cloud Python notebooks. With its flexible features and easy-to-use commands, datamachine makes it easy to execute and import notebooks from various sources, store collections of code and their corresponding links in a library, and organize your code with an index. So why wait? Install datamachine today and take your cloud notebook experience to the next level!
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
Hashes for datamachine-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2133ecb4d301307d4f3b017d30d621db081d73a55da06267440605caadd1c67 |
|
MD5 | da29287da0935f8a7120558992372e3c |
|
BLAKE2b-256 | b791cac2d1829751f2871e0c3b13119532ffa42ec3c036772002273bbe1bd894 |