Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] [pydeck] Propagate Javascript errors to notebook cells when using pydeck in Colab #9370

Open
bijanvakili opened this issue Jan 21, 2025 · 0 comments
Labels

Comments

@bijanvakili
Copy link

bijanvakili commented Jan 21, 2025

Target Use Case

A common experience with using pydeck are silent failures. This occurs when running code in a python notebook but seeing no output (a blank output cell). What is actually occurring is that the IPython.display.HTML object has encountered a Javascript error during its render (display) operation. This error is not propagated from the client browser to the python notebook runtime.

The only way to discover this error is to review the browser’s Javascript console output (for example, manually opening the Console panel from Chrome’s Dev Tools). This creates friction for python notebooks as it takes the user outside their normal workflow.

Examples of this friction can be seen from issues filed for pydeck:

Proposal

A better user experience would be to display the Javascript error and fail the notebook cell operation. Notebook users would get feedback immediately so as to fix their code or, more typically, their deck.gl layer parameters.

pydeck already has logic here to detect the google.colab package. This can be extended to use Colab's Javascript to Python communication.

More specifically:

  1. pydeck.deck.Deck.show can be extended to register callbacks with google.colab.output.register_callback
  2. The HTML rendered index.j2 Jinja template can be extended to set up event handlers to listen to both the Deck.onAfterRender and Deck.onError events.
  3. Console errors can then be propagated from the client browser back to the python notebook runtime.
  4. The receiver callback registered in step 1n can raise a python exception to propagate the error back to the user and fail the notebook’s cell operation.

If synchronization is required, a python condition object can be used to ensure safe waiting on these messages.

Optional If google.colab is unavailable, the Jinja template can still be modified to at least display the Javascript error in a <div/> or <code/> HTML element. Although the error is still displayed to the user immediately, the only drawback of this approach is that the notebook’s cell operation will not be marked as an error (a false positive). Still, showing output is still a major UX improvement over the current behavior of no output.

@bijanvakili bijanvakili changed the title [Feat] Propagate Javascript errors to notebook cells when using pydeck in Colab [Feat] [pydeck] Propagate Javascript errors to notebook cells when using pydeck in Colab Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant