You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Great project.
I'd like to make a 'plugin' on top of the starboard notebook. However, for this I'd like to run Python code without interacting and displaying it in the notebook cells. So when e.g. a notebook cell contains python code 'x=1' and has been normally run I'd like to access these variables. I know that in Pyodide this is possible by just running running seperate runPython commands to write and read variables ,e.g.:
I know when using the barebones demo it is hard to do this due to the iFrame restrictions. I'm now running StarBoard Notebook without an iFrame and I can access the variable 'runtime' to control StarBoard (I'm aware of the security risks).
So ideally I would run Python code - to extract data from the notebook cells - outside the notebook cells from javascript.
Either directly through Pyodide or through the Notebook's runtime.
When for example using the Python Pandas library in the notebook cells I can extract in the background the column names of a Pandas Dataframe, and display those in a sidebar.
I've been trying to find how to do this from the starboard-python and starboard-notebook source code.
I guess it can be done through 'runPythonAsync' or 'runPython', but I don't know how to access these function from a js script in the browser. (Sorry I'm strong Python and a bit of an JS/TS noob).
I guess to directly access the Pyodide variable it depends also if Pyodide is running in the maintread or in a web worker. Today I was able to access the 'pyodide' variable in the Chrome Console, but somehow I cannot replicate it. I think the notebook was initialized to run python in the maintread.
I guess if the runPython functionality can be exposed through the 'runtime' it would make it possible to create a lof of other creative plugins/ applications on top of this.
The text was updated successfully, but these errors were encountered:
The current version of pyodide, when run in the main thread (it is now actually possible to run pyodide in a webworker too, but the default is main thread), adds a variable on window called pyodide. So you could do this:
I can't promise that this wont' break in some future version, but I imagine a variant of this will still exist.
I know when using the barebones demo it is hard to do this due to the iFrame restrictions. I'm now running StarBoard Notebook without an iFrame and I can access the variable 'runtime' to control StarBoard (I'm aware of the security risks).
You can definitely do this within an iframe too, you would usually make a plugin that customizes the notebook how you want it. Anyway for version 1 non-iframe mode is fine, also if your website otherwise is stateless anyway there is no risk (i.e. there is no login to abuse).
Thanks for the swift feedback. :-)
I'm able to run the code from the notebook cells, but I'm not able to access pyodide outside the cells (e.g. from the Chrome Developers console.
Sorry, I'm too in experienced outside my Python backend skills. Time to learn some more JS/TS and write plugins for StarBoard haha.
Your notebook runs in an iframe in the browser for sandboxing purposes. That sandbox will have its own environment, so you have to set your browser console to that context. In chrome you do it here:
Great project.
I'd like to make a 'plugin' on top of the starboard notebook. However, for this I'd like to run Python code without interacting and displaying it in the notebook cells. So when e.g. a notebook cell contains python code 'x=1' and has been normally run I'd like to access these variables. I know that in Pyodide this is possible by just running running seperate runPython commands to write and read variables ,e.g.:
I know when using the barebones demo it is hard to do this due to the iFrame restrictions. I'm now running StarBoard Notebook without an iFrame and I can access the variable 'runtime' to control StarBoard (I'm aware of the security risks).
So ideally I would run Python code - to extract data from the notebook cells - outside the notebook cells from javascript.
Either directly through Pyodide or through the Notebook's runtime.
When for example using the Python Pandas library in the notebook cells I can extract in the background the column names of a Pandas Dataframe, and display those in a sidebar.
I've been trying to find how to do this from the starboard-python and starboard-notebook source code.
I guess it can be done through 'runPythonAsync' or 'runPython', but I don't know how to access these function from a js script in the browser. (Sorry I'm strong Python and a bit of an JS/TS noob).
I guess to directly access the Pyodide variable it depends also if Pyodide is running in the maintread or in a web worker. Today I was able to access the 'pyodide' variable in the Chrome Console, but somehow I cannot replicate it. I think the notebook was initialized to run python in the maintread.
I guess if the
runPython
functionality can be exposed through the 'runtime' it would make it possible to create a lof of other creative plugins/ applications on top of this.The text was updated successfully, but these errors were encountered: