"""Module wrapping the Client of Jina."""importargparsefromtypingimportoverload,Optional,Union,TYPE_CHECKING__all__=['Client']fromjina.enumsimportGatewayProtocolTypeifTYPE_CHECKING:fromjina.clients.grpcimportGRPCClient,AsyncGRPCClientfromjina.clients.websocketimportWebSocketClient,AsyncWebSocketClientfromjina.clients.httpimportHTTPClient,AsyncHTTPClient# overload_inject_start_client@overloaddefClient(*,asyncio:Optional[bool]=False,host:Optional[str]='0.0.0.0',https:Optional[bool]=False,port:Optional[int]=None,protocol:Optional[str]='GRPC',proxy:Optional[bool]=False,return_responses:Optional[bool]=False,**kwargs)->Union['AsyncWebSocketClient','WebSocketClient','AsyncGRPCClient','GRPCClient','HTTPClient','AsyncHTTPClient',]:"""Create a Client. Client is how user interact with Flow :param asyncio: If set, then the input and output of this Client work in an asynchronous manner. :param host: The host address of the runtime, by default it is 0.0.0.0. :param https: If set, connect to gateway using https :param port: The port of the Gateway, which the client should connect to. :param protocol: Communication protocol between server and client. :param proxy: If set, respect the http_proxy and https_proxy environment variables. otherwise, it will unset these proxy variables before start. gRPC seems to prefer no proxy :param return_responses: If set, return results as List of Requests instead of a reduced DocArray. :return: the new Client object .. # noqa: DAR202 .. # noqa: DAR101 .. # noqa: DAR003 """# overload_inject_end_client
[docs]defClient(args:Optional['argparse.Namespace']=None,**kwargs)->Union['AsyncWebSocketClient','WebSocketClient','AsyncGRPCClient','GRPCClient','HTTPClient','AsyncHTTPClient',]:"""Jina Python client. :param args: Namespace args. :param kwargs: Additional arguments. :return: An instance of :class:`GRPCClient` or :class:`WebSocketClient`. """protocol=(args.protocolifargselsekwargs.get('protocol',GatewayProtocolType.GRPC))ifisinstance(protocol,str):protocol=GatewayProtocolType.from_string(protocol)is_async=(argsandargs.asyncio)orkwargs.get('asyncio',False)ifprotocol==GatewayProtocolType.GRPC:ifis_async:fromjina.clients.grpcimportAsyncGRPCClientreturnAsyncGRPCClient(args,**kwargs)else:fromjina.clients.grpcimportGRPCClientreturnGRPCClient(args,**kwargs)elifprotocol==GatewayProtocolType.WEBSOCKET:ifis_async:fromjina.clients.websocketimportAsyncWebSocketClientreturnAsyncWebSocketClient(args,**kwargs)else:fromjina.clients.websocketimportWebSocketClientreturnWebSocketClient(args,**kwargs)elifprotocol==GatewayProtocolType.HTTP:ifis_async:fromjina.clients.httpimportAsyncHTTPClientreturnAsyncHTTPClient(args,**kwargs)else:fromjina.clients.httpimportHTTPClientreturnHTTPClient(args,**kwargs)