def test_parent_nodes(): # build the graph g1 = FromEventStream( "event", ("data", "det_image"), principle=True, stream_name="g1", asynchronous=True, ) g11 = FromEventStream( "event", ("data", "det_image"), stream_name="g11", asynchronous=True ) g2 = g1.zip(g11).starmap(op.mul, stream_name="mul") g = g2.SimpleToEventStream(("img2",)) l1 = g.sink_to_list() # g.sink(print) assert len(g.translation_nodes) == 2 print("start experiment") # run the experiment l0 = [] for yy in y(5): l0.append(yy) g11.update(yy) g1.update(yy) print(g11.start_uid) assert len(l1[0][1]["parent_node_map"]) == 2
def test_replay_export_test(): def y(): suid = str(uuid.uuid4()) yield ("start", {"uid": suid, "time": time.time()}) duid = str(uuid.uuid4()) yield ( "descriptor", { "uid": duid, "run_start": suid, "name": "primary", "data_keys": {"det_image": {"dtype": "int", "units": "arb"}}, "time": time.time(), }, ) for i in range(5): yield ( "event", { "uid": str(uuid.uuid4()), "data": {"det_image": i}, "timestamps": {"det_image": time.time()}, "seq_num": i + 1, "time": time.time(), "descriptor": duid, }, ) yield ( "stop", {"uid": str(uuid.uuid4()), "time": time.time(), "run_start": suid}, ) print("build graph") g1 = FromEventStream( "event", ("data", "det_image"), principle=True, stream_name="g1" ) g11 = FromEventStream("event", ("data", "det_image"), stream_name="g11") g11_1 = g1.zip(g11) g2 = g11_1.starmap(op.mul).map(np.log) g = g2.SimpleToEventStream(("img2",)) from pprint import pprint g.sink(pprint) L = g.sink_to_list() print("run experiment") for yy in y(): print(yy[0]) g11.update(yy) g1.update(yy) assert L[-1][1]["run_start"]