示例#1
0
def test_api_calls():
    from vital.config import config
    from vital.modules import modules
    from sprokit.pipeline import process
    from sprokit.pipeline import process_factory

    modules.load_known_modules()

    proc_type = 'orphan'
    c = config.empty_config()

    process_factory.create_process(proc_type, '')
    process_factory.create_process(proc_type, '', c)
    process_factory.types()
    process_factory.description(proc_type)

    process_factory.Process.property_no_threads
    process_factory.Process.property_no_reentrancy
    process_factory.Process.property_unsync_input
    process_factory.Process.property_unsync_output
    process_factory.Process.port_heartbeat
    process_factory.Process.config_name
    process_factory.Process.config_type
    process_factory.Process.type_any
    process_factory.Process.type_none
    process_factory.Process.type_data_dependent
    process_factory.Process.type_flow_dependent
    process_factory.Process.flag_output_const
    process_factory.Process.flag_input_static
    process_factory.Process.flag_input_mutable
    process_factory.Process.flag_input_nodep
    process_factory.Process.flag_required
示例#2
0
def test_api_calls():
    from sprokit.pipeline import config
    from vital.modules import modules
    from sprokit.pipeline import process
    from sprokit.pipeline import process_factory

    modules.load_known_modules()

    proc_type = 'orphan'
    c = config.empty_config()

    process_factory.create_process(proc_type, '')
    process_factory.create_process(proc_type, '', c)
    process_factory.types()
    process_factory.description(proc_type)

    process_factory.Process.property_no_threads
    process_factory.Process.property_no_reentrancy
    process_factory.Process.property_unsync_input
    process_factory.Process.property_unsync_output
    process_factory.Process.port_heartbeat
    process_factory.Process.config_name
    process_factory.Process.config_type
    process_factory.Process.type_any
    process_factory.Process.type_none
    process_factory.Process.type_data_dependent
    process_factory.Process.type_flow_dependent
    process_factory.Process.flag_output_const
    process_factory.Process.flag_input_static
    process_factory.Process.flag_input_mutable
    process_factory.Process.flag_input_nodep
    process_factory.Process.flag_required
示例#3
0
def test_register_cluster():
    from sprokit.pipeline import config
    from sprokit.pipeline import process
    from sprokit.pipeline import process_cluster
    from sprokit.pipeline import process_factory

    proc_type = 'python_example'
    proc_desc = 'simple description'

    process_factory.add_process(proc_type, proc_desc, base_example_process_cluster())

    if not proc_desc == process_factory.description(proc_type):
        test_error("Description was not preserved when registering")

    p = None

    try:
        p = process_factory.create_process(proc_type, '')
        if p is None:
            raise Exception()
    except BaseException:
        import sys

        e = sys.exc_info()[1]

        test_error("Could not create newly registered process cluster type: %s" % str(e))

    if process_cluster.cluster_from_process(p) is None:
        test_error("A cluster process from the registry was not detected as a cluster process")
示例#4
0
def test_register_cluster():
    from vital.config import config
    from sprokit.pipeline import process
    from sprokit.pipeline import process_cluster
    from sprokit.pipeline import process_factory

    proc_type = 'python_example'
    proc_desc = 'simple description'

    process_factory.add_process(proc_type, proc_desc,
                                base_example_process_cluster())

    if not proc_desc == process_factory.description(proc_type):
        test_error("Description was not preserved when registering")

    p = None

    try:
        p = process_factory.create_process(proc_type, '')
        if p is None:
            raise Exception()
    except BaseException:
        import sys

        e = sys.exc_info()[1]

        test_error(
            "Could not create newly registered process cluster type: %s" %
            str(e))

    if process_cluster.cluster_from_process(p) is None:
        test_error(
            "A cluster process from the registry was not detected as a cluster process"
        )
示例#5
0
def create_process(type, name, conf):
    from sprokit.pipeline import modules
    from sprokit.pipeline import process_factory

    modules.load_known_modules()

    p = process_factory.create_process(type, name, conf)

    return p
示例#6
0
def create_process(type, name, conf):
    from vital.modules import modules
    from sprokit.pipeline import process_factory

    modules.load_known_modules()

    p = process_factory.create_process(type, name, conf)

    return p
示例#7
0
def test_api_calls():
    from sprokit.pipeline import config
    from sprokit.pipeline import modules
    from sprokit.pipeline import process
    from sprokit.pipeline import process_factory

    modules.load_known_modules()

    proc_type = 'orphan'
    c = config.empty_config()

    process_factory.create_process(proc_type, process.ProcessName())
    process_factory.create_process(proc_type, process.ProcessName(), c)
    process_factory.types()
    process_factory.description(proc_type)

    process_factory.Process.property_no_threads
    process_factory.Process.property_no_reentrancy
    process_factory.Process.property_unsync_input
    process_factory.Process.property_unsync_output
    process_factory.Process.port_heartbeat
    process_factory.Process.config_name
    process_factory.Process.config_type
    process_factory.Process.type_any
    process_factory.Process.type_none
    process_factory.Process.type_data_dependent
    process_factory.Process.type_flow_dependent
    process_factory.Process.flag_output_const
    process_factory.Process.flag_input_static
    process_factory.Process.flag_input_mutable
    process_factory.Process.flag_input_nodep
    process_factory.Process.flag_required

    cluster_bases = process_factory.ProcessCluster.__bases__
    if not cluster_bases[0] == process_factory.Process:
        test_error("The cluster class does not inherit from the process class")
