In [ ]:
"""Run this cell to add the start_new_dagpy_block to you namespace. Call it from any cell to start a new block there."""
from IPython.display import display_javascript
def start_new_dagpy_block():
header_code = """### Block_id\\n\\n##### Description\\n\\n##### Parents\\n\\n##### Filter\\n\\n##### File\\n"""
display_javascript("""var t_cell = IPython.notebook.get_selected_cell()
var t_index = IPython.notebook.get_cells().indexOf(t_cell)-1
var t_cell = IPython.notebook.get_cell(t_index)
t_cell.set_text("{header_code}");
t_cell.metadata = {{"dagpy": {{"cell_type": "delimiter"}}}};
IPython.notebook.to_markdown(t_index);
IPython.notebook.get_cell(t_index).render();""".format(header_code = header_code), raw=True)
In [1]:
# DAGpy input filter
import dill
In [2]:
var_a = 5
In [3]:
print('var_a = {}'.format(var_a))
In [4]:
# DAGpy output filter
# To change the filter, edit the block properties, not this cell.
import dill
import os
os.makedirs(os.path.dirname('cache/A_var_a.dill'), exist_ok=True)
dill.dump(var_a, open('cache/A_var_a.dill', 'wb+'))
In [1]:
# DAGpy input filter
import dill
A_var_a = dill.load(open('cache/A_var_a.dill','rb'))
In [2]:
var_b = A_var_a / 2
In [3]:
print('var_b = {}'.format(var_b))
In [4]:
# DAGpy output filter
# To change the filter, edit the block properties, not this cell.
import dill
import os
os.makedirs(os.path.dirname('cache/B_var_b.dill'), exist_ok=True)
dill.dump(var_b, open('cache/B_var_b.dill', 'wb+'))
In [1]:
# DAGpy input filter
import dill
A_var_a = dill.load(open('cache/A_var_a.dill','rb'))
In [2]:
var_c = A_var_a * 2
In [3]:
print('var_c = {}'.format(var_c))
In [4]:
# DAGpy output filter
# To change the filter, edit the block properties, not this cell.
import dill
import os
os.makedirs(os.path.dirname('cache/C_var_c.dill'), exist_ok=True)
dill.dump(var_c, open('cache/C_var_c.dill', 'wb+'))
In [1]:
# DAGpy input filter
import dill
B_var_b = dill.load(open('cache/B_var_b.dill','rb'))
C_var_c = dill.load(open('cache/C_var_c.dill','rb'))
In [2]:
print('var_b = {}'.format(B_var_b + C_var_c))
In [3]:
# DAGpy output filter
# To change the filter, edit the block properties, not this cell.
import dill
import os