Specify file paths#

Functions to download sample datasets from the Ansys example data repository.

Exceptions:

RemoteFileNotFoundError(url)

Raised on an attempt to download a non-existent remote file.

Functions:

delete_downloads()

Delete all downloaded examples from the default examples folder to free space or update the files.

download_file(file_name[, directory, ...])

Download specified example file from the Ansys example data repository.

path(file_name)

Return path of given file name.

exception ansys.fluent.core.examples.downloads.RemoteFileNotFoundError(url)#

Bases: FileNotFoundError

Raised on an attempt to download a non-existent remote file.

__init__(url)#
ansys.fluent.core.examples.downloads.delete_downloads()#

Delete all downloaded examples from the default examples folder to free space or update the files.

Notes

The default examples path is given by pyfluent.EXAMPLES_PATH.

ansys.fluent.core.examples.downloads.download_file(file_name, directory=None, save_path=None, return_without_path=None)#

Download specified example file from the Ansys example data repository.

Parameters:
file_namestr

File to download.

directorystr, optional

Ansys example data repository directory where specified file is located. If not specified, looks for the file in the root directory of the repository.

save_pathstr, optional

Path to download the specified file to.

return_without_pathbool, optional

When unspecified, defaults to False, unless the PYFLUENT_LAUNCH_CONTAINER=1 environment variable is specified, in which case defaults to True. Relevant when using Fluent Docker container images, as the full path for the imported file from the host side is not necessarily going to be the same as the one for Fluent inside the container. Assuming the Fluent inside the container has its working directory set to the path that was mounted from the host, and that the example files are being made available by the host through this same path, only the file name is required for Fluent to find and open the file.

Returns:
str

file path of the downloaded or already existing file, or only the file name if return_without_path=True.

Raises:
RemoteFileNotFoundError

If remote file does not exist.

Examples

>>> from ansys.fluent.core import examples
>>> file_path = examples.download_file("bracket.iges", "geometry")
>>> file_path
'/home/user/.local/share/ansys_fluent_core/examples/bracket.iges'
>>> file_name = examples.download_file("bracket.iges", "geometry", return_without_path=True)
>>> file_name
'bracket.iges'
>>> file_path = examples.download_file("bracket.iges", "geometry", save_path='.')
'/home/<current_folder_path>/bracket.iges'
>>> file_name = examples.download_file("bracket.iges", "geometry", save_path='.', return_without_path=True)
>>> file_name
'bracket.iges'
>>> file_path = examples.download_file("bracket.iges", "geometry", save_path='<user_specified_path>')
'/home/<user_specified_path>/bracket.iges'
>>> file_name = examples.download_file("bracket.iges", "geometry", save_path='<user_specified_path>',
...                                   return_without_path=True)
>>> file_name
'bracket.iges'
ansys.fluent.core.examples.downloads.path(file_name)#

Return path of given file name.

Parameters:
file_namestr

Name of the file.

Returns:
file_path: str

File path.

Raises:
FileNotFoundError

If file does not exist.