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)#

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.

ansys.dpf.core.server_types.launch_dpf_on_docker(running_docker_config=<ansys.dpf.core.server_factory.RunningDockerConfig object>, ansys_path=None, ip='127.0.0.1', port=50054, timeout=10.0)#

Launch Ansys DPF.

Parameters:
  • running_docker_config (server_factory.RunningDockerConfig, optional) – To start DPF server as a docker, specify the docker configurations here.

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

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", "server_version" , "os" and "path" keys.

Return type:

dictionary

property session#

Allows to plan events call backs from the server: progress bar when workflows are running, logging…

Return type:

ansys.dpf.core.session.Session

abstract property os#

Get the operating system of the server

Returns:

os – “nt” or “posix”

Return type:

str

release()#

Clears the available Operators and Releases licenses when necessary.

Notes

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

apply_context(context)#

Defines 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).

property 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

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

apply_context(context)#

Defines 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).

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

property 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

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

release()#

Clears the available Operators and Releases licenses when necessary.

Notes

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

property session#

Allows to plan events call backs from the server: progress bar when workflows are running, logging…

Return type:

ansys.dpf.core.session.Session

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: str | None = None, ip: str = '127.0.0.1', port: str = 50054, timeout: float = 10.0, as_global: bool = True, load_operators: bool = True, launch_server: bool = True, docker_config: ansys.dpf.core.server_factory.DockerConfig = <ansys.dpf.core.server_factory.DockerConfig object>, use_pypim: bool = True, num_connection_tryouts: int = 3, context: ansys.dpf.core.server_context.AvailableServerContexts = <ansys.dpf.core.server_context.ServerContext object>)#

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

property 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 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

apply_context(context)#

Defines 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).

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

property 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

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

release()#

Clears the available Operators and Releases licenses when necessary.

Notes

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

property session#

Allows to plan events call backs from the server: progress bar when workflows are running, logging…

Return type:

ansys.dpf.core.session.Session

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: str | None = None, as_global: bool = True, load_operators: bool = True, timeout: None = None, context: ansys.dpf.core.server_context.AvailableServerContexts = <ansys.dpf.core.server_context.ServerContext object>)#

Server using the InProcess communication protocol

property os#

Get the operating system of the server

Returns:

os – “nt” or “posix”

Return type:

str

apply_context(context)#

Defines 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).

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

property 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

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

release()#

Clears the available Operators and Releases licenses when necessary.

Notes

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

property session#

Allows to plan events call backs from the server: progress bar when workflows are running, logging…

Return type:

ansys.dpf.core.session.Session

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.get_system_path()#

Return the current PATH environment variable value of the system.

Return type:

str

class ansys.dpf.core.server_types.LegacyGrpcServer(ansys_path: str | None = None, ip: str = '127.0.0.1', port: str = 50054, timeout: float = 5.0, as_global: bool = True, load_operators: bool = True, launch_server: bool = True, docker_config: ansys.dpf.core.server_factory.DockerConfig = <ansys.dpf.core.server_factory.DockerConfig object>, use_pypim: bool = True, context: ansys.dpf.core.server_context.AvailableServerContexts = <ansys.dpf.core.server_context.ServerContext object>)#

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_config (server_factory.DockerConfig, 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.

apply_context(context)#

Defines 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).

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

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

release()#

Clears the available Operators and Releases licenses when necessary.

Notes

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

property session#

Allows to plan events call backs from the server: progress bar when workflows are running, logging…

Return type:

ansys.dpf.core.session.Session

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 ip#

IP address of the server.

Returns:

ip

Return type:

str

property port#

Port of the server.

Returns:

port

Return type:

int

property external_ip#

Public IP address of the server. Is the same as ansys.dpf.core.LegacyGrpcServer.ip() in all cases except for servers using a gateway: for example, servers running in Docker Images might have an internal ansys.dpf.core.LegacyGrpcServer.ip() different from the public ansys.dpf.core.LegacyGrpcServer.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 external_port#

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

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", "server_version" , "os" and "path" keys.

Return type:

dictionary

ansys.dpf.core.server_types.DpfServer#

alias of LegacyGrpcServer