Skip to content

Commit

Permalink
fix(pydeck): Fix cell height in Google Colab (#8881)
Browse files Browse the repository at this point in the history
* fix(pydeck): Fix cell height in Google Colab
* docs(pydeck): Add documentation about testing local changes in Google Colab
  • Loading branch information
donmccurdy committed May 10, 2024
1 parent 86f3f84 commit 950d666
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
35 changes: 34 additions & 1 deletion bindings/pydeck/docs/contributing.rst
Expand Up @@ -36,7 +36,40 @@ enable pydeck to run on JupyterLab and Jupyter Notebook locally:
make init
make prepare-jupyter
At this point, verify that this new local copy of pydeck works by running ``make test``.
Verify that this new local copy of pydeck works by running ``make test``.

Local development in Jupyter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To test local changes to Pydeck in a Jupyter notebook, set up a virtual environment as
described above, then start a local Jupyter notebook:

.. code-block:: bash
jupyter notebook
.. CAUTION::
Additional steps (TODO) required to include local changes to deck.gl in a local Pydeck build.

Local development in Google Colab
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To test local changes to Pydeck in a Google Colab notebook, first start a Jupyter runtime with
additional flags to trust WebSocket connections from the Colab frontend:

.. code-block:: bash
jupyter notebook \
--NotebookApp.allow_origin='https://colab.research.google.com' \
--port=8888 \
--NotebookApp.port_retries=0
After the notebook starts, copy the full (localhost) URL printed to the console. In a Google
Colab notebook, select *Connect to a local runtime* from the additional connection options
dropdown, and provide the local URL when prompted. After a reload, the Colab notebook will have
access to the local Jupyter runtime and its local Pydeck build.

For more information, refer to Google Colab's `documentation for local runtimes <https://research.google.com/colaboratory/local-runtimes.html>`__.

Submitting a PR
^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion bindings/pydeck/pydeck/io/html.py
Expand Up @@ -113,7 +113,7 @@ def iframe_with_srcdoc(html_str, width="100%", height=500):
def render_for_colab(html_str, iframe_height):
from IPython.display import HTML, Javascript # noqa

js_height_snippet = f"google.colab.output.setIframeHeight({iframe_height}, true, {{minHeight: {iframe_height}}})"
js_height_snippet = f"google.colab.output.setIframeHeight({iframe_height}, true, {{minHeight: {iframe_height}, maxHeight: {iframe_height}}})"
display(Javascript(js_height_snippet)) # noqa
display(HTML(html_str)) # noqa

Expand Down

0 comments on commit 950d666

Please sign in to comment.