model-analysis: TFMA not rendering in JupyterLab
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow Model Analysis): Yes, minor
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 18.04 and image python:3.7-slim
- TensorFlow Model Analysis installed from (source or binary): pip install
- TensorFlow Model Analysis version (use command below): 0.27.0
- Python version: 3.7
- Jupyter Notebook version: jupyterlab 2.2.9
- Exact command to reproduce: see sample notebook
Describe the problem
tfma.view.render_slicing_metrics shows no output.
Source code / logs
Slim docker image to reproduce the issue:
FROM python:3.7-slim
ENV DEBIAN_FRONTEND=noninteractive
# This is used because our k8s cluster can only access our internal pypi
#COPY pip.conf /etc/pip.conf
# # TFMA is installed in the notebook because pip complained otherwise
RUN python3.7 -m pip install --no-cache-dir jupyterlab==2.2.9
# Install Node (for jupyter lab extensions)
RUN apt update && \
apt -y install nano curl dirmngr apt-transport-https lsb-release ca-certificates && \
curl -L https://deb.nodesource.com/setup_15.x | bash - && \
apt update && apt install -y nodejs && \
node -v
RUN jupyter labextension install tensorflow_model_analysis@0.27.0 && \
jupyter labextension install @jupyter-widgets/jupyterlab-manager@2
RUN jupyter lab build
ENV DEBIAN_FRONTEND=
ENV NB_PREFIX /
ENV SHELL=/bin/bash
# Standard KubeFlow jupyter startup command
CMD ["/bin/bash","-c", "jupyter lab --notebook-dir=/home/jovyan --ip=0.0.0.0 --no-browser --allow-root --port=8888 --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.allow_origin='*' --NotebookApp.base_url=${NB_PREFIX}"]
Below is an evaluation artifact from a small TFX pipeline and a minimal notebook to reproduce. Notebook consists of unzipping, install tfma, load eval result and try to display. 3053.zip tfma-render-issue.ipynb.zip
Edit: I’ve also run the above with node 12 instead of 15 with the exact same result.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 75 (20 by maintainers)
Commits related to this issue
- Read baseUrl in JupyterLab to support TFMA rendering: #112 PiperOrigin-RevId: 401267422 — committed to tensorflow/model-analysis by deleted user 3 years ago
Ah yes, I misplaced this release note! It should be part of 0.31.0 instead.
I’ve had the same issue with Jupyterlab throwing the
Error display widget.... My current setup is:I got TFMA to work by installing the above mentioned notebook extensions
and then launch the file in a traditional Jupyter notebook:
This is what I see in jupyter lab:
We think this should be fixed now, but would like someone to try it out. Special thanks to @Bobgy and @zijianjoy.
Hi @atn832, Sorry to bother you again. do you have any updates or ETA for the Kubeflow support? I’d like to make this extension available soon to Twitter employees using Kubeflow.
This may or may not help. I recently got the TFMA visualization working in JupyterLab by changing my browser settings. I’m using Chrome, and under Settings > Privacy and security > Security my setting was “Enhanced protection”. Changing it to “Standard protection” fixed the issue, which was caused by Chrome stopping what it sees as a CORB request. I was using this code to display the visualization:
I hope that helps!
@JanetVictorious That’s not fixing this at all, you’ve just just jupyter notebook instead of JupyterLab and this entire issue is about JupyterLab support.
@mdreves I just tried to test this but when running
tfma.view.render_slicing_metrics(eval_result)I gotError displaying widget. I’m using jupyterlab 3 and I have installed TFMA using the official instructions. Any idea why I get this?The 0.35 release will be out shortly if you want to wait for that so you don’t need to install from head, though you can also try with the nightly.
@mwakaba2, Thanks for reporting the issue and checking the flag. Even though you all had explained the problem well, I misunderstood it and fixed the wrong issue. I was fixing @Bobgy’s use case posted on Feb 25 (https://github.com/tensorflow/model-analysis/issues/10#issuecomment-595618035), which is to show the TFMA UI in a standalone HTML page outside of a notebook environment, that HTML page being exported from a notebook.
This time, I’ll see if I can support your use case of running the TFMA UI in Jupyter Lab hosted by Kubeflow Notebook Server.
Yes, my fix was merged a few days ago (https://github.com/tensorflow/model-analysis/commit/cc7d75c1bf588123795511572e1b4445d9a52191) and this issue should be resolved on the next release.
@atn832 Any update on this?
@ConverJens The latest JupyterLab major version (which uses Jupyter Server as the backend) is planning on dropping the nbclassic extension. Currently, there exists a shim to help ease users who are transitioning but this will cease to exist in the future. Thus, it makes sense for this to evolve to work out of the box with just JupyterLab since this seems like an antipattern. The nbclassic plugin is only needed for the JupyterLab extension to serve a static file which should be able to be hosted by a different mechanism such as a server extension.
@rcrowe-google there’s still an upstream problem here FYI.
in the Jupyter ecosystem, there are two primary types of frontend extensions (this doc may be helpful):
nbextensions are effectively deprecated in favor of labextensions, because all modern notebook runtimes (incl AI Platform Notebooks etc are fronted with Jupyter Lab). so in order to enable nbextensions (Jupyter Classic Notebook extensions) on top of Jupyter Server (which replaces the Jupyter Notebook server) to support serving of this Javascript, we had to install a compatibility layer that otherwise wouldn’t need to exist (called nbclassic).
so tl;dr: the problem with TFMA’s JupyterLab support is that it’s not a pure JupyterLab extension. It’s a labextension that depends on a nbextension to work. what we’ve employed here is a workaround vs a proper fix. the proper fix would involve making the labextension carry its own dependencies vs the existing hybrid model (which is unprecedented btw).
this gap is likely where the other folks like @ConverJens are running into issues making this work - as it’s non-obvious vs the way any other lab extension works.
My use case
I generate the html in a step in a pipeline, and the pipeline UI shows the html in an iframe. but that’s not related to this issue