pyiron / pyiron_workflow

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

Edge case where semantic labels are not unique in their scope #431

Open liamhuber opened 3 months ago

liamhuber commented 3 months ago

We promise that child labels are unique inside their scope, such that they have a unique semantic path -- and this is true through adding and removing children, assigning children to parent attributes, etc... but there's nothing stoping a user from just manually breaking it by assigning nonsense to .label:

from pyiron_workflow import Workflow

wf = Workflow("tmp", delete_existing_savefiles=True)
wf.a = Workflow.create.standard.UserInput(42)
wf.b = Workflow.create.standard.UserInput(43)

wf.a.label = "b"

print(wf.child_labels)
>>> ('b', 'b')

And as bad/worse:

print(wf.a.full_label)
>>> '/tmp/b'

The silver lining is that if you actually try to run such a workflow it fails hard (although not with a particularly informative error message), so at least it's wrong in a catestrophic way rather than a sneaky way.