Often you are doing one of 2 things:
* Building a larger example from many small cells.
* Showing many small isolated examples.
The default so far has followed iPython, where cells are connected
by default (in its case, the interpreter state backing them sticks
around).
This change adds a new magic `%config` where you can change the setting
`cellreset` to change that behaviour (this is currently the only setting).
Also added is a `%noreset` magic so that along with `%reset` you can
override the default for one particular cell.
The default is equivalent to `%config cellreset off`. If you then
wanted to reset in a cell, you can just do %reset to override it.
(this is what the current notebooks do)
If you instead do `%config cellreset on`, cells always reset and
you can choose not to using `%noreset`.
The setting is named `cellreset` not `reset` to differentiate it
a bit more from the one off command `reset`.
The demo notebook has been updated with examples of this in action.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D149055
Previously the kernel.json would always point to `python3` even if you
installed using a python from a virtualenv. This meant that tools like VSCode
would try to run the kernel against the system python and fail.
Added a note to the readme about it. I've removed the need to
add to PYTHONPTHON as well, turns out it wasn't needed.
This fixes an issue reported in https://discourse.llvm.org/t/tablegen-the-playground-ipynb-file-is-not-working-as-expected/71745.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D154351
Previously this message was only shown on the command line,
which is not much help if you can't see that.
(you've full screened the browser or you aren't running Jupyter
on the same machine)
Instead return the error as stderr which will get printed in
the notebook just like stderr from llvm-tblgen would.
I've refactored the message sending along the way. Note that
even when we do not send a stream, we still need to send the
status reply. The send_... methods will do that for you.
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D142531
This changes the default mode to cache the code blocks we're
asked to compile until we see the new `%reset` magic to clear that cache.
This means that if you run several cells in sequence, at the end you're
compiling the code from all the cells at once.
This emulates what the ipython kernel does where it uses a persistent
interpreter state by default.
`%reset` will only be acted on when it's in the cell we're asked to run
(the newest code).
`%args` we will use the most recent value we have cached.
The example notebook has been updated to explain that.
Depends on D132378
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D132646
This is based on the MLIR opt kernel:
https://github.com/llvm/llvm-project/tree/main/mlir/utils/jupyter
The inent of this is to enable experimentation and the creation
of interactive tutorials for the basics of tablegen.
Noteable changes from that:
* Removed the codemirror mode settings since those won't exist
for tablegen.
* Added "%args" "magic" to control arguments sent to llvm-tblgen.
(magics are directives, see
https://ipython.readthedocs.io/en/stable/interactive/magics.html)
For example the following:
```
%args --print-detailed-records
class Stuff {}
def water_bottle : Stuff {}
```
Produces:
```
DETAILED RECORDS for file -
-------------------- Global Variables (0) --------------------
-------------------- Classes (1) --------------------
Stuff |<stdin>:1|
Template args: (none)
Superclasses: (none)
Fields: (none)
-------------------- Records (1) --------------------
water_bottle |<stdin>:3|
Superclasses: Stuff
Fields: (none)
```
Reviewed By: jpienaar, awarzynski
Differential Revision: https://reviews.llvm.org/D132378