コード例 #1
0
ファイル: test_index.py プロジェクト: mrahmands1/jina
def test_two_client_route_parallel():
    fa1 = set_flow_parser().parse_args(['--optimize-level', str(FlowOptimizeLevel.NONE)])
    f1 = Flow(fa1).add(parallel=3)
    f2 = Flow(optimize_level=FlowOptimizeLevel.IGNORE_GATEWAY).add(parallel=3)

    def start_client(fl):
        fl.index(input_fn=random_docs_new_api(10))

    with f1:
        assert f1.num_peas == 6
        t1 = mp.Process(target=start_client, args=(f1,))
        t1.daemon = True
        t2 = mp.Process(target=start_client, args=(f1,))
        t2.daemon = True

        t1.start()
        t2.start()

    with f2:
        # no optimization can be made because we ignored the gateway
        assert f2.num_peas == 6
        t1 = mp.Process(target=start_client, args=(f2,))
        t1.daemon = True
        t2 = mp.Process(target=start_client, args=(f2,))
        t2.daemon = True

        t1.start()
        t2.start()
コード例 #2
0
ファイル: custom.py プロジェクト: jina-ai/jinad
def build_pydantic_model(kind: str = 'local',
                         model_name: str = 'CustomModel',
                         module: str = 'pod'):
    if kind == 'api':
        all_cli_args = get_latest_api()
        module_args = get_module_args(all_args=all_cli_args, module=module)
        all_fields, field_validators = get_pydantic_fields(config=module_args)

    elif kind == 'local':
        from jina.parser import set_pea_parser, set_pod_parser, set_flow_parser
        if module == 'pod':
            parser = set_pod_parser()
        elif module == 'pea':
            parser = set_pea_parser()
        elif module == 'flow':
            parser = set_flow_parser()
        all_fields, field_validators = get_pydantic_fields(config=parser)

    return create_model(model_name,
                        **all_fields,
                        __config__=PydanticConfig,
                        __validators__=field_validators)
コード例 #3
0
def test_load_flow_from_cli():
    a = set_flow_parser().parse_args(['--uses', 'yaml/test-flow-port.yml'])
    f = Flow.load_config(a.uses)
    with f:
        assert f.port_expose == 12345