Closed christian-oreilly closed 5 months ago
Let me wrap this also in this issue to avoid creating another issue just for that: The run_custom_code
also seems to fail to return values. Printing is_pial
in this example currently gives me None
. With fixing this, we should add a test for pytest that avoids code regression on that. This is a fairly simple test to add.
Thank you for bringing this up. run_custom_code
does not work online Jupyter environments, such as Google Colab, due to the way online Jupyter handles concurrent execution. See https://github.com/Kirill888/jupyter-ui-poll/issues/23#issuecomment-1321256681 for more info.
Concerning ipyniivue, we can either add note to the documentation specifying that run_custom_code
(and therefore all getters that use run_custom_code
) do not work in online Jupyter environments.
Alternatively, we could explore implementing some solution that runs in online Jupyter environments. Currently, I don't know of any ways to do this.
What is the difference between local and "online" Jupyter environments exactly? The issue you referred to seems to make a difference between ipykernel
(works) and jupyterlite
(does not work). I may be mistaken but I did not see any clear restrictions (except in the version maybe) for ipykernel
on the Colab...? Also, jupyter-ui-poll
seems to work on Colab (https://github.com/Kirill888/jupyter-ui-poll/issues/18). It seems like there was some issues with ipykernel
4.x, which was the default for Colab at the time the ticket was created, but the current version is now 5.5.6.
I see, I think I was confused with JupyterLite and Google Colab, and just assumed they used the same kernel. I'll have to do more testing to see if I can get run_custom_code to work in Colab then. The reason it takes at most 60 seconds to run the run_custom_code function is because it times out at 60 seconds.
So, a deeper issue is the transparency of JS errors from Python side. This should cause a timeout exception on Python side so that the user knows what is happening.
The following code
launched on Google Colab takes about 60s to run. My understanding is that this code just checks if "pial" is a mesh extension, which should be a very fast operation. All similar calls seem to be that slow. This can be tested using the example notebook on running custom code.