Package: papermill-report
Papermill Jupyter reportMicroservice to generate Jupyter reports by executing notebook and exporting them to static HTML page combiningpapermillandnbconvert.It can be run as a standalone application or as a JupyterHub service.The workflow is described in the figure below. You can either:Set a specific URL to select a notebook and pass query arguments as parameters,Or interactively select one notebook and set its parameters.FeaturesThe API is describedthere.There are two features provided by this service:Listing all available report templates (and their parameters)
The available templates are all notebook files existing within thetemplate_root_dir.Generate a report (i.e. execute a parametrized notebook and convert it to HTML)Parametrized notebook are supported only for Python notebook.ConfigurationThe configurable settings for the service are:broken_reports_dir: Folder in which broken notebook will be copied - it must be a subfolder ofnotebook_dir; default/home/USERNAME/broken_reportsconfig_file: Configuration file name; defaultpapermill_service_configgit_auth: Git authentication (username:password); defaultNonenotebook_dir: Notebook server root directory; default/home/USERNAMEThis is needed to build the link to broken notebook.port: Port of the service; default8888template_root_dir: Folder containing the notebook templates on the server; default/opt/papermill_reporttemplate_dir: Folder of the Git repository containing the notebook templates; default"."template_git_url: Git repository URL source of the notebook templates; defaultNonetemplate_paths: Paths to search for service webpage jinja templates, before using the default templates; defaultNoneThe stringUSERNAMEwill be replaced with the user’s username if used inbroken_reports_dirornotebook_dir.NotesOn Unix platforms, the service must be run asrootbecause report processes are executed throughsu <user> --logincommand to
impersonate the authenticated user and setting the environment variables afresh.DevelopmentThis python package is meant to be deployed as aJupyterHub Hub-Managed service.The consequences are:The service runs its own tornado server. Requests will be forwarded to it
by the JupyterHub internal proxy from the standard URLhttps://myhub.horse/services/my-service/(pay attention to the required trailing/).Authentication is deferred to JupyterHubAs it is managed by JupyterHub, JupyterHub will check that the service is
alive. And if not, it will restart it. Moreover, when JupyterHub is nicely stopped, it will stop the service.TestingThere is 2 levels of test in this service. Some conventional unit tests withpytestand a Dockerfile to spin an integrated environment starting the service
as JupyterHub service.Unit testpython -m install -r requirements.txt -r requirements_dev.txt
pytest papermill_reportIntegration with JupyterHubTo build and launch the integrated environment:docker build -t papermill-report .
docker run -p 8000:8000 --rm papermill-reportThe Hub is parameterized (seejupyterhub_config.py) with two users:jovyan: an administratormarc: an userThere are no password on the accounts.The template folder is theexamplesfolder of this project.You can also test the service manually by visiting valid endpoints:http://localhost:8000/services/report/http://localhost:8000/services/report/broken_parameters.ipynbhttp://localhost:8000/services/report/no_parameters.ipynbhttp://localhost:8000/services/report/subfolder/simple_execute.ipynb&msg=helloIntegration tests can be executed automatically using that environment with the following command:docker-compose -f e2e-tests/docker-compose.yml run e2e ./e2e-tests/run_e2e.sh
docker-compose -f e2e-tests/docker-compose.yml down