davidbrochart / akernel Goto Github PK
View Code? Open in Web Editor NEWAsynchronous Python Jupyter kernel
License: MIT License
Asynchronous Python Jupyter kernel
License: MIT License
Hi @davidbrochart!
It turns out that akernel actually solves the issue with the widget we are building. We can use await
to call async methods on our widget and the akernel isn't blocked unlike the default one:
Do you think there is a chance of these changes being accepted into the default ipykernel?
Our widget calls self.send(msg)
without passing buffers
and we are hitting this error:
It works just fine if we use self.send(msg, buffers=[])
instead, but I think akernel should also handle buffers=None
.
Actually, send_message
in akernel has a mutable default list argument for buffers
which is problematic. It should probably just have a check if buffers to is not None
instead
I'm curious how this interacts with global
variables inside a function inside a cell, for example:
a = 1
def f():
global a
a = 5
f()
print(a)
This prints out 5
with the current ipykernel, which is what I would expect.
Currently the code is made async by direct manipulation of the code string. This is not robust, we should use the ast
module instead.
If a cell takes a while to calculate it would be nice to highlight updating/stale cells.
Cells 1 and 3 should be marked while cell 2 is working:
Maybe with colors similar to nbsafety:
https://nbsafety.org/docs/#Running
Or with grey gutter line like in observablehq:
https://observablehq.com/d/797362a5c2538221
Such as +=
, etc.
This can be seen with the following code where "f" is printed twice:
def f(x):
print("f")
return x + 1
b = f(a)
b
a = 0
This doesn't happen in ipyx
.
Currently, an already defined variable a
is not wrapped with ipyx.X(a)
, but kept as-is. It shouldn't be the case because then it means that y = a + 1
is not updated when a
changes.
This implies that all variables must be accessed with their .v
attribute, not only when they are in the RHS of an assignment.
We should have a mapping of original code to transformed code, in terms of line numbers, in order to make traceback generation easier. Right it is kind of hacky.
Currently, with e.g. a reactive variable y
defined as:
y = x + 1
One needs to delete it before redefining it, e.g.:
del y # currently needed
y = x + 2
It should be automatically deleted when redefined.
How can I access the information about dependencies of akernel to use it for JupyterLab extensions?
What would be the right entry point for that?
Lets say I have a JupyterLab extension that is able to access a notebook cell model:
let notebook = __tryToGetNotebook(app);
if(notebook){
let cellModels = notebook.model.cells
for(let cellIndex=0; cellIndex < cellModels.length; cellIndex++){
let cellModel = cellModels.get(cellIndex);
let dependencies = __getDependencies(cellModel, notebook); //<= how to implement this?
}
}
=> Is it possible to ask the cell for its dependencies? Or would I have to somehow directly communicate with akernel or ipyx?
Related:
Some possible use cases:
A. Show neighboring cell dependencies in a dependency view when focusing a distinct cell.
The corresponding terms in obsservablehq are "Visual Dataflow" and "Minimap":
https://observablehq.com/@observablehq/introducing-visual-dataflow
B. Generate a full dependency graph
Could look similar to
https://observablehq.com/@observablehq/notebook-visualizer
https://observablehq.com/@observablehq/notebook-visualizer-elk-edition
C. Generate editable flow chart from akernel notebook cells
Maybe combine akernel with a view of ipyspaghetti or node-red, so that a user gets an alternative GUI to edit the notebook cells in some sort of flow chart.
https://github.com/cphyc/ipyspaghetti
D. Navigate between dependent cells.
Similar to the navigation features in a code IDE, the dependency information could be used to
https://www.jetbrains.com/help/pycharm/navigating-through-the-source-code.html#go_to_declaration
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.