file_transfer_service#

Provides a module for file transfer service.

Classes:

FileTransferStrategy(*args, **kwargs)

Provides the file transfer strategy.

LocalFileTransferStrategy([server_cwd])

Provides the local file transfer strategy can be used for Fluent launched in the standalone mode.

PimFileTransferService([pim_instance])

Provides a file transfer service based on PyPIM and the simple_upload_server() method.

RemoteFileTransferStrategy([image_name, ...])

Provides a file transfer service based on the gRPC client and gRPC server.

Exceptions:

PyPIMConfigurationError()

Raised when PyPIM<https://pypim.docs.pyansys.com/version/stable/> is not configured.

class ansys.fluent.core.utils.file_transfer_service.FileTransferStrategy(*args, **kwargs)#

Bases: Protocol

Provides the file transfer strategy.

Methods:

__init__(*args, **kwargs)

download(file_name[, local_directory])

Download a file from the server.

upload(file_name[, remote_file_name])

Upload a file to the server.

__init__(*args, **kwargs)#
download(file_name, local_directory=None)#

Download a file from the server.

Parameters:
file_namestr

File name.

local_directorystr, optional

Local directory. The default is None.

upload(file_name, remote_file_name=None)#

Upload a file to the server.

Parameters:
file_namestr

File name.

remote_file_namestr, optional

Remote file name. The default is None.

class ansys.fluent.core.utils.file_transfer_service.LocalFileTransferStrategy(server_cwd=None)#

Bases: FileTransferStrategy

Provides the local file transfer strategy can be used for Fluent launched in the standalone mode.

Examples

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
>>> mesh_file_name = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
>>> meshing_session = pyfluent.launch_fluent(mode=pyfluent.FluentMode.MESHING, file_transfer_service=LocalFileTransferStrategy())
>>> meshing_session.upload(file_name=mesh_file_name, remote_file_name="elbow.msh.h5")
>>> meshing_session.meshing.File.ReadMesh(FileName="elbow.msh.h5")
>>> meshing_session.meshing.File.WriteMesh(FileName="write_elbow.msh.h5")
>>> meshing_session.download(file_name="write_elbow.msh.h5", local_directory="<local_directory_path>")

Methods:

__init__([server_cwd])

Local File Transfer Service.

download(file_name[, local_directory])

Download a file from the server.

file_exists_on_remote(file_name)

Check if remote file exists.

upload(file_name[, remote_file_name])

Upload a file to the server.

__init__(server_cwd=None)#

Local File Transfer Service.

Parameters:
server_cwd: str, Optional

Current working directory of server/Fluent.

download(file_name, local_directory=None)#

Download a file from the server.

Parameters:
file_namelist[str] | str

File name.

local_directorystr, optional

Local directory. The default is None.

Examples

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
>>> mesh_file_name = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
>>> meshing_session = pyfluent.launch_fluent(mode=pyfluent.FluentMode.MESHING, file_transfer_service=LocalFileTransferStrategy())
>>> meshing_session.meshing.File.WriteMesh(FileName="write_elbow.msh.h5")
>>> meshing_session.download(file_name="write_elbow.msh.h5", local_directory="<local_directory_path>")
file_exists_on_remote(file_name)#

Check if remote file exists.

Parameters:
file_name: str

File name.

Returns:
Whether file exists.
upload(file_name, remote_file_name=None)#

Upload a file to the server.

Parameters:
file_namelist[str] | str

File name.

remote_file_namestr, optional

Remote file name. The default is None.

Raises:
FileNotFoundError

If a file does not exist.

Examples

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
>>> mesh_file_name = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
>>> meshing_session = pyfluent.launch_fluent(mode=pyfluent.FluentMode.MESHING, file_transfer_service=LocalFileTransferStrategy())
>>> meshing_session.upload(file_name=mesh_file_name, remote_file_name="elbow.msh.h5")
>>> meshing_session.meshing.File.ReadMesh(FileName="elbow.msh.h5")
class ansys.fluent.core.utils.file_transfer_service.PimFileTransferService(pim_instance=None)#

Bases: object

Provides a file transfer service based on PyPIM and the simple_upload_server() method.

Attributes:
pim_instance: PIM instance

Instance of PIM which supports upload server services.

file_service: Client instance

Instance of Client which supports upload and download methods.

Methods

upload(

file_name, remote_file_name ) Upload a file to the server.

download(

file_name, local_directory ) Download a file from the server.

Methods:

__init__([pim_instance])

download(file_name[, local_directory])

Download a file from the server.

download_file(file_name[, local_directory])

Download a file from the server supported by PyPIM<https://pypim.docs.pyansys.com/version/stable/>.

file_exists_on_remote(file_name)

Check if remote file exists.

is_configured()

Check pypim configuration.

upload(file_name[, remote_file_name])

