Skip to content

Commit f711b4b

Browse files
authored
Move NOT_DATA to its own module (#746)
Signed-off-by: liamhuber <[email protected]>
1 parent fe9d937 commit f711b4b

File tree

20 files changed

+60
-50
lines changed

20 files changed

+60
-50
lines changed

notebooks/deepdive.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
}
2323
},
2424
"source": [
25-
"import pyiron_workflow as pwf"
25+
"import pyiron_workflow as pwf\n",
26+
"import pyiron_workflow.data"
2627
],
2728
"outputs": [],
2829
"execution_count": 81
@@ -293,7 +294,7 @@
293294
" _output_labels = (\"plus\", \"minus\")\n",
294295
"\n",
295296
" def is_bound(self, n) -> bool:\n",
296-
" if self.outputs.plus.value is not pwf.api.NOT_DATA:\n",
297+
" if self.outputs.plus.value is not pyiron_workflow.data.NOT_DATA:\n",
297298
" return self.outputs.plus.value > n and self.outputs.minus.value < n\n",
298299
" else:\n",
299300
" raise RuntimeError(\"Run the node first\")\n",
@@ -1178,7 +1179,7 @@
11781179
"source": [
11791180
"i2d = pwf.api.inputs_to_dict(\n",
11801181
" input_specification={\n",
1181-
" \"x\": (None, pwf.api.NOT_DATA),\n",
1182+
" \"x\": (None, pyiron_workflow.data.NOT_DATA),\n",
11821183
" \"y\": (int, 42)\n",
11831184
" }\n",
11841185
")\n",
@@ -1628,7 +1629,7 @@
16281629
"start_time": "2025-08-13T22:35:56.546690Z"
16291630
}
16301631
},
1631-
"source": "assert(pwf.std.UserInput().inputs.user_input.value is pwf.api.NOT_DATA)",
1632+
"source": "assert(pwf.std.UserInput().inputs.user_input.value is pyiron_workflow.data.NOT_DATA)",
16321633
"outputs": [],
16331634
"execution_count": 120
16341635
},

pyiron_workflow/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
# Node developer entry points
8-
from pyiron_workflow.channels import NOT_DATA
8+
from pyiron_workflow.data import NOT_DATA
99
from pyiron_workflow.executors import CloudpickleProcessPoolExecutor, NodeSlurmExecutor
1010
from pyiron_workflow.find import (
1111
find_nodes as _find_nodes, # Not formally in API -- don't rely on interface

pyiron_workflow/channels.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
import typing
1313
from abc import ABC, abstractmethod
1414

15-
from pyiron_snippets.singleton import Singleton
16-
15+
from pyiron_workflow.data import NOT_DATA
1716
from pyiron_workflow.mixin.display_state import HasStateDisplay
1817
from pyiron_workflow.mixin.has_interface_mixins import HasChannel, HasLabel
1918
from pyiron_workflow.type_hinting import (
@@ -304,29 +303,6 @@ class OutputChannel(Channel[InputType], ABC):
304303
"""Mixin for output channels."""
305304

306305

307-
class NotData(metaclass=Singleton):
308-
"""
309-
This class exists purely to initialize data channel values where no default value
310-
is provided; it lets the channel know that it has _no data in it_ and thus should
311-
not identify as ready.
312-
"""
313-
314-
@classmethod
315-
def __repr__(cls):
316-
# We use the class directly (not instances of it) where there is not yet data
317-
# So give it a decent repr, even as just a class
318-
return "NOT_DATA"
319-
320-
def __reduce__(self):
321-
return "NOT_DATA"
322-
323-
def __bool__(self):
324-
return False
325-
326-
327-
NOT_DATA = NotData()
328-
329-
330306
class DataChannel(FlavorChannel["DataChannel"], typing.Generic[ReceiverType], ABC):
331307
"""
332308
Data channels control the flow of data on the graph.

pyiron_workflow/data.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from __future__ import annotations
2+
3+
from pyiron_snippets.singleton import Singleton
4+
5+
6+
class NotData(metaclass=Singleton):
7+
"""
8+
This class exists purely to initialize data channel values where no default value
9+
is provided; it lets the channel know that it has _no data in it_ and thus should
10+
not identify as ready.
11+
"""
12+
13+
@classmethod
14+
def __repr__(cls):
15+
# We use the class directly (not instances of it) where there is not yet data
16+
# So give it a decent repr, even as just a class
17+
return "NOT_DATA"
18+
19+
def __reduce__(self):
20+
return "NOT_DATA"
21+
22+
def __bool__(self):
23+
return False
24+
25+
26+
NOT_DATA = NotData()

pyiron_workflow/draw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import graphviz
1111
from pyiron_snippets.colors import SeabornColors
1212

13-
from pyiron_workflow.channels import NotData
13+
from pyiron_workflow.data import NOT_DATA
1414

1515
if TYPE_CHECKING:
1616
from pyiron_workflow.channels import Channel as WorkflowChannel # noqa: F401
@@ -198,7 +198,7 @@ def shape(self) -> str:
198198

199199
@property
200200
def style(self) -> str:
201-
if len(self.channel.connections) == 0 and self.channel.value is NotData():
201+
if len(self.channel.connections) == 0 and self.channel.value is NOT_DATA:
202202
return "bold"
203203
return "filled"
204204

pyiron_workflow/mixin/injection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import abc
1212
from typing import TYPE_CHECKING, Any
1313

14-
from pyiron_workflow.channels import NOT_DATA, OutputData
14+
from pyiron_workflow.channels import OutputData
15+
from pyiron_workflow.data import NOT_DATA
1516
from pyiron_workflow.io import GenericOutputs
1617
from pyiron_workflow.mixin.has_interface_mixins import HasChannel
1718

pyiron_workflow/mixin/preview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from pyiron_snippets.dotdict import DotDict
2727

28-
from pyiron_workflow.channels import NOT_DATA
28+
from pyiron_workflow.data import NOT_DATA
2929
from pyiron_workflow.logging import logger
3030
from pyiron_workflow.output_parser import ParseOutput
3131

pyiron_workflow/nodes/for_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pandas import DataFrame
1111
from pyiron_snippets.factory import classfactory
1212

13-
from pyiron_workflow.channels import NOT_DATA
13+
from pyiron_workflow.data import NOT_DATA
1414
from pyiron_workflow.mixin.run import InterpretableAsExecutor
1515
from pyiron_workflow.nodes.composite import Composite
1616
from pyiron_workflow.nodes.static_io import StaticNode

pyiron_workflow/nodes/standard.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from pathlib import Path
1212
from time import sleep
1313

14-
from pyiron_workflow.channels import NOT_DATA, OutputSignal
14+
from pyiron_workflow.channels import OutputSignal
15+
from pyiron_workflow.data import NOT_DATA
1516
from pyiron_workflow.nodes.function import Function, as_function_node
1617

1718

pyiron_workflow/nodes/transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from pyiron_snippets.factory import classfactory
1616

1717
from pyiron_workflow import identifier
18-
from pyiron_workflow.channels import NOT_DATA, NotData
18+
from pyiron_workflow.data import NOT_DATA, NotData
1919
from pyiron_workflow.nodes.static_io import StaticNode
2020

2121

0 commit comments

Comments
 (0)