Option to customize port
Include filter context in notebook text
Table of contents
Steps 1-3
Steps 5-7 (DateOfSale dragged to rows, cell for 2022 clicked, PivotToJupyer custom action selected
Step 8, play all cells and observe results
zpm "install pivottojupyter"
Installing with ZPM does not configure Python or the notebook server. It simply installs the demo KPI class. This means either the demo KPI will need to be modified for your configurations, or you will need to make configuration changes similar to what the container does.
The following python libraries are used: notebook pandas matplotlib seaborn sqlalchemy-iris
.
Manual configurations for a notebook server are also needed. The KPI expects a notebook server to be listening on port 61888 (it is actually listening on port 8888 in the container, but the container exposes this as 61888). The KPI also places generated notebook files in <install dir>/mgr/<namespace>/notebooks
, which means the notebook server needs to look in this directory for the files.
For extra details on how these are implemented in the container, continue reading the Implementation Guide.
There are two main components to this demo. The first is a custom action inside or IRIS BI. The second is a Jupyter notebook that uses data that was specified in the custom action.
Custom Actions come from code that is implemented in a “KPI Action Class”. This class is then pointed to by a cube so it can use the defined custom actions. In this example, the class PivotToJupyter.CustomKPIAction
was created to implement the custom action. Inside of %OnDashboardAction
, there is logic to pull the current query context out of the pContext object so either the selected cell on the pivot table, or the context of the entire pivot table will be used. Once this context is extracted, a new table is created based on the Listing results of the current query context. Then, a python method, GenerateNotebook
is executed to generate the notebook that queries this new table. Finally, it uses the “newWindow” command to open a new browser window that points to the notebook server running in the container with the newly generated notebook.
The Dockerfile does two important steps for creating the notebook server:
RUN python3 -m pip install notebook pandas matplotlib seaborn sqlalchemy-iris
- this installs dependencies for both hosting the notebook server as well as installing the python libraries that the demo code in the generated notebook uses.
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--NotebookApp.token=''", "--ServerApp.root_dir=/usr/irissys/mgr/user/notebooks"]
- this tells the container to run the notebook server when the container is started. I also needed to implement entrypoint.sh
to ensure that iris-main is still executed so IRIS also starts with the container.
Note that the custom action creates the notebook in a local folder, which is why we’re starting Jupyter from inside the IRIS container rather than as a separate container.
:information_source: Note that the above command starts the Jupyter notebook app at port 8888, but the docker-compose.yml
file wires that to 61888 on your host. You can customize the port to use for building the URL through ^PivotToJupyter("jupyter-port")
as required (see also src/PivotToJupyter/CustomKPIAction.cls
).