build_grpc_channel#

Instance.build_grpc_channel(service_name: str = 'grpc', **kwargs)#

Build a gRPC channel to communicate with this instance.

The instance must be ready before calling this method.

Parameters:
service_namestr, optional

Custom service name. The default is grpc.

kwargs: list

Named argument to pass to the gRPC channel creation.

Returns:
grpc.Channel

gRPC channel preconfigured to work with the instance.

Raises:
InstanceNotReadyError

The instance is not yet ready.

UnsupportedServiceError

The instance does not support the service.

Examples

>>> import ansys.platform.instancemanagement as pypim
>>> from ansys.mapdl.core import Mapdl
>>> pim=pypim.connect()
>>> instance = pim.create_instance(product_name="mapdl", product_version="221")
>>> instance.wait_for_ready()
>>> channel = instance.build_grpc_channel(
>>>     options=[("grpc.max_receive_message_length", 8*1024**2)]
>>> )
>>> mapdl = Mapdl(channel=channel)
>>> print(mapdl)
>>> instance.delete()
    Product:             Ansys Mechanical Enterprise
    MAPDL Version:       22.1
    ansys.mapdl Version: 0.61.2

If the service exposes multiple ports, this method can be used to connect to another port by providing the service name:

>>> filemanagement_channel=instance.build_grpc_channel(service_name="filemanagement")