py-cell
and py-notebook
#1842
Replies: 4 comments 3 replies
-
is there a concept of cell orders and re-running cells would trigger rerunning all the downstream cells |
Beta Was this translation helpful? Give feedback.
-
A few personal thoughts around this proposal:
thoughts? |
Beta Was this translation helpful? Give feedback.
-
@JeffersGlass thanks for the write up! Geeking out on a Friday evening is easy but putting that into a proposal takes effort! 🙏 Given that we discussed it already, one can guess I'm aligned with most of it... So I just wanted to bring a few additional thoughts:
As I mentioned when we talked, I'm not entirely bought on the
Think that's a great starting point that we can build from. In general I think we should offer hooks and ways to plug in the
Again, not a big fan of Also, I'm +0 on the proposal of having a CustomElement and a
I'm really excited about it and I think we can come up with some really really cool way of delivering custom user experience depending on how users can customize their "notebook" concept. This is something I'd love to brainstorm and design. More specifically, how do we create a flexible framework to allow freedom during the exploration phase and easy to create fancy/powerful presentation of the results without too much effort. I'm sure threre's a sweet spot somewhere.
Yes!
I'm extremely debated about this one. On one hand I don't like the risk of inflating the page and the number of configs floating around BUT, at the same time, I don't have a good alternative of the flexibility of having everything needed in the page itself (which makes a good case for portability). I think this needs a bit more discovery...
-1 on just erroring. I think a |
Beta Was this translation helpful? Give feedback.
-
in order to work on this, I need to be sure we're all aligned in what we want:
|
Beta Was this translation helpful? Give feedback.
-
@fpliger and I had a great extended talk about the py-cell / py-notebook idea that's been kicking around for awhile - here's a proposal based on what we discussed.
Note: This prposal assumes that all execution by py-cells is in Workers. There are some use cases (i.e. the PyScript docs themselves) where a main-thread version could make sense, but I think let's focus on the API for Workers first, and then figure out the adjusted/reduced version for main thread.
py-cell
A py-cell is visual element represented by a CodeMirror Editor. Users may type code directly into the editor, and run it* by clicking an on-screen run button, or by hitting
shift+enter
. Developers can pre-load code into a py-cell by including code inside the relevant HTML tag, or by using itssrc
attribute.The py-cell is visually and conceptually similar to the
<py-repl>
tag from PyScript Classic; much of that code could likely be reused.*What it means to "run to the py-cell's code" is explored below.
HTML Tag
Question: What should the HTML tag be? Since the py-cell is ultimately a visual element, a custom element like
<py-cell>
would seem to make sense. However, if we want to have the functionality of developers being able to 'pre-enter' Python code into the cell in-line, then maybe<script type="py-cell">
is better to avoid parsing issues. Or maybe we should ditch the inline-code feature?py-notebook
A py-notebook is a collection of py-cells which share a common interpreter and its config. This allows developers to link several py-cells together to create multiple cohesive demos on a single page without them interfering with each other.
This page would contain two separate py-notebooks:
HTML Tag and Code Execution
The
<py-notebook>
custom element is a container for several py-cells (and other content, if desired). The first time a py-cell inside a given py-notebook is asked to execute code, an interpreter of the appopriate type is bootstrapped in a worker (presumably Pyodide, but we can imagine an<mpy-notebook>
in the future etc), using the available config, if any (see below)Once the interpreter is bootstrapped, any time a cell iin this notebook asked to execute code, it uses that same interpreter; i.e. it calls
my_interpreter.runAsync(code_in_the_codemirror)
. Thus, multiple py-cells inside a py-notebook share the same interpreter:Config
The
<py-notebook>
tag has aconfig
attribute that functions the same as our currentscript type="py"
tag's config attribute: it can take a URL pointing to a JSON or TOML file, or an inline representation of the same.Question: Should users be able to write a
<py-config>
tag inside a py-notebook tag and have the notebook use that tag?? It would obviously affect howscript type="py"
tags find their own configs on the page, since we'd want to ignore py-configs inside notebooks in that case... but if a<py-config>
tag is our promoted way of configuring interpreters, it might be nice to write one right into the HTMLOther Thoughts:
<py-notebook>
? One option is to just error; another is to treat it as if it had a "plain" notebook around it:notebook
on a py-cell could accomodate this:autogenerate
, scripts that run on interpreter bootstrap, save/import/export, etc.. However, I'd like to focus on this core proposal to start with, and get to those in future proposals.Beta Was this translation helpful? Give feedback.
All reactions