示例#8
0
def test_register():
    from vital.config import config
    from sprokit.pipeline import process
    from sprokit.pipeline import process_factory

    proc_type = 'python_example'
    proc_desc = 'simple description'

    process_factory.add_process(proc_type, proc_desc, example_process(True))

    if not proc_desc == process_factory.description(proc_type):
        test_error("Description was not preserved when registering")

    try:
        p = process_factory.create_process(proc_type, '')
        if p is None:
            raise Exception()
    except:
        test_error("Could not create newly registered process type")
示例#9
0
def test_register():
    from sprokit.pipeline import config
    from sprokit.pipeline import process
    from sprokit.pipeline import process_factory

    proc_type = 'python_example'
    proc_desc = 'simple description'

    process_factory.add_process(proc_type, proc_desc, example_process(True))

    if not proc_desc == process_factory.description(proc_type):
        test_error("Description was not preserved when registering")

    try:
        p = process_factory.create_process(proc_type, '')
        if p is None:
            raise Exception()
    except:
        test_error("Could not create newly registered process type")
示例#10
0
def test_wrapper_api():
    from vital.config import config
    from vital.modules import modules
    from sprokit.pipeline import pipeline
    from sprokit.pipeline import process_factory
    from sprokit.pipeline import scheduler_factory

    sched_type = 'python_example'
    sched_desc = 'simple description'

    modules.load_known_modules()

    scheduler_factory.add_scheduler(sched_type, sched_desc,
                                    example_scheduler(False))

    p = pipeline.Pipeline()

    proc_type = 'orphan'
    proc_name = 'orphan'

    proc = process_factory.create_process(proc_type, proc_name)

    p.add_process(proc)

    def check_scheduler(s):
        if s is None:
            test_error("Got a 'None' scheduler")
            return

        s.start()
        s.pause()
        s.resume()
        s.stop()
        s.start()
        s.wait()

        del s

    p.reset()
    p.setup_pipeline()

    s = scheduler_factory.create_scheduler(sched_type, p)
    check_scheduler(s)
示例#11
0
def test_wrapper_api():
    from sprokit.pipeline import config
    from vital.modules import modules
    from sprokit.pipeline import pipeline
    from sprokit.pipeline import process_factory
    from sprokit.pipeline import scheduler_factory

    sched_type = 'python_example'
    sched_desc = 'simple description'

    modules.load_known_modules()

    scheduler_factory.add_scheduler(sched_type, sched_desc, example_scheduler(False))

    p = pipeline.Pipeline()

    proc_type = 'orphan'
    proc_name = 'orphan'

    proc = process_factory.create_process(proc_type, proc_name)

    p.add_process(proc)

    def check_scheduler(s):
        if s is None:
            test_error("Got a 'None' scheduler")
            return

        s.start()
        s.pause()
        s.resume()
        s.stop()
        s.start()
        s.wait()

        del s

    p.reset()
    p.setup_pipeline()

    s = scheduler_factory.create_scheduler(sched_type, p)
    check_scheduler(s)
示例#12
0
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_factory
    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()

    p = process_factory.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
示例#13
0
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_factory
    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()

    p = process_factory.create_process('orphan', 'process_name')

    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
示例#14
0
def test_api_calls():
    from vital.config import config
    from sprokit.pipeline import edge
    from vital.modules import modules
    from sprokit.pipeline import pipeline
    from sprokit.pipeline import process
    from sprokit.pipeline import process_cluster
    from sprokit.pipeline import process_factory

    p = pipeline.Pipeline()

    proc_type1 = 'numbers'
    proc_type2 = 'print_number'
    proc_type3 = 'orphan_cluster'

    proc_name1 = 'src'
    proc_name2 = 'snk'
    proc_name3 = 'orp'

    port_name1 = 'number'
    port_name2 = 'number'

    modules.load_known_modules()

    proc1 = process_factory.create_process(proc_type1, proc_name1)

    conf_name = 'output'

    c = config.empty_config()

    c.set_value(conf_name, 'test-python-pipeline-api_calls-print_number.txt')
    proc2 = process_factory.create_process(proc_type2, proc_name2, c)

    proc3 = process_factory.create_process(proc_type3, proc_name3)

    p.add_process(proc1)
    p.add_process(proc2)
    p.add_process(proc3)
    p.connect(proc_name1, port_name1, proc_name2, port_name2)
    p.process_names()
    p.process_by_name(proc_name1)
    p.cluster_names()
    p.cluster_by_name(proc_name3)
    p.connections_from_addr(proc_name1, port_name1)
    p.connection_to_addr(proc_name2, port_name2)

    p.disconnect(proc_name1, port_name1, proc_name2, port_name2)
    p.remove_process(proc_name1)
    p.remove_process(proc_name3)

    # Restore the pipeline so that setup_pipeline works.
    p.add_process(proc1)
    p.connect(proc_name1, port_name1, proc_name2, port_name2)

    p.setup_pipeline()

    p.upstream_for_process(proc_name2)
    p.upstream_for_port(proc_name2, port_name2)
    p.downstream_for_process(proc_name1)
    p.downstream_for_port(proc_name1, port_name1)
    p.sender_for_port(proc_name2, port_name2)
    p.receivers_for_port(proc_name1, port_name1)
    p.edge_for_connection(proc_name1, port_name1, proc_name2, port_name2)
    p.input_edges_for_process(proc_name2)
    p.input_edge_for_port(proc_name2, port_name2)
    p.output_edges_for_process(proc_name1)
    p.output_edges_for_port(proc_name1, port_name1)

    p.is_setup()
    p.setup_successful()

    c = config.empty_config()

    p.reconfigure(c)

    p.reset()
