pyiron / pyiron_workflow

Graph-and-node based workflows
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

iPython not playing nicely with node injection #253

Closed liamhuber closed 3 months ago

liamhuber commented 3 months ago

I discovered today that iPython is not playing well with node injection, in particular the GetAttr injection.

This is totally fine:

from pyiron_workflow import Workflow
wf = Workflow("tmp")
wf.foo = Workflow.create.standard.UserInput("some_value")
print(wf.node_labels)
>>> ('foo',)
wf.foo
print(wf.node_labels)
>>> ('foo',)

Exactly as expected. But, if you split it into two cells, iPython is doing some attribute access nonsense that winds up injecting an extra node!

Cell 1: as expected

from pyiron_workflow import Workflow
wf = Workflow("tmp")
wf.foo = Workflow.create.standard.UserInput("some_value")
print(wf.node_labels)
>>> ('foo',)
wf.foo

Cell 2: reveals the problem

print(wf.node_labels)
>>> ('foo', 'foo__user_input_GetAttr__ipython_canary_method_should_not_exist_')

This doesn't functionally impact us by breaking anything, because these are just little dead-end nodes, but it is certainly undesirable and bloats storage, etc.