Skip to content

Commit

Permalink
Format black
Browse files Browse the repository at this point in the history
  • Loading branch information
pyiron-runner committed Jun 30, 2023
1 parent 24c62a1 commit 82fdcfd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
1 change: 1 addition & 0 deletions pyiron_contrib/workflow/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class NotData:
is provided; it lets the channel know that it has _no data in it_ and thus should
not identify as ready.
"""

pass


Expand Down
29 changes: 18 additions & 11 deletions pyiron_contrib/workflow/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@

from pyiron_contrib.workflow.node import Node
from pyiron_contrib.workflow.function import (
Function, SingleValue, Slow, function_node, slow_node, single_value_node
Function,
SingleValue,
Slow,
function_node,
slow_node,
single_value_node,
)
from pyiron_contrib.workflow.node_library import atomistics, standard
from pyiron_contrib.workflow.node_library.package import NodePackage
Expand Down Expand Up @@ -74,16 +79,16 @@ class Composite(Node, ABC):
# Allows users/devs to easily create new nodes when using children of this class

def __init__(
self,
label: str,
*args,
parent: Optional[Composite] = None,
strict_naming: bool = True,
**kwargs
self,
label: str,
*args,
parent: Optional[Composite] = None,
strict_naming: bool = True,
**kwargs,
):
super().__init__(*args, label=label, parent=parent, **kwargs)
self.strict_naming: bool = strict_naming
self.nodes: DotDict[str: Node] = DotDict()
self.nodes: DotDict[str:Node] = DotDict()
self.add: NodeAdder = NodeAdder(self)
self.starting_nodes: None | list[Node] = None

Expand All @@ -96,13 +101,15 @@ def to_dict(self):
@property
def upstream_nodes(self) -> list[Node]:
return [
node for node in self.nodes.values()
node
for node in self.nodes.values()
if node.outputs.connected and not node.inputs.connected
]

def on_run(self):
starting_nodes = self.upstream_nodes if self.starting_nodes is None \
else self.starting_nodes
starting_nodes = (
self.upstream_nodes if self.starting_nodes is None else self.starting_nodes
)
for node in starting_nodes:
node.run()

Expand Down
42 changes: 21 additions & 21 deletions pyiron_contrib/workflow/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ class Node(HasToDict, ABC):
"""
Nodes are elements of a computational graph.
They have input and output data channels that interface with the outside
world, and a callable that determines what they actually compute, and input and
output signal channels that can be used to customize the execution flow of the
graph;
world, and a callable that determines what they actually compute, and input and
output signal channels that can be used to customize the execution flow of the
graph;
Together these channels represent edges on the computational graph.
Nodes can be run to force their computation, or more gently updated, which will
Nodes can be run to force their computation, or more gently updated, which will
trigger a run only if the `run_on_update` flag is set to true and all of the input
is ready (i.e. channel values conform to any type hints provided).
Nodes may have a `parent` node that owns them as part of a sub-graph.
Nodes may have a `parent` node that owns them as part of a sub-graph.
Every node must be named with a `label`, and may use this label to attempt to create
a working directory in memory for itself if requested.
These labels also help to identify nodes in the wider context of (potentially
These labels also help to identify nodes in the wider context of (potentially
nested) computational graphs.
By default, nodes' signals input comes with `run` and `ran` IO ports which force
the `run()` method and which emit after `finish_run()` is completed, respectfully.
Nodes have a status, which is currently represented by the `running` and `failed`
By default, nodes' signals input comes with `run` and `ran` IO ports which force
the `run()` method and which emit after `finish_run()` is completed, respectfully.
Nodes have a status, which is currently represented by the `running` and `failed`
boolean flags.
Their value is controlled automatically in the defined `run` and `finish_run`
Their value is controlled automatically in the defined `run` and `finish_run`
methods.
This is an abstract class.
Expand Down Expand Up @@ -95,12 +95,12 @@ class Node(HasToDict, ABC):
"""

def __init__(
self,
label: str,
*args,
parent: Optional[Composite] = None,
run_on_updates: bool = False,
**kwargs,
self,
label: str,
*args,
parent: Optional[Composite] = None,
run_on_updates: bool = False,
**kwargs,
):
"""
A mixin class for objects that can form nodes in the graph representation of a
Expand Down

0 comments on commit 82fdcfd

Please sign in to comment.