Observed since 20 Oct, 18:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
An Activated AI utility for importing Jupyter notebooks as Python modules
ActivatedNotebookImporter is a Python package developed and used internally by Activated AI (https://activated-ai.com) that allows you to import Jupyter notebooks as Python modules. This package is designed to seamlessly integrate Jupyter notebooks into your Python workflows.
ActivatedNotebookImporter is particularly useful for workflows where you want to use Jupyter notebooks as reusable modules. Instead of converting your Jupyter notebooks to Python scripts, you can use them directly in your workflows:
params argument when importing the notebookThis approach allows for more flexible and maintainable code, keeping your exploratory work and reusable code closely aligned.
You can install ActivatedNotebookImporter using pip:
pip install activated-notebook-importer
Here's a basic example of how to use ActivatedNotebookImporter:
from activated_notebook_importer import import_notebook
# Import a notebook with parameter substitution
module = import_notebook('path/to/your/notebook.ipynb',
{'param1': 'value1', 'param2': 'value2'})
# Assuming your notebook defines a 'my_function' function
result = module.my_function()
print(result)
In your Jupyter notebook:
# In the first cell or in cells tagged with "parameters"
param1 = 'default1'
param2 = 'default2'
# In a code cell
def my_function(param1=param1, param2=param2):
# Your code here
return some_result
# In another cell, tag this with 'import-exclude' in Jupyter
# This cell won't be executed when the notebook is imported
my_function()
Note:
params argument when importing.One potential use case is for hyperparameter search in machine learning models:
from activated_notebook_importer import import_notebook
hyperparameters = [
{'learning_rate': 0.01, 'batch_size': 32},
{'learning_rate': 0.001, 'batch_size': 64},
{'learning_rate': 0.0001, 'batch_size': 128}
]
results = []
for params in hyperparameters:
module = import_notebook('model_training.ipynb', params)
results.append(module.train())
# Process and analyze results
ActivatedNotebookImporter is a tool used in various workflows at Activated AI. We use it to:
By using this tool, we've improved our ability to leverage work done in Jupyter notebooks in our broader Python ecosystem.
We welcome contributions! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
ActivatedNotebookImporter is developed and maintained by Activated AI. Visit our website at https://activated-ai.com to learn more about our AI research and development.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.0 | 12 Aug 2024 | 3 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 18:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:032e226646f3691c12c023e81d45d12e9d119fe8ca21bfca9951ce339d707cda