Dependencies and the Cell Toolbar

Dependencies in the notebook will execute upstreams if the code in an upstream cell changes. Code caches are checked to ensure that everything stays up to date.

In [f9cfcd]:
from IPython.display import Image
Image:
IPython.core.display.Image
In [c4ae59]:
a = 3
a:
3
In [e26943]:
b = a+2
b:
5

Upon changing a to be a different value such as a=2 and executing Cell[e26943], Cell[c4ae59] will immediatly execute to ensure that b now returns 6 instead.

How this works: To ensure that the ``a`` being referenced is the proper ``a`` we have enforced a variable name lockdown. That means that any attempts to reassign a will result in failure. However this only happens at the final output stage, every cell in the Dataflow kernel is a closure.

In [d7c413]:
a = 4
---------------------------------------------------------------------------
DuplicateNameError                        Traceback (most recent call last)
DuplicateNameError: name 'a' has already been defined in Cell 'c4ae59'

Defining every cell as a closure allows for more interesting behavior but the user has to be careful as the a in the folowing case is considered to be a local variable.

In [dd9629]:
a = 5
c = a+4
c:
9

However you can ensure that you are referring to the correct a by the use of the following keywords global and nonlocal.

In [ccf913]:
global a
a = 6
d = a+3
d:
6

In the following case a user may want to refer to a locally declared variable a inside a function or class and switch between this locally declared variable and one that is in the global namespace.

In [c08a91]:
a = 6

class g():
    def __init__(self):
        self.f()
        self.g()
    def f(self):
        nonlocal a
        print(a)
    def g(self):
        global a
        print(a)
g()
6
3
Out[c08a91]:
<__main__.__closure__.<locals>.g at 0x7f49dc5fa6a0>

Cell Toolbars

To allow users an easy way to get an overview of the upstream and downstream dependencies we’ve provided a cell toolbar that is enabled from the view dropdown.

In [df4af9]:
CellToolBar = Image(url='https://rawgit.com/colinjbrown/dfkernel/documentation-update/docs/tutorial/img/enabletoolbar.png')
CellToolBar:

Upon enabling the dataflow toolbar and executing the cells below we get an overview of the dependencies in each cell as well as the ability to toggle refresh states.

In [ed0889]:
x = a+10
y = b+4
x,y
x:
13
y:
9
In [a6cb70]:
z = x+y
z:
22
In [d8a75f]:
CellToolBarOpen = Image(url='https://rawgit.com/colinjbrown/dfkernel/documentation-update/docs/tutorial/img/cells_displayed.png')
CellToolBarOpen:

In this menu by clicking on you are able to use the cached version of this cell, anything that is retrieved from this cell will be from the last run.

While clicking on will make sure that if a cell that is upstream of this cell executes that you want this downstream cell to also execute.

If a user clicks on all of the cells that are upstream from this cell will be selected in the notebook.

Where as if a user clicks on all of the cells that are downstream from this cell will be selected instead.

Note: The Auto-Refresh on downstream is setup this way because it’s not explicit that a user would want a downstream cell to be re-executed or not, all cells upstream of a cell have to be re-executed to be considered valid.