コード例 #1
0
def test_pipeline_ai_model_config():
    """Test the source ref is resolved"""

    config_manager.stop()

    config_manager.set({
        "ai_models": {
            "test": {
                "labels": "ai_models/coco_labels.txt",
                "model": {
                    "tflite":
                    "ai_models/mobilenet_ssd_v2_coco_quant_postprocess.tflite",
                }
            }
        },
        "pipelines": {
            "pipeline1": [{
                "source": {
                    "uri": "test"
                }
            }, {
                "detect_objects": {
                    "ai_model": "test",
                    "confidence_threshold": 0.0
                }
            }]
        }
    })
    p = _one_pipeline_setup(config_manager.get_pipelines())
    p[0].load_elements()

    log.debug(p[0]._pipe_elements[1])
    assert len(p[0]._pipe_elements) == 2
    assert p[0]._pipe_elements[1]._tfengine._confidence_threshold == 0.0
コード例 #2
0
def test_pipeline_reload_delete_source_ref():
    """Test that when a source reference changes, the pipeline reload"""
    interpreter.PIPELINE_CLASS = _TestPipeline
    config_manager.stop()
    config_manager.set({
        "sources": {
            "source1": {
                "uri": "test",
                "type": "video",
                "live": False
            }
        },
        "pipelines": {
            "pipeline1": [{
                "source": "source1"
            }]
        }
    })
    config = config_manager.get()
    p = _one_pipeline_setup(config.get("pipelines"))
    p[0].start()

    pe = p[0]._pipe_elements[0]
    assert p[0]._pipe_elements[0].state == pipeline.PIPE_STATE_RUNNING
    assert pe.start_called

    del config["sources"]["source1"]

    assert p[0].restart_called
    assert len(p[0]._pipe_elements) == 0
コード例 #3
0
def test_pipeline_reload_sources_ref():
    """Test that when a source reference changes, the pipeline reload"""
    config_manager.stop()
    config_manager.set({
        "sources": {
            "source1": {
                "uri": "test",
                "type": "video",
                "live": False
            }
        },
        "pipelines": {
            "pipeline1": [{
                "source": "source1"
            }]
        }
    })
    config = config_manager.get()
    p = _one_pipeline_setup(config.get("pipelines"))
    p[0].start()

    pe = p[0]._pipe_elements[0]
    assert p[0]._pipe_elements[0].state == pipeline.PIPE_STATE_RUNNING
    assert pe.start_called

    config["sources"]["source1"]["uri"] = "test2"
    log.debug(p[0]._pipe_elements[0].config)
    assert p[0]._pipe_elements[0].config['uri'] == 'test2'
コード例 #4
0
def test_pipeline_reload_onchange():
    """Test that when a reference in the pipeline changes, the pipeline reload"""
    config_manager.set({"pipelines": _get_pipelines_config()})
    p = _one_pipeline_setup(config_manager.get_pipelines())
    p[0].start()
    pe = p[0]._pipe_elements[0]
    assert p[0]._pipe_elements[0].state == pipeline.PIPE_STATE_RUNNING
    assert pe.start_called

    config_manager.get_pipeline("pipeline_one")[0]["source"]["uri"] = "test2"
    assert p[0]._pipe_elements[0].config['uri'] == 'test2'
コード例 #5
0
def test_pipeline_server_config_change():

    _dir = os.path.dirname(os.path.abspath(__file__))

    source_cfg = {
        "uri": os.path.join(_dir, "./avsource/test2-cam-person1.mkv")
    }

    config_manager.set(Config({"pipelines": {"test": [{"source": "test"}]}}))

    srv = PipelineServerEv(config_manager.get_pipelines())
    srv.start()

    config_manager.get().add_callback(srv.trigger_event)
    config_manager.get_sources().set("test", source_cfg)
    # the callback will restart the process
    assert srv.triggered
コード例 #6
0
def test_pipeline_source_config():
    """Test the source ref is resolved"""
    config_manager.set({
        "sources": {
            "source1": {
                "uri": "test",
                "type": "video",
                "live": False
            }
        },
        "pipelines": {
            "pipeline1": [{
                "source": "source1"
            }]
        }
    })
    p = _one_pipeline_setup(config_manager.get_pipelines())
    p[0].load_elements()

    log.debug(p[0]._pipe_elements[0])
    assert p[0]._pipe_elements[0].config["uri"] == "test"
コード例 #7
0
def test_pipeline_server_start_stop():

    _dir = os.path.dirname(os.path.abspath(__file__))

    config_manager.set(
        Config({
            "sources": {
                "test": {
                    "uri": os.path.join(_dir,
                                        "./avsource/test2-cam-person1.mkv")
                }
            },
            "pipelines": {
                "test": [{
                    "source": "test"
                }]
            }
        }))

    srv = PipelineServer(config_manager.get_pipelines())
    srv.start()
    srv.stop()
コード例 #8
0
ファイル: test_flaskr.py プロジェクト: will300/ambianic-edge
def reset_config():
    config_manager.stop()
    config_manager.set({"data_dir": "./data", "sources": {}})