fluksio.arrived(): a node can tell which inputs the wave behind it wrote, so a value written again unchanged is seen
This commit is contained in:
@@ -12,7 +12,7 @@ from fluksio.flow.artifacts import ArtifactStore, VolatileStore
|
||||
from fluksio.flow.controller import EmitSink, FlowController
|
||||
from fluksio.flow.messages import DType, MessageSpec
|
||||
from fluksio.flow.nodes import Node
|
||||
from fluksio.flow.nodes.base import NodeOutputError
|
||||
from fluksio.flow.nodes.base import ARRIVED, NodeOutputError
|
||||
from fluksio.flow.pipeline import Pipeline
|
||||
from fluksio.flow.schemas import FlowDef, NodeDef
|
||||
from fluksio.flow.state import MemoryState
|
||||
@@ -87,6 +87,22 @@ def test_a_node_can_log_through_the_module_it_imports(pool, capsys):
|
||||
assert "tuned 7" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_a_node_reads_which_inputs_arrived(pool):
|
||||
code = (
|
||||
"import fluksio\n\n\n"
|
||||
"def process(auto, manual):\n"
|
||||
" arrived = fluksio.arrived()\n"
|
||||
" return {'out': None if arrived is None else sorted(arrived)}\n"
|
||||
)
|
||||
token = ARRIVED.set(["manual"])
|
||||
try:
|
||||
assert run(pool, code, auto=True, manual=True) == {"out": ["manual"]}
|
||||
finally:
|
||||
ARRIVED.reset(token)
|
||||
# A run nothing can account for, such as a flow starting.
|
||||
assert run(pool, code, auto=True, manual=True) == {"out": None}
|
||||
|
||||
|
||||
def test_a_failure_keeps_its_class_and_points_at_the_node(pool):
|
||||
with pytest.raises(Exception) as caught:
|
||||
run(pool, "def process():\n raise ValueError('bad input')\n")
|
||||
|
||||
Reference in New Issue
Block a user