GrpcServer#

class ansys.dpf.core.server_types.GrpcServer(ansys_path: str | None = None, ip: str = LOCALHOST, port: str = DPF_DEFAULT_PORT, timeout: float = 10.0, as_global: bool = True, load_operators: bool = True, launch_server: bool = True, docker_config: ansys.dpf.core.server_factory.DockerConfig = RUNNING_DOCKER, use_pypim: bool = True, context: ansys.dpf.core.server_context.ServerContext = server_context.SERVER_CONTEXT, grpc_mode: ansys.dpf.core.server_factory.GrpcMode = server_factory.DEFAULT_GRPC_MODE, certificates_dir: pathlib.Path = None)#

Bases: CServer

Server using the gRPC communication protocol.

Parameters:
  • ansys_path – Root path for the Ansys installation directory. For example, "/ansys_inc/v212/". The default is the latest Ansys installation.

  • ip – IP address of the remote or local instance to connect to. The default is "LOCALHOST".

  • port – Port to connect to the remote instance on. The default is "DPF_DEFAULT_PORT", which is 50054.

  • timeout – Maximum number of seconds for the initialization attempt. The default is 10. Once the specified number of seconds passes, the connection fails.

  • as_global – Set this server as the global server used by default by PyDPF. The default is True.

  • load_operators – Whether to load the operators upon server initialization. The default is True.

  • launch_server – Whether to launch a new server process. If False, connects to an existing server. The default is True.

  • docker_config – To start DPF server as a docker, specify the docker configurations here.

  • use_pypim – Whether to use PyPIM to launch a remote DPF server if PyPIM is configured. The default is True.

  • context – Context to apply to DPF server when launching it.

  • grpc_mode – Grpc mode to use when launching DPF server. Can be one of the members of ansys.dpf.core.server_factory.GrpcMode. Defaults to mTLS authenticated mode.

  • certificates_dir – Path to a directory containing the certificates to use for mTLS authentication.

Overview#

shutdown

Shutdown the server instance.

get_api_for_type

Return api for type.

set_as_global

Set the current server as global if necessary.

has_client

Check if server has a connected client.

release

Clear the available Operators and Releases licenses when necessary.

apply_context

Define the settings that will be used to load DPF’s plugins.

check_version

Check if the server version matches with a required version.

meet_version

Check if the server version matches with a required version.

version

Get the version of the server.

os

Get the operating system on which the server is running.

client

Get the client associated with the server.

address

Address of the server.

ip

IP address of the server.

port

Port of the server.

external_ip

Public IP address of the server.

external_port

Public Port of the server.

local_server

Get whether the server is running locally.

config

Get the server configuration for the gRPC server.

available_api_types

Return available api type, always c_api.

plugins

Return the list of plugins loaded on the server.

info

Server information.

session

Plan event callbacks from the server, such as progress bars during workflow execution and logging.

on_docker

Whether the DPF server should be started in a Docker Container by default.

docker_config

Return the docker config associated with the server.

context

Returns the settings used to load DPF’s plugins.

__eq__

Return true, if * are equals.

__del__

Clean up resources associated with the instance.

__str__

Return string representation of the instance.

__ne__

Return true, if the servers are not equal.

Import detail#

from ansys.dpf.core.server_types import GrpcServer

Property detail#

property GrpcServer.version#

Get the version of the server.

Returns:

version – The version of the server in ‘major.minor’ format.

Return type:

str

property GrpcServer.os#

Get the operating system on which the server is running.

property GrpcServer.client#

Get the client associated with the server.

Returns:

client – The GrpcClient instance associated with the server.

Return type:

GrpcClient

property GrpcServer.address#

Address of the server.

Returns:

address

Return type:

str

property GrpcServer.ip#

IP address of the server.

Returns:

ip

Return type:

str

property GrpcServer.port#

Port of the server.

Returns:

port

Return type:

int

property GrpcServer.external_ip#

Public IP address of the server.

