This plugin integrates JupyterHub with CKAN, allowing users to execute and temporarily edit interactive Jupyter notebooks within the CKAN environment. The plugin makes data exploration and analysis more accessible and integrated.
- Integration of Jupyter Notebooks within CKAN
- Temporary notebook editing and execution
- Utilize DockerSpawner to create isolated Docker containers for each user, ensuring a secure and personalized computational environment.
- Guest user access without login
- Admin-configurable maximum number of concurrent guest users
- Users access Jupyter notebooks through the CKAN interface.
- Each user is provided with a temporary, isolated Docker container.
- Users can edit notebook cells and install libraries during their session.
- After a predefined timeout, all changes are automatically reverted.
- Guest users can access notebooks without logging in, subject to availability.
The extension consists of two main components:
-
CKAN Extension (ckanext-jupyternotebook)
- Core CKAN plugin functionality
- Views and templates for notebook interaction
- Controllers for handling notebook operations
-
JupyterHub Component (jupyterhub)
- Runs as a separate Docker container
- Manages notebook instances
- Provides API endpoints for user management
As usual for CKAN extensions, you can install ckanext-jupyternotebook as follows:
git clone git@github.com:SDM-TIB/ckanext-jupyternotebook.git
pip install -e ./ckanext-jupyternotebook
pip install -r ./ckanext-jupyternotebook/requirements.txtConfigure the .env file with the following required variables::
CKAN_JUPYTERNOTEBOOK_URL: The base URL for JupyterHub accessCKAN_JUPYTERHUB_BASE_URL: The base path for JupyterHubCKAN_NETWORK: Docker network nameCKAN_STORAGE_NOTEBOOK: Path to notebook storageCKAN_API_JUPYTERHUB: JupyterHub API endpointCKAN_JUPYTERHUB_TIMEOUT: Session timeout in secondsCKAN_JUPYTERHUB_USER: Maximum concurrent usersCKAN_JUPYTERHUB_PERCENTAGE_CPU: CPU allocation per containerCKAN_JUPYTERHUB_MEMORY_LIMIT: Memory limit per container
Example of customising the extension's behaviour using the following environment variables::
# JupyterHub variables
CKAN_JUPYTERNOTEBOOK_URL=https://your-domain/jupyter/
CKAN_JUPYTERHUB_BASE_URL=/your-path/jupyter
CKAN_NETWORK=your-docker-network
CKAN_STORAGE_NOTEBOOK=/path/to/notebook/storage
CKAN_API_JUPYTERHUB=http://jupyterhub:6000
CKAN_JUPYTERHUB_TIMEOUT=1200
CKAN_JUPYTERHUB_USER=100
CKAN_JUPYTERHUB_PERCENTAGE_CPU=50
CKAN_JUPYTERHUB_MEMORY_LIMIT=1G
For CKAN to automatically recognize Jupyter Notebook files and create preview views for them, two configuration changes are needed in your ckan.ini:
-
Register the default view: Add
jupyternotebookto the list of default views so that CKAN automatically creates a notebook preview when a Jupyter Notebook resource is uploaded:ckan.views.default_views = jupyternotebook image_view text_view recline_view -
Enable loading of
.ipynbfiles: Addipynbto the list of loadable preview formats so that CKAN recognizes.ipynbas a previewable file type:ckan.preview.loadable = ipynb html htm rdf+xml owl+xml xml n3 n-triples turtle ...
Note: Without these settings, users would have to manually select the notebook view for each uploaded
.ipynbresource. With both options configured, the preview is created automatically upon resource upload.
ckanext-jupyternotebook is licensed under GPL-3.0, see the license file.