GrpcClient#

class ansys.geometry.core.connection.client.GrpcClient(host: str = pygeom_defaults.DEFAULT_HOST, port: str | int = pygeom_defaults.DEFAULT_PORT, channel: grpc.Channel | None = None, remote_instance: ansys.platform.instancemanagement.Instance | None = None, docker_instance: ansys.geometry.core.connection.docker_instance.LocalDockerInstance | None = None, product_instance: ansys.geometry.core.connection.product_instance.ProductInstance | None = None, timeout: ansys.geometry.core.typing.Real = 120, logging_level: int = logging.INFO, logging_file: pathlib.Path | str | None = None, proto_version: str | None = None, transport_mode: str | None = None, uds_dir: pathlib.Path | str | None = None, uds_id: str | None = None, certs_dir: pathlib.Path | str | None = None)#

Wraps the gRPC connection for the Geometry service.

Parameters:
hoststr, default: DEFAULT_HOST

Host where the server is running.

portstr or int, default: DEFAULT_PORT

Port number where the server is running.

channelChannel, default: None

gRPC channel for server communication.

remote_instanceansys.platform.instancemanagement.Instance, default: None

Corresponding remote instance when the Geometry service is launched through PyPIM. This instance is deleted when calling the GrpcClient.close method.

docker_instanceLocalDockerInstance, default: None

Corresponding local Docker instance when the Geometry service is launched using the launch_docker_modeler() method. This local Docker instance is deleted when the GrpcClient.close method is called.

product_instanceProductInstance, default: None

Corresponding local product instance when the product (Discovery or SpaceClaim) is launched through the launch_modeler_with_geometry_service(), launch_modeler_with_discovery() or the launch_modeler_with_spaceclaim() interface. This instance will be deleted when the GrpcClient.close method is called.

timeoutreal, default: 120

Maximum time to spend trying to make the connection.

logging_levelint, default: INFO

Logging level to apply to the client.

logging_filestr or Path, default: None

File to output the log to, if requested.

proto_versionstr | None, default: None

Protocol version to use for communication with the server. If None, v0 is used. Available versions are “v0”, “v1”, etc.

transport_modestr | None

Transport mode selected. Needed if channel is not provided. Options are: “insecure”, “uds”, “wnua”, “mtls”.

uds_dirPath | str | None

Directory to use for Unix Domain Sockets (UDS) transport mode. By default None and thus it will use the “~/.conn” folder.

uds_idstr | None

Optional ID to use for the UDS socket filename. By default None and thus it will use “aposdas_socket.sock”. Otherwise, the socket filename will be “aposdas_socket-.sock”.

certs_dirPath | str | None

Directory to use for TLS certificates. By default None and thus search for the “ANSYS_GRPC_CERTIFICATES” environment variable. If not found, it will use the “certs” folder assuming it is in the current working directory.

Overview#

backend_info

Get a string with the backend information.

close

Close the channel.

target

Get the target of the channel.

get_name

Get the target name of the connection.

backend_type

Backend type.

backend_version

Get the current backend version.

channel

Client gRPC channel.

services

GRPC services.

log

Specific instance logger.

is_closed

Flag indicating whether the client connection is closed.

healthy

Flag indicating whether the client channel is healthy.

__repr__

Represent the client as a string.

Import detail#

from ansys.geometry.core.connection.client import GrpcClient

Property detail#

property GrpcClient.backend_type: ansys.geometry.core.connection.backend.BackendType#

Backend type.

Options are Windows Service, Linux Service, Discovery, and SpaceClaim.

Notes

This method might return None because determining the backend type is not straightforward.

property GrpcClient.backend_version: semver.version.Version#

Get the current backend version.

Returns:
Version

Backend version.

property GrpcClient.channel: grpc.Channel#

Client gRPC channel.

property GrpcClient.services: ansys.geometry.core._grpc._services._service._GRPCServices#

GRPC services.

property GrpcClient.log: ansys.geometry.core.logger.PyGeometryCustomAdapter#

Specific instance logger.

property GrpcClient.is_closed: bool#

Flag indicating whether the client connection is closed.

property GrpcClient.healthy: bool#

Flag indicating whether the client channel is healthy.

Method detail#

GrpcClient.backend_info(indent=0) str#

Get a string with the backend information.

Returns:
str

String with the backend information.

GrpcClient.__repr__() str#

Represent the client as a string.

GrpcClient.close()#

Close the channel.

Notes

If an instance of the Geometry service was started using PyPIM, this instance is deleted. Furthermore, if a local Docker instance of the Geometry service was started, it is stopped.

GrpcClient.target() str#

Get the target of the channel.

GrpcClient.get_name() str#

Get the target name of the connection.