-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
329 changed files
with
294,252 additions
and
666,605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from barazmoon.main import BarAzmoonProcess | ||
from barazmoon.main import BarAzmoonAsync | ||
from barazmoon.main import BarAzmoonAsyncRest | ||
from barazmoon.mlserver import MLServerProcess | ||
from barazmoon.mlserver import MLServerAsync | ||
from barazmoon.mlserver import MLServerAsyncRest | ||
from barazmoon.mlserver import MLServerAsyncGrpc | ||
# from barazmoon.main import queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
mlserver/1-paper-audio-qa/seldon-core-version/client-async-grpc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from urllib import response | ||
import grpc | ||
from pprint import PrettyPrinter | ||
from mlserver.types import InferenceResponse | ||
from mlserver.grpc.converters import ModelInferResponseConverter | ||
import mlserver.grpc.dataplane_pb2_grpc as dataplane | ||
import mlserver.grpc.converters as converters | ||
from mlserver.codecs.string import StringRequestCodec | ||
from mlserver.codecs.string import StringRequestCodec | ||
pp = PrettyPrinter(indent=4) | ||
from datasets import load_dataset | ||
import mlserver.types as types | ||
import json | ||
import asyncio | ||
|
||
# single node seldon+mlserver | ||
endpoint = "localhost:32000" | ||
deployment_name = 'audio-qa' | ||
model = None | ||
namespace = "default" | ||
metadata = [("seldon", deployment_name), ("namespace", namespace)] | ||
|
||
batch_test = 30 | ||
ds = load_dataset( | ||
"hf-internal-testing/librispeech_asr_demo", | ||
"clean", | ||
split="validation") | ||
|
||
input_data = ds[0]["audio"]["array"] | ||
|
||
async def send_requests(ch): | ||
grpc_stub = dataplane.GRPCInferenceServiceStub(ch) | ||
inference_request = types.InferenceRequest( | ||
inputs=[ | ||
types.RequestInput( | ||
name="echo_request", | ||
shape=[1, len(input_data)], | ||
datatype="FP32", | ||
data=input_data.tolist(), | ||
parameters=types.Parameters(content_type="np"), | ||
) | ||
] | ||
) | ||
inference_request_g = converters.ModelInferRequestConverter.from_types( | ||
inference_request, model_name=model, model_version=None | ||
) | ||
response = await grpc_stub.ModelInfer( | ||
request=inference_request_g, | ||
metadata=metadata) | ||
return response | ||
|
||
|
||
async def main(): | ||
async with grpc.aio.insecure_channel(endpoint) as ch: | ||
responses = await asyncio.gather(*[send_requests(ch) for _ in range(10)]) | ||
|
||
inference_responses = list(map( | ||
lambda response: ModelInferResponseConverter.to_types(response), responses)) | ||
raw_jsons = list(map( | ||
lambda inference_response: StringRequestCodec.decode_response( | ||
inference_response), inference_responses)) | ||
outputs = list(map( | ||
lambda raw_json: json.loads(raw_json[0]), raw_jsons)) | ||
|
||
pp.pprint(outputs) | ||
|
||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.