file_transfer_service#
Provides a module for file transfer service.
Classes:
|
Provides the file transfer strategy. |
|
Provides the local file transfer strategy can be used for Fluent launched in the standalone mode. |
|
Provides a file transfer service based on PyPIM and the |
|
Provides a file transfer service based on the gRPC client and gRPC server. |
Exceptions:
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.
- 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:
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:
- 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])Initialize PimFileTransferService.
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.
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)#
Initialize PimFileTransferService.
- Parameters:
- pim_instance: Any, optional
PIM instance.
- download(file_name, local_directory='.')#
Download a file from the server.
- download_file(file_name, local_directory=None)#
Download a file from the server supported by PyPIM<https://pypim.docs.pyansys.com/version/stable/>.
- Parameters:
- 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:
- 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:
- 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.
Methods:
__init__
()Initialize PyPIMConfigurationError.
- __init__()#
Initialize PyPIMConfigurationError.
- 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_tag
str
,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:
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:
- 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")