mindspore_serving

MindSpore Serving.

mindspore_serving.server

mindspore_serving.server.register

mindspore_serving.server.distributed

mindspore_serving.client

MindSpore Serving Client

class mindspore_serving.client.Client(ip, port, servable_name, method_name, version_number=0)[source]

The Client encapsulates the serving gRPC API, which can be used to create requests, access serving, and parse results.

Parameters
  • ip (str) – Serving ip.

  • port (int) – Serving port.

  • servable_name (str) – The name of servable supplied by Serving.

  • method_name (str) – The name of method supplied by servable.

  • version_number (int) – The version number of servable, default 0, which means the maximum version number in all running versions.

Raises

RuntimeError – The type or value of the parameters is invalid, or other errors happened.

Examples

>>> from mindspore_serving.client import Client
>>> import numpy as np
>>> client = Client("localhost", 5500, "add", "add_cast")
>>> instances = []
>>> x1 = np.ones((2, 2), np.int32)
>>> x2 = np.ones((2, 2), np.int32)
>>> instances.append({"x1": x1, "x2": x2})
>>> result = client.infer(instances)
>>> print(result)
infer(instances)[source]

Used to create requests, access serving service, and parse and return results.

Parameters

instances (map, tuple of map) – Instance or tuple of instances, every instance item is the inputs map. The map key is the input name, and the value is the input value, the type of value can be python int, float, bool, str, bytes, numpy number, or numpy array object.

Raises

RuntimeError – The type or value of the parameters is invalid, or other errors happened.

Examples

>>> from mindspore_serving.client import Client
>>> import numpy as np
>>> client = Client("localhost", 5500, "add", "add_cast")
>>> instances = []
>>> x1 = np.ones((2, 2), np.int32)
>>> x2 = np.ones((2, 2), np.int32)
>>> instances.append({"x1": x1, "x2": x2})
>>> result = client.infer(instances)
>>> print(result)
infer_async(instances)[source]

Used to create requests, async access serving.

Parameters

instances (map, tuple of map) – Instance or tuple of instances, every instance item is the inputs map. The map key is the input name, and the value is the input value.

Raises

RuntimeError – The type or value of the parameters is invalid, or other errors happened.

Examples

>>> from mindspore_serving.client import Client
>>> import numpy as np
>>> client = Client("localhost", 5500, "add", "add_cast")
>>> instances = []
>>> x1 = np.ones((2, 2), np.int32)
>>> x2 = np.ones((2, 2), np.int32)
>>> instances.append({"x1": x1, "x2": x2})
>>> result_future = client.infer_async(instances)
>>> result = result_future.result()
>>> print(result)