Skip to content

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

@MatusGasparik

Description

@MatusGasparik

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions