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

[Viewer] Add native support of Jupyter and Google Colab #187

Merged
merged 11 commits into from
Aug 31, 2020
Merged

[Viewer] Add native support of Jupyter and Google Colab #187

merged 11 commits into from
Aug 31, 2020

Conversation

duburcqa
Copy link
Owner

@duburcqa duburcqa commented Aug 29, 2020

New features and improvements:

  • [Viewer] Native and full support of Jupyter, using directly kernel communication to avoid websockets and port forward all together. It should work on Google Colab but it cannot be tested easily (must be installed using wheel)
  • [Viewer] Remove the support of port forwarding, since it is not longer relevant
  • [Viewer] Create display cell in notebook mode when instantiating a viewer while no display cell is already available
  • [Viewer] Check for browser availability when calling 'open_gui', and wait for the client to be ready

Bug fixes and improvements:

  • [Viewer] Avoid timeout on low-hand machine while starting video recording
  • [Viewer] Improve the reliability of running Meshcat server detection. Remove heartbeat check since it is impossible to estimate appropriate response time (It can take a while if the meshes are already loading in a display cell for instance).

Various other minor fixes.

Side notes:

Bi-directional communication between frontend javascript and backend zmq is a bit tricky to achieve. It comes from the fact that the handling of incoming communications (including connection requests) are handled by the main thread, so it is not impossible to wait for a message through zmq socket, while waiting for an incoming reply from the kernel communications. More generally, it is impossible to do any multitasking, ie starting to monitor an new jupyter display while a replay loop is already running. Moreover, since the callback cannot interrupt the main thread, if the reply of a simulation has already started then a new display cell will stay empty since the opening notification will be received by the server only at the end. #stackoverflow #ipykernel

To circumvent those limitations, 'kernel.do_one_iteration' is interleaved 'zmq_socket.recv', so that incoming messages can be processed on the spot. The only issue doing this is that every request from the kernel will also be processed, including that queued cell evaluation. If there is any, it will corrupt the stack and Jupyter will throw an error (recoverable). It would be possible to avoid it by analysing the messages in the stack, only process 'comm_*', and put back in the stack the other ones. This is out of the scope of the PR. (UPDATE: Fixed by #190)

@duburcqa duburcqa changed the title WIP: [Viewer] Add native support of Jupyter and Google Colab [Viewer] Add native support of Jupyter and Google Colab Aug 31, 2020
@duburcqa duburcqa merged commit b2b0b9c into duburcqa:dev Aug 31, 2020
@duburcqa duburcqa mentioned this pull request Aug 31, 2020
@duburcqa duburcqa deleted the viewer_colab branch August 31, 2020 18:18
duburcqa added a commit that referenced this pull request Aug 31, 2020
* [Viewer] Native and full support of Jupyter and Google Colab, using directly kernel communication
* [Viewer] Remove the support of port forwarding, since it is not longer relevant
* [Viewer] Create display cell in notebook mode when instantiating a viewer while no display cell is already available
* [Viewer] Check for browser availability when calling 'open_gui', and wait for the client to be ready
* [Viewer] Avoid timeout on low-hand machine while starting video recording
* [Viewer] Improve the reliability of running Meshcat server detection.
* [Viewer] Remove heartbeat check since it is impossible to estimate appropriate response time

Co-authored-by: Alexis Duburcq <alexis.duburcq@wandercraft.eu>
duburcqa added a commit that referenced this pull request Aug 31, 2020
* [Viewer] Native and full support of Jupyter and Google Colab, using directly kernel communication
* [Viewer] Remove the support of port forwarding, since it is not longer relevant
* [Viewer] Create display cell in notebook mode when instantiating a viewer while no display cell is already available
* [Viewer] Check for browser availability when calling 'open_gui', and wait for the client to be ready
* [Viewer] Avoid timeout on low-hand machine while starting video recording
* [Viewer] Improve the reliability of running Meshcat server detection.
* [Viewer] Remove heartbeat check since it is impossible to estimate appropriate response time

Co-authored-by: Alexis Duburcq <alexis.duburcq@wandercraft.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant