Repository: voxel51/fiftyone

Issue:
[BUG] 3d visualizer doesn't show upon generating docs from jupyter notebook
@ritch @benjaminpkane

### Commands to reproduce

in notebook in docs/source/tutorials:
`import fiftyone as fo`
`import fiftyone.zoo as foz`
`dataset = foz.load_zoo_dataset("kitti-multiview")`
`session = fo.launch_app(dataset)`
`session.freeze()`

Then run `bash docs/generate_docs.bash` in terminal.

Attaching a screenshot. On the left is the "left" image. On the right should be the 3d visualizer. It appears without problem in the notebook, but turns blank upon generating html docs...

<img width="983" alt="Screenshot 2022-11-28 at 5 35 56 PM" src="https://user-images.githubusercontent.com/12500356/204395578-3497c670-0041-4eea-97a7-2768915fd1e8.png">

### What areas of FiftyOne does this bug affect?

-   [X] `App`: FiftyOne application issue
-   [ ] `Core`: Core Python library issue
-   [ ] `Server`: FiftyOne server issue



Discussion:

Resolving patch:
diff --git a/fiftyone/core/session/notebooks.py b/fiftyone/core/session/notebooks.py
--- a/fiftyone/core/session/notebooks.py
+++ b/fiftyone/core/session/notebooks.py
@@ -52,6 +52,7 @@ def display(
     funcs = {
         focx._COLAB: display_colab,
         focx._IPYTHON: display_ipython,
+        focx._DATABRICKS: display_databricks,
     }
     fn = funcs[focx._get_context()]
     fn(client, cell, reactivate)
diff --git a/fiftyone/core/session/session.py b/fiftyone/core/session/session.py
--- a/fiftyone/core/session/session.py
+++ b/fiftyone/core/session/session.py
@@ -881,7 +881,7 @@ def show(self, height: int = None) -> None:
             height = self.config.notebook_height
 
         uuid = str(uuid4())
-        self._notebook_cells[uuid] = fosn.NotebookCell(
+        cell = fosn.NotebookCell(
             address=self.server_address,
             handle=IPython.display.DisplayHandle(display_id=uuid),
             height=height,
@@ -889,7 +889,8 @@ def show(self, height: int = None) -> None:
             subscription=uuid,
         )
 
-        fosn.display(self._client, self._notebook_cells[uuid])
+        self._notebook_cells[uuid] = cell
+        fosn.display(self._client, cell)
 
     def no_show(self) -> fou.SetAttributes:
         """Returns a context manager that temporarily prevents new App
@@ -990,18 +991,18 @@ def _attach_listeners(session: "Session"):
     if focx.is_notebook_context() and not focx.is_colab_context():
 
         def on_capture_notebook_cell(event: CaptureNotebookCell) -> None:
-            fosn.capture(session._notebook_cells[event.subscription], event)
+            cell = session._notebook_cells.get(event.subscription, None)
+            if cell is not None:
+                fosn.capture(cell, event)
 
         session._client.add_event_listener(
             "capture_notebook_cell", on_capture_notebook_cell
         )
 
         def on_reactivate_notebook_cell(event: ReactivateNotebookCell) -> None:
-            fosn.display(
-                session._client,
-                session._notebook_cells[event.subscription],
-                reactivate=True,
-            )
+            cell = session._notebook_cells.get(event.subscription, None)
+            if cell is not None:
+                fosn.display(session._client, cell, reactivate=True)
 
         session._client.add_event_listener(
             "reactivate_notebook_cell", on_reactivate_notebook_cell


Test patch: