pythonflow icon indicating copy to clipboard operation
pythonflow copied to clipboard

Evaluating operations outside the `with` block in Jupyter Notebook grows the `graph.operations` dict

Open MatusGasparik opened this issue 1 year ago • 0 comments

This seem like a bug, and probably related to fact that I am running this in a jupyter notebook. Given this example:

import pythonflow as pf

with pf.Graph() as graph:
    a = pf.constant(4, name='a')
    b = pf.constant(38, name='b')
    x = (a + b).set_name('x')

looking at the graph.operations looks fine initially:

{'a': <pf.func_op 'a' target=<function identity at 0x106500310> args=<1 items> kwargs=<0 items>>,
 'b': <pf.func_op 'b' target=<function identity at 0x106500310> args=<1 items> kwargs=<0 items>>,
 'x': <pf.func_op 'x' target=<built-in function add> args=<2 items> kwargs=<0 items>>}

However, if I evaluate any of the Operation instances in the notebook cell (e.g. a or b at the end of the cell) the dictionary with graph.operations grows with additional items (and continues growing by a dozen new getattr operations every time I evaluate any of the operations)

Here a screenshot that is self-explaining:

image

Is there a way to prevent this behavior?

MatusGasparik avatar May 09 '23 13:05 MatusGasparik