The core.py module#

Summary#

BaseService

The Base Service class allows to make generic requests to dpf’s server.

load_library

Load a DPF plugin (a binary library of operators).

upload_file_in_tmp_folder

Upload a file from the client to a temporary server folder deleted on server shutdown.

upload_files_in_folder

Upload all the files from a folder of the client to the target server folder path.

download_file

Download a file from the server to the target client file path.

download_files_in_folder

Download all the files from a folder of the server to the target client folder path.

upload_file

Upload a file from the client to the target server file path.

make_tmp_dir_server

Create a temporary folder server side. Only one temporary folder can be created by server instance.

Description#

Core.

Module detail#

core.load_library(filename: str | pathlib.Path, name: str = None, symbol: str = 'LoadOperators', server: ansys.dpf.core.AnyServerType = None, generate_operators: bool = False) str#

Load a DPF plugin (a binary library of operators).

Set generate_operators=True to also make the operators available in the current installation of ansys-dpf-core.

Parameters:
  • filename – Filename or path to the operator library.

  • name – Name to give the plugin once loaded. Defaults to the name of the library file.

  • symbol – The name of the entrypoint of the plugin, which is the function recording the operators.

  • server – Server to load the plugin onto. Defaults to the global server.

  • generate_operators – Whether to generate the Python modules for the operators of the library. This updates the ansys.dpf.core.operators package of the current installation.

Examples

Load the mesh operators for Windows (for Linux, just use ‘libmeshOperatorsCore.so’ instead of ‘meshOperatorsCore.dll’)

>>> from ansys.dpf import core as dpf
>>> # dpf.load_library('meshOperatorsCore.dll', 'mesh_operators')
core.upload_file_in_tmp_folder(file_path, new_file_name=None, server=None)#

Upload a file from the client to a temporary server folder deleted on server shutdown.

Parameters:
  • file_path (str or os.PathLike) – file path on the client side to upload

  • new_file_name (str, optional) – name to give to the file server side, if no name is specified, the same name as the input file is given

  • server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the global server.

Returns:

server_file_path – path generated server side

Return type:

str

Notes

Is not implemented for usage with type(server)= ansys.dpf.core.server_types.InProcessServer.

core.upload_files_in_folder(to_server_folder_path, client_folder_path, specific_extension=None, server=None)#

Upload all the files from a folder of the client to the target server folder path.

Parameters:
  • to_server_folder_path (str or os.PathLike) – folder path target where will be uploaded files on the server side

  • client_folder_path (str or os.PathLike) – folder path where the files that must be uploaded are located on client side

  • (optional) (specific_extension) – copies only the files with the given extension

  • server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the global server.

Returns:

paths – new file paths server side

Return type:

list of str

core.download_file(server_file_path, to_client_file_path, server=None)#

Download a file from the server to the target client file path.

Parameters:
  • server_file_path (str or os.PathLike) – file path to download on the server side

  • to_client_file_path (str or os.PathLike) – file path target where the file will be located client side

  • server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the global server.

Notes

Is not implemented for usage with type(server)= ansys.dpf.core.server_types.InProcessServer.

core.download_files_in_folder(server_folder_path, to_client_folder_path, specific_extension=None, server=None)#

Download all the files from a folder of the server to the target client folder path.

Parameters:
  • server_folder_path (str or os.PathLike) – folder path to download on the server side

  • to_client_folder_path (str or os.PathLike) – folder path target where the files will be located client side

  • (optional) (specific_extension) – copies only the files with the given extension

  • server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the global server.

Returns:

paths – new file paths client side

Return type:

list of str

core.upload_file(file_path, to_server_file_path, server=None)#

Upload a file from the client to the target server file path.

Parameters:
  • file_path (str or os.PathLike) – file path on the client side to upload

  • to_server_file_path (str or os.PathLike) – file path target where the file will be located server side

  • server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the global server.

Returns:

server_file_path – path generated server side

Return type:

str

core.make_tmp_dir_server(server=None)#

Create a temporary folder server side. Only one temporary folder can be created by server instance.

The folder will be deleted when the server is stopped.

Parameters:

server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the global server.

Returns:

path – path to the temporary dir

Return type:

str

core.LOG#
core.CONFIGURATION#