ServerConfig
#
- class ansys.dpf.core.server_factory.ServerConfig(protocol: str = DEFAULT_COMMUNICATION_PROTOCOL, legacy: bool = DEFAULT_LEGACY)#
Provides an instance of ServerConfig object to manage the server type used.
The default parameters can be overwritten using the DPF_SERVER_TYPE environment variable. DPF_SERVER_TYPE=INPROCESS, DPF_SERVER_TYPE=GRPC, DPF_SERVER_TYPE=LEGACYGRPC can be used.
- Parameters:
protocol (CommunicationProtocols, optional) – Communication protocol for DPF server (e.g. InProcess, gRPC)
legacy (bool, optional) – If legacy is set to True, the server will be using ansys-grpc-dpf Python module. If not, it will communicate with DPF binaries using ctypes and DPF CLayer calls.
Examples
Use constructor parameters to manually create servers.
>>> from ansys.dpf import core as dpf >>> in_process_config = dpf.ServerConfig( ... protocol=dpf.server_factory.CommunicationProtocols.InProcess, legacy=False) >>> grpc_config = dpf.ServerConfig( ... protocol=dpf.server_factory.CommunicationProtocols.gRPC, legacy=False) >>> legacy_grpc_config = dpf.ServerConfig( ... protocol=dpf.server_factory.CommunicationProtocols.gRPC, legacy=True) >>> in_process_server = dpf.start_local_server(config=in_process_config, as_global=False) >>> grpc_server = dpf.start_local_server(config=grpc_config, as_global=False) >>> legacy_grpc_server = dpf.start_local_server(config=legacy_grpc_config, as_global=False)
Use the environment variable to set the default server configuration.
>>> import os >>> os.environ["DPF_SERVER_TYPE"] = "INPROCESS" >>> dpf.start_local_server()
Overview#
Import detail#
from ansys.dpf.core.server_factory import ServerConfig
Attribute detail#
- ServerConfig.legacy#
Method detail#
- ServerConfig.__str__()#
Return a string representation of the ServerConfig instance.
This method provides a human-readable string summarizing the server configuration, including the protocol and whether it’s using legacy gRPC.
- Returns:
String representation of the ServerConfig instance.
- Return type:
str
- ServerConfig.__eq__(other: ServerConfig)#
Check if two ServerConfig instances are equal.
Compares the current ServerConfig instance with another one to check if they have the same protocol and legacy status.
- Parameters:
other (ServerConfig) – The other ServerConfig instance to compare with.
- Returns:
True if the instances have the same protocol and legacy status, False otherwise.
- Return type:
bool
- ServerConfig.__ne__(other)#
Check if two ServerConfig instances are not equal.
Compares the current ServerConfig instance with another one to check if they have different protocol or legacy status.
- Parameters:
other (ServerConfig) – The other ServerConfig instance to compare with.
- Returns:
True if the instances have different protocol or legacy status, False otherwise.
- Return type:
bool