示例#15
0
def test_api_calls():
    from sprokit.pipeline import config
    from sprokit.pipeline import edge
    from vital.modules import modules
    from sprokit.pipeline import pipeline
    from sprokit.pipeline import process
    from sprokit.pipeline import process_cluster
    from sprokit.pipeline import process_factory

    p = pipeline.Pipeline()

    proc_type1 = 'numbers'
    proc_type2 = 'print_number'
    proc_type3 = 'orphan_cluster'

    proc_name1 = 'src'
    proc_name2 = 'snk'
    proc_name3 = 'orp'

    port_name1 = 'number'
    port_name2 = 'number'

    modules.load_known_modules()

    proc1 = process_factory.create_process(proc_type1, proc_name1)

    conf_name = 'output'

    c = config.empty_config()

    c.set_value(conf_name, 'test-python-pipeline-api_calls-print_number.txt')
    proc2 = process_factory.create_process(proc_type2, proc_name2, c)

    proc3 = process_factory.create_process(proc_type3, proc_name3)

    p.add_process(proc1)
    p.add_process(proc2)
    p.add_process(proc3)
    p.connect(proc_name1, port_name1,
              proc_name2, port_name2)
    p.process_names()
    p.process_by_name(proc_name1)
    p.cluster_names()
    p.cluster_by_name(proc_name3)
    p.connections_from_addr(proc_name1, port_name1)
    p.connection_to_addr(proc_name2, port_name2)

    p.disconnect(proc_name1, port_name1,
                 proc_name2, port_name2)
    p.remove_process(proc_name1)
    p.remove_process(proc_name3)

    # Restore the pipeline so that setup_pipeline works.
    p.add_process(proc1)
    p.connect(proc_name1, port_name1,
              proc_name2, port_name2)

    p.setup_pipeline()

    p.upstream_for_process(proc_name2)
    p.upstream_for_port(proc_name2, port_name2)
    p.downstream_for_process(proc_name1)
    p.downstream_for_port(proc_name1, port_name1)
    p.sender_for_port(proc_name2, port_name2)
    p.receivers_for_port(proc_name1, port_name1)
    p.edge_for_connection(proc_name1, port_name1,
                          proc_name2, port_name2)
    p.input_edges_for_process(proc_name2)
    p.input_edge_for_port(proc_name2, port_name2)
    p.output_edges_for_process(proc_name1)
    p.output_edges_for_port(proc_name1, port_name1)

    p.is_setup()
    p.setup_successful()

    c = config.empty_config()

    p.reconfigure(c)

    p.reset()
示例#16
0
def test_wrapper_api():
    from vital.config import config
    from sprokit.pipeline import edge
    from sprokit.pipeline import process
    from sprokit.pipeline import process_factory

    proc_type = 'python_example'
    proc_desc = 'simple description'

    proc_base_type = 'python_base_example'
    proc_base_desc = 'simple base description'

    iport = 'no_such_iport'
    oport = 'no_such_oport'
    key = 'no_such_key'
    ptype = 'no_type'

    process_factory.add_process(proc_type, proc_desc, example_process(False))
    process_factory.add_process(proc_base_type, proc_base_desc,
                                base_example_process())

    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

    p = process_factory.create_process(proc_type, '')
    check_process(p)

    p = process_factory.create_process(proc_base_type, '')
    check_process(p)
示例#17
0
def test_wrapper_api():
    from sprokit.pipeline import config
    from sprokit.pipeline import edge
    from sprokit.pipeline import process
    from sprokit.pipeline import process_factory

    proc_type = 'python_example'
    proc_desc = 'simple description'

    proc_base_type = 'python_base_example'
    proc_base_desc = 'simple base description'

    iport = 'no_such_iport'
    oport = 'no_such_oport'
    key = 'no_such_key'
    ptype = 'no_type'

    process_factory.add_process(proc_type, proc_desc, example_process(False))
    process_factory.add_process(proc_base_type, proc_base_desc, base_example_process())

    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

    p = process_factory.create_process(proc_type, '')
    check_process(p)

    p = process_factory.create_process(proc_base_type, '')
    check_process(p)