def test_create(): from sprokit.pipeline import config from sprokit.pipeline import edge c = config.empty_config() edge.Edge() edge.Edge(c) edge.Edges()
def test_peek_at_datum_on_port(): """ Test peek at datum on a test port with complete datum """ from sprokit.pipeline import process from sprokit.pipeline import datum, DatumType from vital.config import config from sprokit.pipeline import edge from sprokit.pipeline import stamp cfg = config.empty_config() # Create Dummy Receiver process receiver_proc = process.PythonProcess(cfg) optional = process.PortFlags() receiver_proc.declare_input_port("test_port", "test", optional, "test_port") # Create an Edge and connect input port to the edge test_edge = edge.Edge() receiver_proc.connect_input_port("test_port", test_edge) # Create an Edge Datum and push it to the port s = stamp.new_stamp(1) e_datum = edge.EdgeDatum(datum.complete(), s) test_edge.push_datum(e_datum) receiver_datum_type = receiver_proc.peek_at_datum_on_port( "test_port").type() if receiver_datum_type != DatumType.complete: test_error("Datum mismatch: expected a complete datum, got {0}".format( receiver_datum_type))
def check_process(p): if p is None: test_error("Got a 'None' process") return p.properties() p.input_ports() p.output_ports() expect_exception("asking for info on a non-existant input port", RuntimeError, p.input_port_info, iport) expect_exception("asking for info on a non-existant output port", RuntimeError, p.output_port_info, oport) e = edge.Edge() expect_exception("connecting to a non-existant input port", RuntimeError, p.connect_input_port, iport, e) expect_exception("connecting to a non-existant output port", RuntimeError, p.connect_output_port, oport, e) p.available_config() p.available_tunable_config() expect_exception("asking for info on a non-existant config key", RuntimeError, p.config_info, key) expect_exception("setting a type on a non-existent input port", RuntimeError, p.set_input_port_type, iport, ptype) expect_exception("setting a type on a non-existent output port", RuntimeError, p.set_output_port_type, oport, ptype) p.reset() p.configure() p.init() # TODO: Can't check this because the core frequency of the process # cannot be set. Needs to be stepped within a pipeline to verify this. # Enable the ran_step check in p.check when this is fixed. #p.step() # TODO: Can't check this because only the process_cluster base class # and the pipeline may reconfigure a process. Needs to be stepped # within a pipeline to verify this. Enable the ran_step check in # p.check when this is fixed. #p.reconfigure(reconf) del p
def test_api_calls(): from sprokit.pipeline import config from sprokit.pipeline import datum from sprokit.pipeline import edge from sprokit.pipeline import modules from sprokit.pipeline import process from sprokit.pipeline import process_registry from sprokit.pipeline import stamp e = edge.Edge() e.makes_dependency() e.has_data() e.full_of_data() e.datum_count() d = datum.complete() s = stamp.new_stamp(1) ed = edge.EdgeDatum(d, s) e.push_datum(ed) e.get_datum() e.push_datum(ed) e.peek_datum() e.pop_datum() modules.load_known_modules() reg = process_registry.ProcessRegistry.self() p = reg.create_process('orphan', process.ProcessName()) e.set_upstream_process(p) e.set_downstream_process(p) e.mark_downstream_as_complete() e.is_downstream_complete() e.config_dependency e.config_capacity
def _run_process(self, proc): utils.name_thread(proc.name()) monitor = edge.Edge(self._edge_conf) proc.connect_output_port(process.PythonProcess.port_heartbeat, monitor) complete = False while not complete and not self._event.is_set(): while self._pause_event.is_set(): self._pause_event.wait() proc.step() while monitor.has_data(): edat = monitor.get_datum() dat = edat.datum if dat.type() == datum.DatumType.complete: complete = True