Server types#

Contains the different kinds of servers available for the factory.

ansys.dpf.core.server_types.check_valid_ip(ip)#

Check if a valid IP address is entered.

This method raises an error when an invalid IP address is entered.

ansys.dpf.core.server_types.launch_dpf(ansys_path, ip='127.0.0.1', port=50054, timeout=10, docker_name=None)#

Launch Ansys DPF.

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

  • ip (str, optional) – IP address of the remote or local instance to connect to. The default is "LOCALHOST".

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

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

  • docker_name (str, optional) – To start DPF server as a docker, specify the docker name here.

Returns

process – DPF Process.

Return type

subprocess.Popen

class ansys.dpf.core.server_types.BaseServer#

Abstract class for servers

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.

property info#

Server information.

Returns

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

Return type

dictionary

abstract property os#

Get the operating system of the server

Returns

os – “nt” or “posix”

Return type

str

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

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

class ansys.dpf.core.server_types.CServer(ansys_path=None, load_operators=True)#

Abstract class for servers going through the DPFClientAPI

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

property info#

Server information.

Returns

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

Return type

dictionary

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

abstract property os#

Get the operating system of the server

Returns

os – “nt” or “posix”

Return type

str

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.

class ansys.dpf.core.server_types.GrpcServer(ansys_path=None, ip='127.0.0.1', port=50054, timeout=10, as_global=True, load_operators=True, launch_server=True, docker_name=None, use_pypim=True)#

Server using the gRPC communication protocol

property os#

Get the operating system of the server

Returns

os – “nt” or “posix”

Return type

str

property address#

Address of the server.

Returns

address

Return type

str

property ip#

IP address of the server.

Returns

ip

Return type

str

property port#

Port of the server.

Returns

port

Return type

int

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

property info#

Server information.

Returns

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

Return type

dictionary

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

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.

class ansys.dpf.core.server_types.InProcessServer(ansys_path=None, as_global=True, load_operators=True, docker_name=None, timeout=None)#

Server using the InProcess communication protocol

property os#

Get the operating system of the server

Returns

os – “nt” or “posix”

Return type

str

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

property info#

Server information.

Returns

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

Return type

dictionary

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

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.

class ansys.dpf.core.server_types.LegacyGrpcServer(ansys_path=None, ip='127.0.0.1', port=50054, timeout=10, as_global=True, load_operators=True, launch_server=True, docker_name=None, use_pypim=True)#

Provides an instance of the DPF server using InProcess gRPC. Kept for backward-compatibility with dpf servers <0.5.0.

Parameters
  • ansys_path (str) – Path for the DPF executable.

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

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

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

  • 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.

  • load_operators (bool, optional) – Whether to automatically load the math operators. The default is True.

  • launch_server (bool, optional) – Whether to launch the server on Windows.

  • docker_name (str, optional) – To start DPF server as a docker, specify the docker name here.

  • use_pypim (bool, optional) – Whether to use PyPIM functionalities by default when a PyPIM environment is detected. Defaults to True.

property ip#

IP address of the server.

Returns

ip

Return type

str

property port#

Port of the server.

Returns

port

Return type

int

property version#

Version of the server.

Returns

version

Return type

str

property os#

Get the operating system of the server

Returns

os – “nt” or “posix”

Return type

str

property info#

Server information.

Returns

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

Return type

dictionary

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

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

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.

ansys.dpf.core.server_types.DpfServer#

alias of ansys.dpf.core.server_types.LegacyGrpcServer