Dataflow Kernel Tutorial¶
Controlling Output references¶
In the Dataflow Kernel there are several different ways to export your variables into the current namespace that you’re working in. Any unnamed type will simply be given a persistent identifier that matches the persistent cell identifier that the input is given.
You can also give an output a tag by assigning a name to it, as long as the variable has a name we can just export that into the namespace.
a = 3
All names are considered persistent throughout the notebook, this means if you try and reassign it in a different cell you’ll get an error however, this can be resolved by simply deleting that cell and you’ll be able to redefine that name in any other cell.
a = 4
--------------------------------------------------------------------------- DuplicateNameError Traceback (most recent call last) DuplicateNameError: name 'a' has already been defined in Cell 'aabe16'
You can also assign multiple variables at once as long as you pass multiple references.
c,d = 3,4
e,f = 5,6 e,f
In the case of mixed named and unnamed variables the named variables will be pulled out by their variable names and any unnamed variables will be given the ability to be referenced through bracket notation.
g,h = 5,6 g,h,[2,3]
Since a user might want to split out a dictionary into multiple variables we’ve provided methods for that.
NOTE: In versions of Python below 3.6 tags are not guaranteed to be in order as dict keys have no guaranteed ordering and if you desire your keys to be in order we suggest the user of ``OrderedDict``.
The Dataflow kernel allows for several different methods of accessing exported variables in the notebook. Completion is enabled for only the last cell in the most current revision, despite this cells and tags that have been exported can all be autocompleted by using the completer.
m = 4
n,o = 1,2
When a cell has multiple tags the completer will produce a tuple of the outputs
A cell can also still be addressed as it’s original output tag if desired but this behavior is discouraged unless the user needs to reference outputs this way.
In the example below typing
f2c and hitting
<tab> will result in
Auto-Parse Library functionality¶
To make life easier on users we came to the conclusion that libraries should be parsed out at a local level because writing extra code to specifically export libraries slows users down.
So even when you write only assignments the library will be parsed out and become attached to that cell.
import sys p = 3
<module 'sys' (built-in)>
However, when you access the cell or try to reference it, it will perform in the same way you expected before so it doesn’t become a problem when referencing objects.
It also performs the same way when you have multiple tags but is instead referenced as a tuple.
import os q,r = 1,2
<module 'os' from '/home/colin/anaconda3/envs/noglobals/lib/python3.6/os.py'>