コード例 #1
0
    def process_wrapper():
        monkeypatch.setattr(
            networking.GrpcConnectionPool,
            'send_requests_once',
            DummyMockConnectionPool.send_requests_once,
        )
        port_in = random_port()

        with GRPCGatewayRuntime(set_gateway_parser().parse_args([
                '--port-expose',
                f'{port_in}',
                '--graph-description',
                f'{json.dumps(merge_graph_dict_directly_merge_in_last_deployment)}',
                '--deployments-addresses',
                '{}',
        ])) as runtime:

            async def _test():
                responses = []
                req = request_generator(
                    '/', DocumentArray([Document(text='client0-Request')]))
                async for resp in runtime.streamer.Call(request_iterator=req):
                    responses.append(resp)
                return responses

            responses = asyncio.run(_test())
        assert len(responses) > 0
        assert len(responses[0].docs) == 1
        deployment1_path = (
            f'client0-Request-client0-deployment0-client0-deployment1-client0-merger-client0-deployment_last'
            in responses[0].docs[0].text)
        deployment2_path = (
            f'client0-Request-client0-deployment0-client0-deployment2-client0-merger-client0-deployment_last'
            in responses[0].docs[0].text)
        assert deployment1_path or deployment2_path
コード例 #2
0
ファイル: test_runtimes.py プロジェクト: sthagen/jina
def _create_gateway_runtime(graph_description, pod_addresses, port):
    with GRPCGatewayRuntime(set_gateway_parser().parse_args([
            '--graph-description',
            graph_description,
            '--deployments-addresses',
            pod_addresses,
            '--port',
            str(port),
    ])) as runtime:
        runtime.run_forever()
コード例 #3
0
 def _create_runtime():
     with GRPCGatewayRuntime(set_gateway_parser().parse_args([
             '--port-expose',
             str(port_expose),
             '--graph-description',
             '{"start-gateway": ["deployment0"], "deployment0": ["end-gateway"]}',
             '--deployments-addresses',
             '{"deployment0": ["0.0.0.0:' + f'{deployment0_port}' +
             '", "0.0.0.0:' + f'{deployment1_port}' + '"]}',
     ])) as runtime:
         runtime.run_forever()
コード例 #4
0
    def process_wrapper():
        port_in = random_port()

        with GRPCGatewayRuntime(set_gateway_parser().parse_args([
                '--port-expose',
                f'{port_in}',
                '--graph-description',
                f'{json.dumps({})}',
                '--deployments-addresses',
                '{}',
        ])) as runtime:

            async def _test():
                responses = []
                req = request_generator(
                    '/', DocumentArray([Document(text='client0-Request')]))
                async for resp in runtime.streamer.Call(request_iterator=req):
                    responses.append(resp)
                return responses

            responses = asyncio.run(_test())
        assert len(responses) > 0
        assert len(responses[0].docs) == 1
        assert responses[0].docs[0].text == f'client0-Request'