build_grpc_channel#
- Instance.build_grpc_channel(service_name: str = 'grpc', **kwargs) Channel#
Build a gRPC channel to communicate with this instance.
The instance must be ready before calling this method. The channel is automatically secured using the transport the server reported for this service (see
Service.transport); you do not need to build the credentials yourself. See Security.- Parameters:
- service_name
str,optional Custom service name. The default is
grpc.- kwargs: list
Named argument to pass to the gRPC channel creation.
- service_name
- Returns:
grpc.ChannelgRPC channel preconfigured to work with the instance.
- Raises:
InstanceNotReadyErrorThe instance is not yet ready.
UnsupportedServiceErrorThe 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")