microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 293 forks source link

VPython doesn't seem to work in vscode cell #1477

Closed tomasderner97 closed 2 years ago

tomasderner97 commented 5 years ago

VPython does weird things in vscode jupyter cell. Normally in jupyter, when you run

import vpython
vpython.box()

an interactive output shows up with a movable and rotatable cube (doesn't require an extension). In vscode cell or interactive console, vpython.box() doesn't ever finish, the cell number has a star in it. Does vpython do something currently unsupported by vscode or is this fixable?

IanMatthewHuff commented 5 years ago

@tomasderner97. Right now the interactive window supports a specific set of Jupyter output types. From my quick check it looks like vpython is one of the interactive types that don't work currently. We are considering some future work for getting these interactive types to work, but it's currently unsupported.

MossiAhmadi commented 3 years ago

@DonJayamanne , could you please kindly let me know if the VPython integration will come to vscode any time soon? I am designing a course for my students and it would be nice if I can teach them VPython in vscode. Thank you for helping to bring VPython to vscode.

DonJayamanne commented 3 years ago

Thanks for pining us back, I've checked this and it is still (obviously) not working. I'll bring this up with the team to try and prioritize this work.

From what I can tell we're not handling a message.

Notes for the team: Also looks like we aren't picking up scripts from nbextensions/xyz/index. I've seen this for vega as well. We could instead add a hook when require.js tries to fetch these scripts we can try to look for them in the extension host and return the response as and when requested. I.e. broaden the way we look for scripts for scenarios where widgets have require('nbextensions/xyz/index')

MossiAhmadi commented 3 years ago

Thank you Don for prioritizing the case. VPython has always been messy since it requires the browser to open to view the physics simulations outputted by VPython. Bringing it to VSCode interactive window will be a revolutionary idea to teach physics coding with ease. I will enquire about the implementation process here in github once every two months. I hope VPython will be implemented in VSCode python interactive and VSCode jupyter notebook in the next four months. Also, is it possible to contact the team taking care of VPython implementation directly - or a dedicated VPython VSCode github page -, for instance to view the power of VSCode to do VPython simulations with ease or a place for suggesting further improvements?

DonJayamanne commented 3 years ago

Notes for team (internal notes)

define(["base/js/utils",
        "nbextensions/vpython_libraries/plotly.min",
        "nbextensions/vpython_libraries/glow.min",
        "nbextensions/vpython_libraries/jquery-ui.custom.min"], function(utils, Plotly) {

var comm
var ws = null
var isopen = false

window.Plotly = Plotly

console.log('START OF GLOWCOMM')

IPython.notebook.kernel.comm_manager.register_target('glow',

Problems:

DonJayamanne commented 3 years ago

Also related https://github.com/microsoft/vscode-jupyter/issues/6054

MossiAhmadi commented 3 years ago

Could you please kindly let me know if VPython will be integrated into Jupyter vsocde anytime soon?

DonJayamanne commented 3 years ago

I'm sorry got not getting back to you. Looking at VPython code, I've learnt that vpython is using some non-standard techniques to communicate with the kernel (by directly setting up socket connections instead of going via the kernel communications as other widgets). This artchitecture will not be supported in VS Code as we do not setup socket connections like Jupyter labs/notebooks. Having spoken to some of the maintainers of ipywidgets too I've learnt this current approach (using direct socket connections) isn't the best.

MossiAhmadi commented 3 years ago

OK. Thank you for the update.

DonJayamanne commented 2 years ago

Closing this issue as there's nothing we can do about this, due to the way the vpython widget is written. Summary - vpython uses a non standard way to communicate with the backend kernel by creating other sockets.