Is the same as ansys.dpf.core.GrpcServer.ip() in all cases except for servers using a gateway: for example, servers running in Docker Images might have an internal ansys.dpf.core.GrpcServer.ip() different from the public ansys.dpf.core.GrpcServer.external_ip(), the latter should be used to get connected to the server from outside the Docker Image.

Returns:

external_ip

Return type:

str

property GrpcServer.external_port#

Public Port of the server.

Is the same as ansys.dpf.core.GrpcServer.port() in all cases except for servers using a gateway: for example, servers running in Docker Images might have an internal ansys.dpf.core.GrpcServer.port() different from the public ansys.dpf.core.GrpcServer.external_port(), the latter should be used to get connected to the server from outside the Docker Image.

Returns:

port

Return type:

int

property GrpcServer.local_server#

Get whether the server is running locally.

Returns:

local_server – True if the server is running locally, False otherwise.

Return type:

bool

property GrpcServer.config#

Get the server configuration for the gRPC server.

Returns:

config – The server configuration for the gRPC server from the AvailableServerConfigs.

Return type:

AvailableServerConfigs

property GrpcServer.available_api_types#

Return available api type, always c_api.

property GrpcServer.plugins: dict#

Return the list of plugins loaded on the server.

property GrpcServer.info#

Server information.

Returns:

info – Dictionary with server information, including "server_ip", "server_port", "server_process_id", "server_version" , "os" and "path" keys.

Return type:

dictionary

property GrpcServer.session#

Plan event callbacks from the server, such as progress bars during workflow execution and logging.

Return type:

ansys.dpf.core.session.Session

property GrpcServer.on_docker#

Whether the DPF server should be started in a Docker Container by default.

property GrpcServer.docker_config#

Return the docker config associated with the server.

property GrpcServer.context#

Returns the settings used to load DPF’s plugins.

To update the context server side, use ansys.dpf.core.BaseServer.server_types.apply_context()

Return type:

ServerContext

Attribute detail#

GrpcServer.live = False#
GrpcServer.ansys_path = None#
GrpcServer.__slots__ = ()#

Method detail#

GrpcServer.shutdown()#

Shutdown the server instance.

GrpcServer.__eq__(other_server)#

Return true, if * are equals.

GrpcServer.get_api_for_type(capi, grpcapi)#

Return api for type.

GrpcServer.__del__()#

Clean up resources associated with the instance.

Raises:

Warning – If an exception occurs while attempting to delete resources.

GrpcServer.set_as_global(as_global=True)#

Set the current server as global if necessary.

Parameters:

as_global (bool, optional) – Global variable that stores the IP address and port for the DPF module. All DPF objects created in this Python session will use this IP and port. The default is True.

GrpcServer.has_client()#

Check if server has a connected client.

GrpcServer.release()#

Clear the available Operators and Releases licenses when necessary.

Notes

Available with server’s version starting at 6.0 (Ansys 2023R2).

GrpcServer.apply_context(context)#

Define the settings that will be used to load DPF’s plugins.

A DPF xml file can be used to list the plugins and set up variables.

Parameters:

context (ServerContext) – The context allows to choose which capabilities are available server side.

Notes

Available with server’s version starting at 6.0 (Ansys 2023R2).

GrpcServer.check_version(required_version, msg=None)#

Check if the server version matches with a required version.

Parameters:
  • required_version (str) – Required version to compare with the server version.

  • msg (str, optional) – Message for the raised exception if version requirements do not match.

:raises dpf_errors : errors: errors.DpfVersionNotSupported is raised if failure.

Returns:

True if the server version meets the requirement.

Return type:

bool

GrpcServer.meet_version(required_version)#

Check if the server version matches with a required version.

Parameters:

required_version (str) – Required version to compare with the server version.

Returns:

True if the server version meets the requirement.

Return type:

bool

GrpcServer.__str__()#

Return string representation of the instance.

GrpcServer.__ne__(other_server)#

Return true, if the servers are not equal.