ServerConnection#

class ansys.additive.core.server_connection.server_connection.ServerConnection(channel: grpc.Channel | None = None, addr: str | None = None, product_version: str = DEFAULT_PRODUCT_VERSION, log: logging.Logger = None, linux_install_path: os.PathLike | None = None)#

Provides connection to Additive server.

If neither channel nor addr are provided, an attempt is made to start an Additive server and connect to it. Starting a server in a cloud environment requires PyPIM to be available. To start a server when running on localhost, the Additive option of the Structures package of the Ansys unified installation must be installed.

Parameters:
channel: grpc.Channel, None

gRPC channel connected to server.

addr: str, None

IPv4 address of server of the form host:port.

product_version: str

Version of the Ansys product installation in the form "YYR", where YY is the two-digit year and R is the release number. For example, the release 2024 R1 would be specified as 241. This parameter is only applicable in PyPIM-enabled cloud environments and on localhost.

log: logging.Logger, None

Log to write connection messages to.

linux_install_path: os.PathLike, None default: None

Path to the Ansys installation directory on Linux. This parameter is only required when Ansys has not been installed in the default location. Example: /usr/shared/ansys_inc. Note that the path should not include the product version.

Overview#

status

Return the server connection status.

ready

Return whether the server is ready.

channel_str

GRPC channel target.

materials_stub

Materials service stub.

simulation_stub

Simulation service stub.

operations_stub

Operations service stub.

settings_stub

Settings service stub.

__del__

Destructor for cleaning up server connection.

Import detail#

from ansys.additive.core.server_connection.server_connection import ServerConnection

Property detail#

property ServerConnection.channel_str: str#

GRPC channel target.

The form is generally "ip:port". For example, "127.0.0.1:50052".

property ServerConnection.materials_stub: ansys.api.additive.v0.additive_materials_pb2_grpc.MaterialsServiceStub#

Materials service stub.

property ServerConnection.simulation_stub: ansys.api.additive.v0.additive_simulation_pb2_grpc.SimulationServiceStub#

Simulation service stub.

property ServerConnection.operations_stub: google.longrunning.operations_pb2_grpc.OperationsStub#

Operations service stub.

property ServerConnection.settings_stub: ansys.api.additive.v0.additive_settings_pb2_grpc.SettingsServiceStub#

Settings service stub.

Method detail#

ServerConnection.__del__()#

Destructor for cleaning up server connection.

ServerConnection.status() ServerConnectionStatus#

Return the server connection status.

ServerConnection.ready(retries: int = 5) bool#

Return whether the server is ready.

Parameters:
retries: int

Number of times to retry before giving up. An linearly increasing delay is used between each retry.

Returns:
bool:

True means server is ready. False means the number of retries was exceeded without receiving a response from the server.