Upload a file to the server.

upload_file(file_name[, remote_file_name])

Upload a file to the server supported by PyPIM<https://pypim.docs.pyansys.com/version/stable/>.

__init__(pim_instance=None)#
download(file_name, local_directory='.')#

Download a file from the server.

Parameters:
file_namelist[str] | str

File name.

local_directorystr, optional

Local directory. The default is the current working directory.

download_file(file_name, local_directory=None)#

Download a file from the server supported by PyPIM<https://pypim.docs.pyansys.com/version/stable/>.

Parameters:
file_namestr

File name.

local_directorystr, optional

local directory, by default None

Raises:
FileNotFoundError

If the remote file does not exist.

PyPIMConfigurationError

If PyPIM is not configured.

file_exists_on_remote(file_name)#

Check if remote file exists.

Parameters:
file_name: str

File name.

Returns:
Whether file exists.
is_configured()#

Check pypim configuration.

upload(file_name, remote_file_name=None)#

Upload a file to the server.

Parameters:
file_namelist[str] | str

File name.

remote_file_namestr, optional

Remote file name. The default is None.

Raises:
FileNotFoundError

If a file does not exist.

upload_file(file_name, remote_file_name=None)#

Upload a file to the server supported by PyPIM<https://pypim.docs.pyansys.com/version/stable/>.

Parameters:
file_namestr

File name.

remote_file_namestr, optional

Remote file name. The default is None.

Raises:
FileNotFoundError

If the file does not exist.

PyPIMConfigurationError

If PyPIM is not configured.

exception ansys.fluent.core.utils.file_transfer_service.PyPIMConfigurationError#

Bases: ConnectionError

Raised when PyPIM<https://pypim.docs.pyansys.com/version/stable/> is not configured.

__init__()#
class ansys.fluent.core.utils.file_transfer_service.RemoteFileTransferStrategy(image_name=None, image_tag=None, port=None, mount_target=None, mount_source=None)#

Bases: FileTransferStrategy

Provides a file transfer service based on the gRPC client and gRPC server.

Examples

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import RemoteFileTransferStrategy
>>> case_file_name = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
>>> solver_session = pyfluent.launch_fluent(mode=pyfluent.FluentMode.SOLVER, file_transfer_service=RemoteFileTransferStrategy())
>>> solver_session.upload(file_name=case_file_name, remote_file_name="elbow.cas.h5")
>>> solver_session.file.read_case(file_name="elbow.cas.h5")
>>> solver_session.file.write_case(file_name="write_elbow.cas.h5")
>>> solver_session.download(file_name="write_elbow.cas.h5", local_directory="<local_directory_path>")

Methods:

__init__([image_name, image_tag, port, ...])

Provides the gRPC-based remote file transfer strategy.

download(file_name[, local_directory])

Download a file from the server.

file_exists_on_remote(file_name)

Check if remote file exists.

upload(file_name[, remote_file_name])

Upload a file to the server.

__init__(image_name=None, image_tag=None, port=None, mount_target=None, mount_source=None)#

Provides the gRPC-based remote file transfer strategy.

Parameters:
image_name: str

Name of the image.

image_tagstr, optional

Tag of the image.

port: int, optional

Port for the file transfer service to use.

mount_target: str | Path, optional

Path inside the container where mount_source will be mounted to.

mount_source: str | Path, optional

Existing path in the host operating system that will be mounted to mount_target.

download(file_name, local_directory=None)#

Download a file from the server.

Parameters:
file_namelist[str] | str

File name.

local_directorystr, optional

Local directory. The default is None.

Examples

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import RemoteFileTransferStrategy
>>> case_file_name = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
>>> solver_session = pyfluent.launch_fluent(mode=pyfluent.FluentMode.SOLVER, file_transfer_service=RemoteFileTransferStrategy())
>>> solver_session.file.write_case(file_name="write_elbow.cas.h5")
>>> solver_session.download(file_name="write_elbow.cas.h5", local_directory="<local_directory_path>")
file_exists_on_remote(file_name)#

Check if remote file exists.

Parameters:
file_name: str

File name.

Returns:
Whether file exists.
upload(file_name, remote_file_name=None)#

Upload a file to the server.

Parameters:
file_namelist[str] | str

File name.

remote_file_namestr, optional

Remote file name. The default is None.

Raises:
FileNotFoundError

If a file does not exist.

Examples

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import RemoteFileTransferStrategy
>>> case_file_name = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
>>> solver_session = pyfluent.launch_fluent(mode=pyfluent.FluentMode.SOLVER, file_transfer_service=RemoteFileTransferStrategy())
>>> solver_session.upload(file_name=case_file_name, remote_file_name="elbow.cas.h5")
>>> solver_session.file.read_case(file_name="elbow.cas.h5")