Skip to content

Commit

Permalink
Use a more specific name
Browse files Browse the repository at this point in the history
We might have a storage root, etc. Also, the graph and the semantics are not identical, as multiple workflows might have a semantic (but not operational) interaction, so then we'd care about a semantic root! Plus it makes find-usages easier on the IDE when we have a more specific name.
  • Loading branch information
liamhuber committed Jan 18, 2024
1 parent 874aaff commit 9e0a9d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pyiron_workflow/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Node(HasToDict, ABC, metaclass=AbstractHasPost):
owning this, if any.
ready (bool): Whether the inputs are all ready and the node is neither
already running nor already failed.
root (Node): The parent-most node in this graph.
graph_root (Node): The parent-most node in this graph.
run_args (dict): **Abstract** the argmuments to use for actually running the
node. Must be specified in child classes.
running (bool): Whether the node has called :meth:`run` and has not yet
Expand Down Expand Up @@ -318,9 +318,9 @@ def parent(self, new_parent: Composite | None) -> None:
)

@property
def root(self) -> Node:
def graph_root(self) -> Node:
"""The parent-most node in this graph."""
return self if self.parent is None else self.parent.root
return self if self.parent is None else self.parent.graph_root

@property
def readiness_report(self) -> str:
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/test_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,24 +598,24 @@ def test_root(self):

self.assertIs(
top,
top.root,
msg="The parent-most node should be its own root."
top.graph_root,
msg="The parent-most node should be its own graph_root."
)
self.assertIs(
top,
top.middle_composite.root,
msg="The parent-most node should be the root."
top.middle_composite.graph_root,
msg="The parent-most node should be the graph_root."
)
self.assertIs(
top,
top.middle_function.root,
msg="The parent-most node should be the root."
top.middle_function.graph_root,
msg="The parent-most node should be the graph_root."
)
self.assertIs(
top,
top.middle_composite.deep_node.root,
msg="The parent-most node should be the root, recursively accessible from "
"all depths."
top.middle_composite.deep_node.graph_root,
msg="The parent-most node should be the graph_root, recursively accessible "
"from all depths."
)


Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,9 @@ def test_root(self):
n = ANode("n")
self.assertIs(
n,
n.root,
msg="Lone nodes should be their own root, as there is no parent above."
n.graph_root,
msg="Lone nodes should be their own graph_root, as there is no parent "
"above."
)


Expand Down

0 comments on commit 9e0a9d6

Please sign in to comment.